DefaultHepRepAttribute.cc

Go to the documentation of this file.
00001 // Copyright FreeHEP, 2005.
00002 
00003 #include "cheprep/config.h"
00004 
00005 #include <iostream>
00006 #include <algorithm>
00007 
00008 #include "cheprep/DefaultHepRepAttribute.h"
00009 #include "cheprep/DefaultHepRepAttValue.h"
00010 
00011 using namespace std;
00012 using namespace HEPREP;
00013 
00018 namespace cheprep {
00019 
00020 
00021 DefaultHepRepAttribute::DefaultHepRepAttribute() {
00022 }
00023 
00024 DefaultHepRepAttribute::~DefaultHepRepAttribute() {
00025     for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
00026         delete (*i).second;
00027     }
00028 }
00029 
00030 set<HepRepAttValue*> DefaultHepRepAttribute::getAttValuesFromNode() {
00031     set<HepRepAttValue*> attSet;
00032     for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
00033         if ((*i).first != "layer") attSet.insert((*i).second);
00034     }
00035     return attSet;
00036 }
00037 
00038 void DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
00039     string lowerCaseName = hepRepAttValue->getLowerCaseName();
00040     if (attValues[lowerCaseName] != NULL) delete attValues[lowerCaseName];
00041     attValues[lowerCaseName] = hepRepAttValue;
00042 }
00043 
00044 void DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
00045     addAttValue(key, (std::string)value, showLabel);
00046 }
00047 
00048 void DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
00049     addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
00050 }
00051 
00052 void DefaultHepRepAttribute::addAttValue(string key, int64 value, int showLabel) {
00053     addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
00054 }
00055 
00056 void DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
00057     addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
00058 }
00059 
00060 void DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
00061     addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
00062 }
00063 
00064 void DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
00065     addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
00066 }
00067 
00068 void DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
00069     addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
00070 }
00071 
00072 void DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
00073     vector<double> color;
00074     color.push_back(red);
00075     color.push_back(green);
00076     color.push_back(blue);
00077     color.push_back(alpha);
00078     addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
00079 }
00080 
00081 HepRepAttValue* DefaultHepRepAttribute::getAttValueFromNode(string name) {
00082     string s = name;
00083     transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
00084     return (attValues.count(s) > 0) ? attValues[s] : NULL;    
00085 }
00086 
00087 HepRepAttValue* DefaultHepRepAttribute::removeAttValue(string name) {
00088     string s = name;
00089     transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
00090     HepRepAttValue* attValue = attValues[s];
00091     attValues.erase(s);
00092     return attValue;
00093 }
00094 
00095 
00096 } // cheprep

Generated on Mon May 27 17:47:34 2013 for Geant4 by  doxygen 1.4.7