Geant4  10.01
DefaultHepRepDefinition.cc
Go to the documentation of this file.
1 // Copyright FreeHEP, 2005.
2 
3 #include "cheprep/DefaultHepRepDefinition.h"
4 #include "cheprep/DefaultHepRepAttDef.h"
5 
6 #include <iostream>
7 #include <algorithm>
8 
9 using namespace std;
10 using namespace HEPREP;
11 
16 namespace cheprep {
17 
18 DefaultHepRepDefinition::DefaultHepRepDefinition()
19  : DefaultHepRepAttribute() {
20 }
21 
22 DefaultHepRepDefinition::~DefaultHepRepDefinition() {
23  set<HepRepAttDef *> list = getAttDefsFromNode();
24  for (set<HepRepAttDef*>::iterator i1 = list.begin(); i1 != list.end(); i1++) {
25  delete (*i1);
26  }
27 }
28 
29 set<HepRepAttDef *> DefaultHepRepDefinition::getAttDefsFromNode() {
30  set<HepRepAttDef*> attSet;
31  for (map<string, HepRepAttDef*>::iterator i = attDefs.begin(); i != attDefs.end(); i++) {
32  attSet.insert((*i).second);
33  }
34  return attSet;
35 }
36 
37 void DefaultHepRepDefinition::addAttDef(HepRepAttDef* hepRepAttDef) {
38  string lowerCaseName = hepRepAttDef->getLowerCaseName();
39  if (attDefs[lowerCaseName] != NULL) delete attDefs[lowerCaseName];
40  attDefs[lowerCaseName] = hepRepAttDef;
41 }
42 
43 void DefaultHepRepDefinition::addAttDef(string name, string desc, string type, string extra) {
44  addAttDef(new DefaultHepRepAttDef(name, desc, type, extra));
45 }
46 
47 HepRepAttDef* DefaultHepRepDefinition::getAttDefFromNode(string name) {
48  string s = name;
49  transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
50  return (attDefs.count(s) > 0) ? attDefs[s] : NULL;
51 }
52 
53 } // cheprep
G4String name
Definition: TRTMaterials.hh:40
static const double s
Definition: G4SIunits.hh:150