Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cheprep::DefaultHepRepAttValue Class Reference

#include <DefaultHepRepAttValue.h>

Inheritance diagram for cheprep::DefaultHepRepAttValue:
Collaboration 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. More...
 

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

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

Definition at line 27 of file DefaultHepRepAttValue.cc.

28  : name(aName)
29  , type(HepRepConstants::TYPE_STRING)
30  , stringValue(aValue)
31  , longValue(0)
32  , doubleValue(0.)
33  , booleanValue(false)
34  , showLabelValue(aShowLabel)
35  {
36  init();
37  }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

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

Definition at line 39 of file DefaultHepRepAttValue.cc.

40  : name(aName)
41  , type(HepRepConstants::TYPE_LONG)
42  , longValue(aValue)
43  , doubleValue(0.)
44  , booleanValue(false)
45  , showLabelValue(aShowLabel)
46  {
47  init();
48  }
const XML_Char * name
Definition: expat.h:151
cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
int  value,
int  showLabel 
)

Definition at line 50 of file DefaultHepRepAttValue.cc.

51  : name(aName)
52  , type(HepRepConstants::TYPE_INT)
53  , longValue(aValue)
54  , doubleValue(0.)
55  , booleanValue(false)
56  , showLabelValue(aShowLabel)
57  {
58  init();
59  }
const XML_Char * name
Definition: expat.h:151
cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
double  value,
int  showLabel 
)

Definition at line 61 of file DefaultHepRepAttValue.cc.

62  : name(aName)
63  , type(HepRepConstants::TYPE_DOUBLE)
64  , longValue(0)
65  , doubleValue(aValue)
66  , booleanValue(false)
67  , showLabelValue(aShowLabel)
68  {
69  init();
70  }
const XML_Char * name
Definition: expat.h:151
cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
bool  value,
int  showLabel 
)

Definition at line 72 of file DefaultHepRepAttValue.cc.

73  : name(aName)
74  , type(HepRepConstants::TYPE_BOOLEAN)
75  , longValue(0)
76  , doubleValue(0.)
77  , booleanValue(aValue)
78  , showLabelValue(aShowLabel)
79  {
80  init();
81  }
const XML_Char * name
Definition: expat.h:151
cheprep::DefaultHepRepAttValue::DefaultHepRepAttValue ( std::string  name,
std::vector< double >  value,
int  showLabel 
)

Definition at line 83 of file DefaultHepRepAttValue.cc.

84  : name(aName)
85  , type(HepRepConstants::TYPE_COLOR)
86  , longValue(0)
87  , doubleValue(0.)
88  , booleanValue(false)
89  , colorValue(aValue)
90  , showLabelValue(aShowLabel)
91  {
92  init();
93  }
const XML_Char * name
Definition: expat.h:151
cheprep::DefaultHepRepAttValue::~DefaultHepRepAttValue ( )

Definition at line 95 of file DefaultHepRepAttValue.cc.

95  {
96 }

Member Function Documentation

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

Returns a deep copy of this attvalue.

Returns
copy of this attvalue.

Implements HEPREP::HepRepAttValue.

Definition at line 105 of file DefaultHepRepAttValue.cc.

105  {
106  // Coverity issues warnings here. It looks to me (JA) that "return" is
107  // missing on severeal lines.
108  switch(type) {
109 // case HepRepConstants::TYPE_COLOR: new DefaultHepRepAttValue(name, colorValue, showLabelValue);
110 // case HepRepConstants::TYPE_STRING: new DefaultHepRepAttValue(name, stringValue, showLabelValue);
111 // case HepRepConstants::TYPE_LONG: new DefaultHepRepAttValue(name, longValue, showLabelValue);
112 // case HepRepConstants::TYPE_INT: new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
113 // case HepRepConstants::TYPE_DOUBLE: new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
114 // case HepRepConstants::TYPE_BOOLEAN: new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
115  case HepRepConstants::TYPE_COLOR: return new DefaultHepRepAttValue(name, colorValue, showLabelValue);
116  case HepRepConstants::TYPE_STRING: return new DefaultHepRepAttValue(name, stringValue, showLabelValue);
117  case HepRepConstants::TYPE_LONG: return new DefaultHepRepAttValue(name, longValue, showLabelValue);
118  case HepRepConstants::TYPE_INT: return new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
119  case HepRepConstants::TYPE_DOUBLE: return new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
120  case HepRepConstants::TYPE_BOOLEAN: return new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
121  default: return new DefaultHepRepAttValue(name, "Unknown type stored in HepRepAttDef", showLabelValue);
122  }
123 }
const XML_Char * name
Definition: expat.h:151
DefaultHepRepAttValue(std::string name, std::string value, int showLabel)

Here is the call graph for this function:

string cheprep::DefaultHepRepAttValue::getAsString ( )
virtual

Returns value as string.

Returns
value (of any type) in string format.

Implements HEPREP::HepRepAttValue.

Definition at line 193 of file DefaultHepRepAttValue.cc.

