Geant4_10
DefaultHepRepAttribute.cc
Go to the documentation of this file.
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 
18 namespace cheprep {
19 
20 
21 DefaultHepRepAttribute::DefaultHepRepAttribute() {
22 }
23 
24 DefaultHepRepAttribute::~DefaultHepRepAttribute() {
25  for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
26  delete (*i).second;
27  }
28 }
29 
30 set<HepRepAttValue*> DefaultHepRepAttribute::getAttValuesFromNode() {
31  set<HepRepAttValue*> attSet;
32  for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
33  if ((*i).first != "layer") attSet.insert((*i).second);
34  }
35  return attSet;
36 }
37 
38 void DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
39  string lowerCaseName = hepRepAttValue->getLowerCaseName();
40  if (attValues[lowerCaseName] != NULL) delete attValues[lowerCaseName];
41  attValues[lowerCaseName] = hepRepAttValue;
42 }
43 
44 void DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
45  addAttValue(key, (std::string)value, showLabel);
46 }
47 
48 void DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
49  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
50 }
51 
52 void DefaultHepRepAttribute::addAttValue(string key, int64 value, int showLabel) {
53  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
54 }
55 
56 void DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
57  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
58 }
59 
60 void DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
61  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
62 }
63 
64 void DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
65  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
66 }
67 
68 void DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
69  addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
70 }
71 
72 void DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
73  vector<double> color;
74  color.push_back(red);
75  color.push_back(green);
76  color.push_back(blue);
77  color.push_back(alpha);
78  addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
79 }
80 
81 HepRepAttValue* DefaultHepRepAttribute::getAttValueFromNode(string name) {
82  string s = name;
83  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
84  return (attValues.count(s) > 0) ? attValues[s] : NULL;
85 }
86 
87 HepRepAttValue* DefaultHepRepAttribute::removeAttValue(string name) {
88  string s = name;
89  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
90  HepRepAttValue* attValue = attValues[s];
91  attValues.erase(s);
92  return attValue;
93 }
94 
95 
96 } // cheprep
Definition: test07.cc:36
virtual std::string getLowerCaseName()=0
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const XML_Char * s
Definition: expat.h:262
const XML_Char * name
Definition: expat.h:151
Definition: test07.cc:36
long long int64
Definition: config.h:31
const XML_Char int const XML_Char * value
Definition: expat.h:331