Geant4 10.7.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 16 of file DefaultHepRepAttValue.h.

Constructor & Destructor Documentation

◆ DefaultHepRepAttValue() [1/6]

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

Definition at line 26 of file DefaultHepRepAttValue.cc.

27 : name(aName)
29 , stringValue(aValue)
30 , longValue(0)
31 , doubleValue(0.)
32 , booleanValue(false)
33 , showLabelValue(aShowLabel)
34 {
35 init();
36 }

◆ DefaultHepRepAttValue() [2/6]

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

Definition at line 38 of file DefaultHepRepAttValue.cc.

39 : name(aName)
41 , longValue(aValue)
42 , doubleValue(0.)
43 , booleanValue(false)
44 , showLabelValue(aShowLabel)
45 {
46 init();
47 }

◆ DefaultHepRepAttValue() [3/6]

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

Definition at line 49 of file DefaultHepRepAttValue.cc.

50 : name(aName)
52 , longValue(aValue)
53 , doubleValue(0.)
54 , booleanValue(false)
55 , showLabelValue(aShowLabel)
56 {
57 init();
58 }

◆ DefaultHepRepAttValue() [4/6]

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

Definition at line 60 of file DefaultHepRepAttValue.cc.

61 : name(aName)
63 , longValue(0)
64 , doubleValue(aValue)
65 , booleanValue(false)
66 , showLabelValue(aShowLabel)
67 {
68 init();
69 }

◆ DefaultHepRepAttValue() [5/6]

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

Definition at line 71 of file DefaultHepRepAttValue.cc.

72 : name(aName)
74 , longValue(0)
75 , doubleValue(0.)
76 , booleanValue(aValue)
77 , showLabelValue(aShowLabel)
78 {
79 init();
80 }

◆ DefaultHepRepAttValue() [6/6]

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

Definition at line 82 of file DefaultHepRepAttValue.cc.

83 : name(aName)
85 , longValue(0)
86 , doubleValue(0.)
87 , booleanValue(false)
88 , colorValue(aValue)
89 , showLabelValue(aShowLabel)
90 {
91 init();
92 }

◆ ~DefaultHepRepAttValue()

cheprep::DefaultHepRepAttValue::~DefaultHepRepAttValue ( )

Definition at line 94 of file DefaultHepRepAttValue.cc.

94 {
95}

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 104 of file DefaultHepRepAttValue.cc.

104 {
105 // Coverity issues warnings here. It looks to me (JA) that "return" is
106 // missing on severeal lines.
107 switch(type) {
108// case HepRepConstants::TYPE_COLOR: new DefaultHepRepAttValue(name, colorValue, showLabelValue);
109// case HepRepConstants::TYPE_STRING: new DefaultHepRepAttValue(name, stringValue, showLabelValue);
110// case HepRepConstants::TYPE_LONG: new DefaultHepRepAttValue(name, longValue, showLabelValue);
111// case HepRepConstants::TYPE_INT: new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
112// case HepRepConstants::TYPE_DOUBLE: new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
113// case HepRepConstants::TYPE_BOOLEAN: new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
114 case HepRepConstants::TYPE_COLOR: return new DefaultHepRepAttValue(name, colorValue, showLabelValue);
115 case HepRepConstants::TYPE_STRING: return new DefaultHepRepAttValue(name, stringValue, showLabelValue);
116 case HepRepConstants::TYPE_LONG: return new DefaultHepRepAttValue(name, longValue, showLabelValue);
117 case HepRepConstants::TYPE_INT: return new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
118 case HepRepConstants::TYPE_DOUBLE: return new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
119 case HepRepConstants::TYPE_BOOLEAN: return new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
120 default: return new DefaultHepRepAttValue(name, "Unknown type stored in HepRepAttDef", showLabelValue);
121 }
122}
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 192 of file DefaultHepRepAttValue.cc.

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

◆ getAsString() [2/6]

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

Definition at line 233 of file DefaultHepRepAttValue.cc.

233 {
234 return b ? "true" : "false";
235}

◆ getAsString() [3/6]

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

Definition at line 227 of file DefaultHepRepAttValue.cc.

227 {
228 char buffer[40];
229 sprintf(buffer, "%g", d);
230 return buffer;
231}
#define buffer
Definition: xmlparse.cc:628

◆ getAsString() [4/6]

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

Definition at line 214 of file DefaultHepRepAttValue.cc.

214 {
215 char buffer[40];
216 sprintf(buffer, "%d", i);
217 return buffer;
218}

◆ getAsString() [5/6]

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

Definition at line 220 of file DefaultHepRepAttValue.cc.

220 {
221 char buffer[40];
222 sprintf(buffer, CHEPREP_INT64_FORMAT, i);
223 return buffer;
224}
#define CHEPREP_INT64_FORMAT
Definition: config.h:32

◆ getAsString() [6/6]

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

Definition at line 204 of file DefaultHepRepAttValue.cc.

