4 // See the class description in the header file.
6 #include "TG4NameMap.h"
7 #include "TG4Globals.h"
9 #include "g4std/iomanip"
12 G4String TG4NameMap::fgUndefined = "Undefined";
14 typedef G4std::map<G4String, G4String, G4std::less<G4String> >
15 :: iterator MapIterator;
17 //_____________________________________________________________________________
18 TG4NameMap::TG4NameMap()
19 : fSecond(fgUndefined) {
23 //_____________________________________________________________________________
24 TG4NameMap::TG4NameMap(const TG4NameMap& right) {
26 TG4Globals::Exception("TG4NameMap is protected from copying.");
29 //_____________________________________________________________________________
30 TG4NameMap::~TG4NameMap() {
36 //_____________________________________________________________________________
37 TG4NameMap& TG4NameMap::operator=(const TG4NameMap& right)
39 // check assignement to self
40 if (this == &right) return *this;
42 TG4Globals::Exception("TG4NameMap is protected from assigning.");
49 //_____________________________________________________________________________
50 G4bool TG4NameMap::Add(const G4String& first, const G4String& second)
52 // Adds names pair to the map.
53 // fSecond is not used in this add method.
56 if (GetSecond(first) == fgUndefined) {
58 // only in case it is not yet here
65 //_____________________________________________________________________________
66 G4bool TG4NameMap::AddName(const G4String& name)
68 // Adds name to the map.
71 if (GetSecond(name) == fgUndefined) {
73 // only in case it is not yet here
80 //_____________________________________________________________________________
81 const G4String& TG4NameMap::GetSecond(const G4String& name)
83 // Gets second name associated with given name.
86 MapIterator i = fMap.find(name);
93 //_____________________________________________________________________________
94 void TG4NameMap::PrintAll()
100 G4cout << "Dump of TG4NameMap - " << fMap.size() << " entries:" << G4endl;
102 for (MapIterator i=fMap.begin(); i != fMap.end(); i++) {
103 const G4String& first = (*i).first;
104 const G4String& second = (*i).second;
105 G4cout << "Map element " << G4std::setw(3) << counter++ << " "
106 << first << " " << second << G4endl;
111 //_____________________________________________________________________________
112 void TG4NameMap::Clear()
118 fSecond = "Undefined";