ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefaultHepRepAttribute.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DefaultHepRepAttribute.cc
1 // Copyright FreeHEP, 2005.
2 
3 #include "cheprep/config.h"
4 
5 #include <iostream>
6 #include <algorithm>
7 
10 
11 using namespace std;
12 using namespace HEPREP;
13 
17 namespace cheprep {
18 
19 
20 DefaultHepRepAttribute::DefaultHepRepAttribute() {
21 }
22 
23 DefaultHepRepAttribute::~DefaultHepRepAttribute() {
24  for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
25  delete (*i).second;
26  }
27 }
28 
29 set<HepRepAttValue*> DefaultHepRepAttribute::getAttValuesFromNode() {
30  set<HepRepAttValue*> attSet;
31  for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
32  if ((*i).first != "layer") attSet.insert((*i).second);
33  }
34  return attSet;
35 }
36 
37 void DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
38  string lowerCaseName = hepRepAttValue->getLowerCaseName();
39  if (attValues[lowerCaseName] != NULL) delete attValues[lowerCaseName];
40  attValues[lowerCaseName] = hepRepAttValue;
41 }
42 
43 void DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
44  addAttValue(key, (std::string)value, showLabel);
45 }
46 
47 void DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
48  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
49 }
50 
51 void DefaultHepRepAttribute::addAttValue(string key, int64 value, int showLabel) {
52  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
53 }
54 
55 void DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
56  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
57 }
58 
59 void DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
60  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
61 }
62 
63 void DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
64  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
65 }
66 
67 void DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
68  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
69 }
70 
71 void DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
72  vector<double> color;
73  color.push_back(red);
74  color.push_back(green);
75  color.push_back(blue);
76  color.push_back(alpha);
77  addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
78 }
79 
80 HepRepAttValue* DefaultHepRepAttribute::getAttValueFromNode(string name) {
81  string s = name;
82  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
83  return (attValues.count(s) > 0) ? attValues[s] : NULL;
84 }
85 
86 HepRepAttValue* DefaultHepRepAttribute::removeAttValue(string name) {
87  string s = name;
88  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
89  HepRepAttValue* attValue = attValues[s];
90  attValues.erase(s);
91  return attValue;
92 }
93 
94 
95 } // cheprep