Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
cheprep::DefaultHepRepAttValue Class Reference

#include <DefaultHepRepAttValue.h>

+ Inheritance diagram for cheprep::DefaultHepRepAttValue:

Public Member Functions

 DefaultHepRepAttValue (std::string name, std::string value, int showLabel)
 
 DefaultHepRepAttValue (std::string name, int64 value, int showLabel)
 
 DefaultHepRepAttValue (std::string name, int value, int showLabel)
 
 DefaultHepRepAttValue (std::string name, double value, int showLabel)
 
 DefaultHepRepAttValue (std::string name, bool value, int showLabel)
 
 DefaultHepRepAttValue (std::string name, std::vector< double > value, int showLabel)
 
 ~DefaultHepRepAttValue ()
 
HEPREP::HepRepAttValuecopy ()
 
std::string getName ()
 
std::string getLowerCaseName ()
 
int getType ()
 
std::string getTypeName ()
 
int showLabel ()
 
std::string getString ()
 
std::string getLowerCaseString ()
 
int64 getLong ()
 
int getInteger ()
 
double getDouble ()
 
bool getBoolean ()
 
std::vector< double > getColor ()
 
std::string getAsString ()
 
std::string toShowLabel ()
 
- Public Member Functions inherited from HEPREP::HepRepAttValue
virtual ~HepRepAttValue ()
 Destructor.
 
virtual std::string getName ()=0
 
virtual std::string getLowerCaseName ()=0
 
virtual int getType ()=0
 
virtual std::string getTypeName ()=0
 
virtual int showLabel ()=0
 
virtual std::string getString ()=0
 
virtual std::string getLowerCaseString ()=0
 
virtual std::string getAsString ()=0
 
virtual std::vector< double > getColor ()=0
 
virtual int64 getLong ()=0
 
virtual int getInteger ()=0
 
virtual double getDouble ()=0
 
virtual bool getBoolean ()=0
 
virtual HepRepAttValuecopy ()=0
 

Static Public Member Functions

static std::string getAsString (std::vector< double > c)
 
static std::string getAsString (int i)
 
static std::string getAsString (int64 i)
 
static std::string getAsString (double d)
 
static std::string getAsString (bool b)
 
static std::string toShowLabel (int showLabel)
 

Detailed Description

Definition at line 17 of file DefaultHepRepAttValue.h.

Constructor & Destructor Documentation

◆ DefaultHepRepAttValue() [1/6]

cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
std::string  value,
int  showLabel 
)

Definition at line 27 of file DefaultHepRepAttValue.cc.

28 : name(aName), type(HepRepConstants::TYPE_STRING), stringValue(aValue), showLabelValue(aShowLabel) {
29
30 init();
31}

◆ DefaultHepRepAttValue() [2/6]

cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
int64  value,
int  showLabel 
)

Definition at line 33 of file DefaultHepRepAttValue.cc.

34 : name(aName), type(HepRepConstants::TYPE_LONG), longValue(aValue), showLabelValue(aShowLabel) {
35
36 init();
37}

◆ DefaultHepRepAttValue() [3/6]

cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
int  value,
int  showLabel 
)

Definition at line 39 of file DefaultHepRepAttValue.cc.

40 : name(aName), type(HepRepConstants::TYPE_INT), longValue(aValue), showLabelValue(aShowLabel) {
41
42 init();
43}

◆ DefaultHepRepAttValue() [4/6]

cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
double  value,
int  showLabel 
)

Definition at line 45 of file DefaultHepRepAttValue.cc.

46 : name(aName), type(HepRepConstants::TYPE_DOUBLE), doubleValue(aValue), showLabelValue(aShowLabel) {
47
48 init();
49}

◆ DefaultHepRepAttValue() [5/6]

cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
bool  value,
int  showLabel 
)

Definition at line 51 of file DefaultHepRepAttValue.cc.

52 : name(aName), type(HepRepConstants::TYPE_BOOLEAN), booleanValue(aValue), showLabelValue(aShowLabel) {
53
54 init();
55}

◆ DefaultHepRepAttValue() [6/6]

cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
std::vector< double >  value,
int  showLabel 
)

Definition at line 57 of file DefaultHepRepAttValue.cc.

58 : name(aName), type(HepRepConstants::TYPE_COLOR), colorValue(aValue), showLabelValue(aShowLabel) {
59
60 init();
61}

◆ ~DefaultHepRepAttValue()

cheprep::DefaultHepRepAttValue::~DefaultHepRepAttValue ( )

Definition at line 63 of file DefaultHepRepAttValue.cc.

63 {
64}

Member Function Documentation

◆ copy()

HepRepAttValue * cheprep::DefaultHepRepAttValue::copy ( )
virtual

Returns a deep copy of this attvalue.

Returns
copy of this attvalue.

