17 using namespace HEPREP;
25 std::string DefaultHepRepAttValue::labelStrings[LABELSTRINGS_LEN];
27 DefaultHepRepAttValue::DefaultHepRepAttValue(
string aName,
string aValue,
int aShowLabel)
28 :
name(aName), type(
HepRepConstants::TYPE_STRING), stringValue(aValue), showLabelValue(aShowLabel) {
34 :
name(aName), type(
HepRepConstants::TYPE_LONG), longValue(aValue), showLabelValue(aShowLabel) {
40 :
name(aName), type(
HepRepConstants::TYPE_INT), longValue(aValue), showLabelValue(aShowLabel) {
46 :
name(aName), type(
HepRepConstants::TYPE_DOUBLE), doubleValue(aValue), showLabelValue(aShowLabel) {
52 :
name(aName), type(
HepRepConstants::TYPE_BOOLEAN), booleanValue(aValue), showLabelValue(aShowLabel) {
58 :
name(aName), type(
HepRepConstants::TYPE_COLOR), colorValue(aValue), showLabelValue(aShowLabel) {
66 void DefaultHepRepAttValue::init() {
67 labelStrings[0] =
"NAME";
68 labelStrings[1] =
"DESC";
69 labelStrings[2] =
"VALUE";
70 labelStrings[3] =
"EXTRA";
91 transform(s.begin(), s.end(), s.begin(), (
int(*)(
int)) tolower);
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";
112 return showLabelValue;
116 if (type != HepRepConstants::TYPE_STRING) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'string'" << endl;
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);
128 if (type != HepRepConstants::TYPE_LONG) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'long'" << endl;
133 if (type != HepRepConstants::TYPE_INT) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'int'" << endl;
134 return (
int64)longValue;
138 if (type != HepRepConstants::TYPE_DOUBLE) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'double'" << endl;
143 if (type != HepRepConstants::TYPE_BOOLEAN) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'boolean'" << endl;
148 if (type != HepRepConstants::TYPE_COLOR) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'color'" << endl;
156 case HepRepConstants::TYPE_STRING:
return getString();
161 default:
return "Unknown typecode";
167 sprintf(buffer,
"%4.2f, %4.2f, %4.2f, %4.2f",
171 (c.size() > 3) ? c[3] : 1.0);
177 sprintf(buffer,
"%d", i);
190 sprintf(buffer,
"%g", d);
195 return b ?
"true" :
"false";
209 if (showLabel == HepRepConstants::SHOW_NONE) {
212 for (
int i=0; i<16; i++) {
213 if (((showLabel >> i) & 0x0001) == 0x0001) {
219 if (i < LABELSTRINGS_LEN) {
220 label.append(labelStrings[i]);
223 sprintf(hex,
"%0x", 1 << i);