204 {
205 char buffer[40];
206 sprintf(buffer, "%4.2f, %4.2f, %4.2f, %4.2f",
207 c[0],
208 c[1],
209 c[2],
210 (c.size() > 3) ? c[3] : 1.0);
211 return buffer;
212}

◆ getBoolean()

bool cheprep::DefaultHepRepAttValue::getBoolean ( )
virtual

Returns value as boolean.

Returns
value as boolean.

Implements HEPREP::HepRepAttValue.

Definition at line 181 of file DefaultHepRepAttValue.cc.

181 {
182 if (type != HepRepConstants::TYPE_BOOLEAN) cerr << "Trying to access AttValue '" << getName() << "' as 'boolean'" << endl;
183 return booleanValue;
184}

Referenced by getAsString().

◆ getColor()

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

Returns value as Color.

Returns
value as Color.

Implements HEPREP::HepRepAttValue.

Definition at line 186 of file DefaultHepRepAttValue.cc.

186 {
187 if (type != HepRepConstants::TYPE_COLOR) cerr << "Trying to access AttValue '" << getName() << "' as 'color'" << endl;
188 return colorValue;
189}

Referenced by getAsString().

◆ getDouble()

double cheprep::DefaultHepRepAttValue::getDouble ( )
virtual

Returns value as double.

Returns
value as double.

Implements HEPREP::HepRepAttValue.

Definition at line 176 of file DefaultHepRepAttValue.cc.

176 {
177 if (type != HepRepConstants::TYPE_DOUBLE) cerr << "Trying to access AttValue '" << getName() << "' as 'double'" << endl;
178 return doubleValue;
179}

Referenced by getAsString().

◆ getInteger()

int cheprep::DefaultHepRepAttValue::getInteger ( )
virtual

Returns value as int.

Returns
value as integer.

Implements HEPREP::HepRepAttValue.

Definition at line 171 of file DefaultHepRepAttValue.cc.

171 {
172 if (type != HepRepConstants::TYPE_INT) cerr << "Trying to access AttValue '" << getName() << "' as 'int'" << endl;
173 return (int64)longValue;
174}
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 166 of file DefaultHepRepAttValue.cc.

166 {
167 if (type != HepRepConstants::TYPE_LONG) cerr << "Trying to access AttValue '" << getName() << "' as 'long'" << endl;
168 return longValue;
169}

Referenced by getAsString().

◆ getLowerCaseName()

string cheprep::DefaultHepRepAttValue::getLowerCaseName ( )
virtual

Returns lowercased name of the attvalue.

Returns
Lowercased Name.

Implements HEPREP::HepRepAttValue.

Definition at line 128 of file DefaultHepRepAttValue.cc.

128 {
129 string s = name;
130 transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
131 return s;
132}

◆ 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 159 of file DefaultHepRepAttValue.cc.

159 {
160 if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
161 string s = stringValue;
162 transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
163 return s;
164}

◆ getName()

string cheprep::DefaultHepRepAttValue::getName ( )
virtual

Returns name of the attvalue.

Returns
Capitalized Name.

Implements HEPREP::HepRepAttValue.

Definition at line 124 of file DefaultHepRepAttValue.cc.

124 {
125 return name;
126}

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 154 of file DefaultHepRepAttValue.cc.

154 {
155 if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
156 return stringValue;
157}

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 134 of file DefaultHepRepAttValue.cc.

134 {
135 return type;
136}

◆ 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 138 of file DefaultHepRepAttValue.cc.

138 {
139 switch(type) {
140 case HepRepConstants::TYPE_COLOR: return("Color");
141 case HepRepConstants::TYPE_STRING: return("String");
142 case HepRepConstants::TYPE_LONG: return("long");
143 case HepRepConstants::TYPE_INT: return("int");
144 case HepRepConstants::TYPE_DOUBLE: return("double");
145 case HepRepConstants::TYPE_BOOLEAN: return("boolean");
146 default: return "Unknown type stored in HepRepAttDef";
147 }
148}

◆ 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 150 of file DefaultHepRepAttValue.cc.

150 {
151 return showLabelValue;
152}

Referenced by toShowLabel().

◆ toShowLabel() [1/2]

string cheprep::DefaultHepRepAttValue::toShowLabel ( )

◆ toShowLabel() [2/2]

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

Definition at line 245 of file DefaultHepRepAttValue.cc.

245 {
246 string label = "";
247 bool first = true;
249 label = "NONE";
250 } else {
251 for (int i=0; i<16; i++) {
252 if (((showLabel >> i) & 0x0001) == 0x0001) {
253 if (first) {
254 first = false;
255 } else {
256 label.append(", ");
257 }
258 if (i < LABELSTRINGS_LEN) {
259 label.append(labelStrings[i]);
260 } else {
261 char hex[20];
262 sprintf(hex, "%0x", 1 << i);
263 label.append(hex);
264 }
265 }
266 }
267 }
268 return label;
269}

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