193  {
194  switch(type) {
195  case HepRepConstants::TYPE_COLOR: return getAsString(getColor());
196  case HepRepConstants::TYPE_STRING: return getString();
197  case HepRepConstants::TYPE_LONG: return getAsString(getLong());
198  case HepRepConstants::TYPE_INT: return getAsString(getInteger());
199  case HepRepConstants::TYPE_DOUBLE: return getAsString(getDouble());
200  case HepRepConstants::TYPE_BOOLEAN: return getAsString(getBoolean());
201  default: return "Unknown typecode";
202  }
203 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 205 of file DefaultHepRepAttValue.cc.

205  {
206  char buffer[40];
207  sprintf(buffer, "%4.2f, %4.2f, %4.2f, %4.2f",
208  c[0],
209  c[1],
210  c[2],
211  (c.size() > 3) ? c[3] : 1.0);
212  return buffer;
213 }
#define buffer
Definition: xmlparse.cc:628
string cheprep::DefaultHepRepAttValue::getAsString ( int  i)
static

Definition at line 215 of file DefaultHepRepAttValue.cc.

215  {
216  char buffer[40];
217  sprintf(buffer, "%d", i);
218  return buffer;
219 }
#define buffer
Definition: xmlparse.cc:628
string cheprep::DefaultHepRepAttValue::getAsString ( int64  i)
static

Definition at line 221 of file DefaultHepRepAttValue.cc.

221  {
222  char buffer[40];
223  sprintf(buffer, CHEPREP_INT64_FORMAT, i);
224  return buffer;
225 }
#define buffer
Definition: xmlparse.cc:628
#define CHEPREP_INT64_FORMAT
Definition: config.h:33
string cheprep::DefaultHepRepAttValue::getAsString ( double  d)
static

Definition at line 228 of file DefaultHepRepAttValue.cc.

228  {
229  char buffer[40];
230  sprintf(buffer, "%g", d);
231  return buffer;
232 }
#define buffer
Definition: xmlparse.cc:628
string cheprep::DefaultHepRepAttValue::getAsString ( bool  b)
static

Definition at line 234 of file DefaultHepRepAttValue.cc.

234  {
235  return b ? "true" : "false";
236 }
bool cheprep::DefaultHepRepAttValue::getBoolean ( )
virtual

Returns value as boolean.

Returns
value as boolean.

Implements HEPREP::HepRepAttValue.

Definition at line 182 of file DefaultHepRepAttValue.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns value as Color.

Returns
value as Color.

Implements HEPREP::HepRepAttValue.

Definition at line 187 of file DefaultHepRepAttValue.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

double cheprep::DefaultHepRepAttValue::getDouble ( )
virtual

Returns value as double.

Returns
value as double.

Implements HEPREP::HepRepAttValue.

Definition at line 177 of file DefaultHepRepAttValue.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

int cheprep::DefaultHepRepAttValue::getInteger ( )
virtual

Returns value as int.

Returns
value as integer.

Implements HEPREP::HepRepAttValue.

Definition at line 172 of file DefaultHepRepAttValue.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

int64 cheprep::DefaultHepRepAttValue::getLong ( )
virtual

Returns value as long.

Returns
value as long.

Implements HEPREP::HepRepAttValue.

Definition at line 167 of file DefaultHepRepAttValue.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

string cheprep::DefaultHepRepAttValue::getLowerCaseName ( )
virtual

Returns lowercased name of the attvalue.

Returns
Lowercased Name.

Implements HEPREP::HepRepAttValue.

Definition at line 129 of file DefaultHepRepAttValue.cc.

129  {
130  string s = name;
131  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
132  return s;
133 }
const XML_Char * name
Definition: expat.h:151
const XML_Char * s
Definition: expat.h:262
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)

Here is the call graph for this function:

string cheprep::DefaultHepRepAttValue::getLowerCaseString ( )
virtual

Returns value as lowercase string.

Returns
value as string (if type is string).

Implements HEPREP::HepRepAttValue.

Definition at line 160 of file DefaultHepRepAttValue.cc.

160  {
161  if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
162  string s = stringValue;
163  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
164  return s;
165 }
const XML_Char * s
Definition: expat.h:262
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)

Here is the call graph for this function:

string cheprep::DefaultHepRepAttValue::getName ( )
virtual

Returns name of the attvalue.

Returns
Capitalized Name.

Implements HEPREP::HepRepAttValue.

Definition at line 125 of file DefaultHepRepAttValue.cc.

125  {
126  return name;
127 }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

string cheprep::DefaultHepRepAttValue::getString ( )
virtual

Returns value as string.

Returns
value as string (if type is string).

Implements HEPREP::HepRepAttValue.

Definition at line 155 of file DefaultHepRepAttValue.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

135  {
136  return type;
137 }
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 139 of file DefaultHepRepAttValue.cc.

139  {
140  switch(type) {
141  case HepRepConstants::TYPE_COLOR: return("Color");
142  case HepRepConstants::TYPE_STRING: return("String");
143  case HepRepConstants::TYPE_LONG: return("long");
144  case HepRepConstants::TYPE_INT: return("int");
145  case HepRepConstants::TYPE_DOUBLE: return("double");
146  case HepRepConstants::TYPE_BOOLEAN: return("boolean");
147  default: return "Unknown type stored in HepRepAttDef";
148  }
149 }
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 151 of file DefaultHepRepAttValue.cc.

151  {
152  return showLabelValue;
153 }

Here is the caller graph for this function:

string cheprep::DefaultHepRepAttValue::toShowLabel ( )

Definition at line 241 of file DefaultHepRepAttValue.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 246 of file DefaultHepRepAttValue.cc.

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

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