]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4NameMap.cxx
not used typedef removed
[u/mrichter/AliRoot.git] / TGeant4 / TG4NameMap.cxx
1 // $Id$
2 // Category: global
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class TG4NameMap
7 // ----------------
8 // See the class description in the header file.
9
10 #include "TG4NameMap.h"
11 #include "TG4Globals.h"
12
13 #include "g4std/iomanip"
14 #include "globals.hh"
15
16 G4String TG4NameMap::fgUndefined = "Undefined";
17
18 //_____________________________________________________________________________
19 TG4NameMap::TG4NameMap() 
20   : fSecond(fgUndefined) {
21 //
22 }
23
24 //_____________________________________________________________________________
25 TG4NameMap::TG4NameMap(const TG4NameMap& right) {
26 //
27   TG4Globals::Exception("TG4NameMap is protected from copying.");
28 }  
29
30 //_____________________________________________________________________________
31 TG4NameMap::~TG4NameMap() {
32 //
33 }
34
35 // operators
36
37 //_____________________________________________________________________________
38 TG4NameMap& TG4NameMap::operator=(const TG4NameMap& right)
39 {
40   // check assignement to self
41   if (this == &right) return *this;
42
43   TG4Globals::Exception("TG4NameMap is protected from assigning.");
44     
45   return *this;  
46 }    
47           
48 // public methods
49
50 //_____________________________________________________________________________
51 G4bool TG4NameMap::Add(const G4String& first, const G4String& second)
52 {  
53 // Adds names pair to the map.
54 // fSecond is not used in this add method.
55 // ---
56
57   if (GetSecond(first) == fgUndefined) {
58     // insert into map 
59     // only in case it is not yet here
60     fMap[first] = second;
61     return true;
62   }
63   return false;
64 }
65
66 //_____________________________________________________________________________
67 G4bool TG4NameMap::AddName(const G4String& name)
68 {  
69 // Adds name to the map.
70 // ---
71
72   if (GetSecond(name) == fgUndefined) {
73     // insert into map 
74     // only in case it is not yet here
75     fMap[name] = fSecond;
76     return true;
77   }
78   return false;
79 }
80
81 //_____________________________________________________________________________
82 const G4String& TG4NameMap::GetSecond(const G4String& name)
83 {
84 // Gets second name associated with given name.
85 // ---
86
87   MapIterator i = fMap.find(name);
88   if (i == fMap.end()) 
89     return fgUndefined;
90   else                 
91     return (*i).second;
92 }
93
94 //_____________________________________________________________________________
95 void TG4NameMap::PrintAll() const
96 {
97 // Dumps all map.
98 // ---
99
100   if (fMap.size()) {
101     G4cout << "Dump of TG4NameMap - " << fMap.size() << " entries:" << G4endl;
102     G4int counter = 0;
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;
108     }
109   }
110 }
111
112 //_____________________________________________________________________________
113 void TG4NameMap::Clear() 
114 {
115 // Clears the map.
116 // ---
117
118   fMap.clear();
119   fSecond = "Undefined";
120 }