Implements HEPREP::HepRepAttValue.

Definition at line 73 of file DefaultHepRepAttValue.cc.

73 {
74 switch(type) {
75 case HepRepConstants::TYPE_COLOR: new DefaultHepRepAttValue(name, colorValue, showLabelValue);
76 case HepRepConstants::TYPE_STRING: new DefaultHepRepAttValue(name, stringValue, showLabelValue);
77 case HepRepConstants::TYPE_LONG: new DefaultHepRepAttValue(name, longValue, showLabelValue);
78 case HepRepConstants::TYPE_INT: new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
79 case HepRepConstants::TYPE_DOUBLE: new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
80 case HepRepConstants::TYPE_BOOLEAN: new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
81 default: return new DefaultHepRepAttValue(name, "Unknown type stored in HepRepAttDef", showLabelValue);
82 }
83}
DefaultHepRepAttValue(std::string name, std::string value, int showLabel)

◆ getAsString() [1/6]

string cheprep::DefaultHepRepAttValue::getAsString ( )
virtual

Returns value as string.

Returns
value (of any type) in string format.

Implements HEPREP::HepRepAttValue.

Definition at line 153 of file DefaultHepRepAttValue.cc.

Referenced by getAsString(), and cheprep::XMLWriter::setAttribute().

◆ getAsString() [2/6]

string cheprep::DefaultHepRepAttValue::getAsString ( bool  b)
static

Definition at line 194 of file DefaultHepRepAttValue.cc.

194 {
195 return b ? "true" : "false";
196}

◆ getAsString() [3/6]

string cheprep::DefaultHepRepAttValue::getAsString ( double  d)
static

Definition at line 188 of file DefaultHepRepAttValue.cc.

188 {
189 char buffer[40];
190 sprintf(buffer, "%g", d);
191 return buffer;
192}
#define buffer
Definition: xmlparse.cc:611

◆ getAsString() [4/6]

string cheprep::DefaultHepRepAttValue::getAsString ( int  i)
static

Definition at line 175 of file DefaultHepRepAttValue.cc.

175 {
176 char buffer[40];
177 sprintf(buffer, "%d", i);
178 return buffer;
179}

◆ getAsString() [5/6]

string cheprep::DefaultHepRepAttValue::getAsString ( int64  i)
static

Definition at line 181 of file DefaultHepRepAttValue.cc.

181 {
182 char buffer[40];
183 sprintf(buffer, CHEPREP_INT64_FORMAT, i);
184 return buffer;
185}
#define CHEPREP_INT64_FORMAT
Definition: config.h:33

◆ getAsString() [6/6]

string cheprep::DefaultHepRepAttValue::getAsString ( std::vector< double >  c)
static

Definition at line 165 of file DefaultHepRepAttValue.cc.

165 {
166 char buffer[40];
167 sprintf(buffer, "%4.2f, %4.2f, %4.2f, %4.2f",
168 c[0],
169 c[1],
170 c[2],
171 (c.size() > 3) ? c[3] : 1.0);
172 return buffer;
173}

◆ getBoolean()

bool cheprep::DefaultHepRepAttValue::getBoolean ( )
virtual

Returns value as boolean.

Returns
value as boolean.

Implements HEPREP::HepRepAttValue.

Definition at line 142 of file DefaultHepRepAttValue.cc.

142 {
143 if (type != HepRepConstants::TYPE_BOOLEAN) cerr << "Trying to access AttValue '" << getName() << "' as 'boolean'" << endl;
144 return booleanValue;
145}

Referenced by getAsString().

◆ getColor()

vector< double > cheprep::DefaultHepRepAttValue::getColor ( )
virtual

Returns value as Color.

Returns
value as Color.

Implements HEPREP::HepRepAttValue.

Definition at line 147 of file DefaultHepRepAttValue.cc.

147 {
148 if (type != HepRepConstants::TYPE_COLOR) cerr << "Trying to access AttValue '" << getName() << "' as 'color'" << endl;
149 return colorValue;
150}

Referenced by getAsString().

◆ getDouble()

double cheprep::DefaultHepRepAttValue::getDouble ( )
virtual

Returns value as double.

Returns
value as double.

Implements HEPREP::HepRepAttValue.

Definition at line 137 of file DefaultHepRepAttValue.cc.

137 {
138 if (type != HepRepConstants::TYPE_DOUBLE) cerr << "Trying to access AttValue '" << getName() << "' as 'double'" << endl;
139 return doubleValue;
140}

Referenced by getAsString().

◆ getInteger()

int cheprep::DefaultHepRepAttValue::getInteger ( )
virtual

Returns value as int.

Returns
value as integer.

Implements HEPREP::HepRepAttValue.

Definition at line 132 of file DefaultHepRepAttValue.cc.

