4 // Author: I. Hrivnacova
8 // See the class description in the header file.
10 #include "TG4NameMap.h"
11 #include "TG4Globals.h"
13 #include "g4std/iomanip"
16 G4String TG4NameMap::fgUndefined = "Undefined";
18 //_____________________________________________________________________________
19 TG4NameMap::TG4NameMap()
20 : fSecond(fgUndefined) {
24 //_____________________________________________________________________________
25 TG4NameMap::TG4NameMap(const TG4NameMap& right) {
27 TG4Globals::Exception("TG4NameMap is protected from copying.");
30 //_____________________________________________________________________________
31 TG4NameMap::~TG4NameMap() {
37 //_____________________________________________________________________________
38 TG4NameMap& TG4NameMap::operator=(const TG4NameMap& right)
40 // check assignement to self
41 if (this == &right) return *this;
43 TG4Globals::Exception("TG4NameMap is protected from assigning.");
50 //_____________________________________________________________________________
51 G4bool TG4NameMap::Add(const G4String& first, const G4String& second)
53 // Adds names pair to the map.
54 // fSecond is not used in this add method.
57 if (GetSecond(first) == fgUndefined) {
59 // only in case it is not yet here
66 //_____________________________________________________________________________
67 G4bool TG4NameMap::AddName(const G4String& name)
69 // Adds name to the map.
72 if (GetSecond(name) == fgUndefined) {
74 // only in case it is not yet here
81 //_____________________________________________________________________________
82 const G4String& TG4NameMap::GetSecond(const G4String& name)
84 // Gets second name associated with given name.
87 MapIterator i = fMap.find(name);
94 //_____________________________________________________________________________
95 void TG4NameMap::PrintAll() const
101 G4cout << "Dump of TG4NameMap - " << fMap.size() << " entries:" << G4endl;
103 for (MapConstIterator i=fMap.begin(); i != fMap.end(); i++) {
104 const G4String& first = (*i).first;
105 const G4String& second = (*i).second;
106 G4cout << "Map element " << G4std::setw(3) << counter++ << " "
107 << first << " " << second << G4endl;
112 //_____________________________________________________________________________
113 void TG4NameMap::Clear()
119 fSecond = "Undefined";