DefaultHepRepDefinition.cc

Go to the documentation of this file.
00001 // Copyright FreeHEP, 2005.
00002 
00003 #include "cheprep/DefaultHepRepDefinition.h"
00004 #include "cheprep/DefaultHepRepAttDef.h"
00005 
00006 #include <iostream>
00007 #include <algorithm>
00008 
00009 using namespace std;
00010 using namespace HEPREP;
00011 
00016 namespace cheprep {
00017 
00018 DefaultHepRepDefinition::DefaultHepRepDefinition()
00019     : DefaultHepRepAttribute() {
00020 }
00021 
00022 DefaultHepRepDefinition::~DefaultHepRepDefinition() {
00023     set<HepRepAttDef *> list = getAttDefsFromNode();
00024     for (set<HepRepAttDef*>::iterator i1 = list.begin(); i1 != list.end(); i1++) {
00025         delete (*i1);
00026     }
00027 }
00028 
00029 set<HepRepAttDef *> DefaultHepRepDefinition::getAttDefsFromNode() {
00030     set<HepRepAttDef*> attSet;
00031     for (map<string, HepRepAttDef*>::iterator i = attDefs.begin(); i != attDefs.end(); i++) {
00032         attSet.insert((*i).second);
00033     }
00034     return attSet;
00035 }
00036 
00037 void DefaultHepRepDefinition::addAttDef(HepRepAttDef* hepRepAttDef) {
00038     string lowerCaseName = hepRepAttDef->getLowerCaseName();
00039     if (attDefs[lowerCaseName] != NULL) delete attDefs[lowerCaseName];
00040     attDefs[lowerCaseName] = hepRepAttDef;
00041 }
00042 
00043 void DefaultHepRepDefinition::addAttDef(string name, string desc, string type, string extra) {
00044     addAttDef(new DefaultHepRepAttDef(name, desc, type, extra));
00045 }
00046 
00047 HepRepAttDef* DefaultHepRepDefinition::getAttDefFromNode(string name) {
00048     string s = name;
00049     transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
00050     return (attDefs.count(s) > 0) ? attDefs[s] : NULL;    
00051 }
00052 
00053 } // cheprep

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