132 {
133 if (type != HepRepConstants::TYPE_INT) cerr << "Trying to access AttValue '" << getName() << "' as 'int'" << endl;
134 return (int64)longValue;
135}
long long int64
Definition: Types.h:27

Referenced by getAsString().

◆ getLong()

int64 cheprep::DefaultHepRepAttValue::getLong ( )
virtual

Returns value as long.

Returns
value as long.

Implements HEPREP::HepRepAttValue.

Definition at line 127 of file DefaultHepRepAttValue.cc.

127 {
128 if (type != HepRepConstants::TYPE_LONG) cerr << "Trying to access AttValue '" << getName() << "' as 'long'" << endl;
129 return longValue;
130}

Referenced by getAsString().

◆ getLowerCaseName()

string cheprep::DefaultHepRepAttValue::getLowerCaseName ( )
virtual

Returns lowercased name of the attvalue.

Returns
Lowercased Name.

Implements HEPREP::HepRepAttValue.

Definition at line 89 of file DefaultHepRepAttValue.cc.

89 {
90 string s = name;
91 transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
92 return s;
93}

◆ getLowerCaseString()

string cheprep::DefaultHepRepAttValue::getLowerCaseString ( )
virtual

Returns value as lowercase string.

Returns
value as string (if type is string).

Implements HEPREP::HepRepAttValue.

Definition at line 120 of file DefaultHepRepAttValue.cc.

120 {
121 if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
122 string s = stringValue;
123 transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
124 return s;
125}

◆ getName()

string cheprep::DefaultHepRepAttValue::getName ( )
virtual

Returns name of the attvalue.

Returns
Capitalized Name.

Implements HEPREP::HepRepAttValue.

Definition at line 85 of file DefaultHepRepAttValue.cc.

85 {
86 return name;
87}

Referenced by getBoolean(), getColor(), getDouble(), getInteger(), getLong(), getLowerCaseString(), and getString().

◆ getString()

string cheprep::DefaultHepRepAttValue::getString ( )
virtual

Returns value as string.

Returns
value as string (if type is string).

Implements HEPREP::HepRepAttValue.

Definition at line 115 of file DefaultHepRepAttValue.cc.

115 {
116 if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
117 return stringValue;
118}

Referenced by getAsString().

◆ getType()

int cheprep::DefaultHepRepAttValue::getType ( )
virtual

Returns type of the attvalue, defined in HepRepConstants with names TYPE_xxx.

Returns
type.

Implements HEPREP::HepRepAttValue.

Definition at line 95 of file DefaultHepRepAttValue.cc.

95 {
96 return type;
97}

◆ getTypeName()

string cheprep::DefaultHepRepAttValue::getTypeName ( )
virtual

Returns the Java-like name for the type of this attvalue.

Returns
type name.

Implements HEPREP::HepRepAttValue.

Definition at line 99 of file DefaultHepRepAttValue.cc.

99 {
100 switch(type) {
101 case HepRepConstants::TYPE_COLOR: return("Color");
102 case HepRepConstants::TYPE_STRING: return("String");
103 case HepRepConstants::TYPE_LONG: return("long");
104 case HepRepConstants::TYPE_INT: return("int");
105 case HepRepConstants::TYPE_DOUBLE: return("double");
106 case HepRepConstants::TYPE_BOOLEAN: return("boolean");
107 default: return "Unknown type stored in HepRepAttDef";
108 }
109}

◆ showLabel()

int cheprep::DefaultHepRepAttValue::showLabel ( )
virtual

Returns the flag bits for showing this attvalue as a label, defined in HepRepConstants with names SHOW_xxx.

Returns
flag bits if should be shown as label.

Implements HEPREP::HepRepAttValue.

Definition at line 111 of file DefaultHepRepAttValue.cc.

111 {
112 return showLabelValue;
113}

Referenced by toShowLabel().

◆ toShowLabel() [1/2]

string cheprep::DefaultHepRepAttValue::toShowLabel ( )

◆ toShowLabel() [2/2]

string cheprep::DefaultHepRepAttValue::toShowLabel ( int  showLabel)
static

Definition at line 206 of file DefaultHepRepAttValue.cc.

206 {
207 string label = "";
208 bool first = true;
210 label = "NONE";
211 } else {
212 for (int i=0; i<16; i++) {
213 if (((showLabel >> i) & 0x0001) == 0x0001) {
214 if (first) {
215 first = false;
216 } else {
217 label.append(", ");
218 }
219 if (i < LABELSTRINGS_LEN) {
220 label.append(labelStrings[i]);
221 } else {
222 char hex[20];
223 sprintf(hex, "%0x", 1 << i);
224 label.append(hex);
225 }
226 }
227 }
228 }
229 return label;
230}

The documentation for this class was generated from the following files: