Fixing Doxygen warnings
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSlatMotifMap.cxx
CommitLineData
dd4ea4ef 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
3d1463c8 16
17//-----------------------------------------------------------------------------
dd4ea4ef 18/// \class AliMpSlatMotifMap
19//
20/// Basically this class provide a garbage collection of AliMpMotif and
21/// AliMpMotifType objects.
22///
23///
24/// \author Laurent Aphecetche
3d1463c8 25//-----------------------------------------------------------------------------
dd4ea4ef 26
27
28// $Id$
29
30#include "AliMpSlatMotifMap.h"
31
32#include "AliMpVMotif.h"
33#include "AliMpMotifType.h"
34#include "AliLog.h"
35#include "TList.h"
36#include "TObjString.h"
37#include "TString.h"
38#include "Riostream.h"
39
05a63cc8 40/// \cond CLASSIMP
dd4ea4ef 41ClassImp(AliMpSlatMotifMap)
05a63cc8 42/// \endcond
43
dd4ea4ef 44//_____________________________________________________________________________
45AliMpSlatMotifMap::AliMpSlatMotifMap()
46: TObject(),
47fMotifs(),
48fMotifTypes()
49{
50 /// ctor
51 fMotifs.SetOwner(kTRUE);
52 fMotifTypes.SetOwner(kTRUE);
53}
54
55//_____________________________________________________________________________
56AliMpSlatMotifMap::~AliMpSlatMotifMap()
57{
58 /// dtor
59 Reset();
60}
61
62//_____________________________________________________________________________
63void
64AliMpSlatMotifMap::Reset()
65{
66 /// Clear
67 fMotifs.DeleteAll();
68 fMotifTypes.DeleteAll();
69}
70
71//_____________________________________________________________________________
72Bool_t
73AliMpSlatMotifMap::AddMotif(AliMpVMotif* motif, Bool_t warn)
74{
75 /// Add a motif to the map
76 AliDebug(1,Form("Adding motif %s",motif->GetID().Data()));
77
78 AliMpVMotif* found = FindMotif(motif->GetID());
79 if (found) {
80 if (warn && found == motif)
81 {
82 AliWarning(Form("The motif %s is already in map",motif->GetID().Data()));
83 }
84 if (warn && found != motif)
85 {
86 AliError(Form("Another motif with the same ID=%s is already in map",
87 motif->GetID().Data()));
88 }
89 return false;
90 }
91
92 fMotifs.Add(new TObjString(motif->GetID()),motif);
93 return true;
94}
95
96//_____________________________________________________________________________
97Bool_t
98AliMpSlatMotifMap::AddMotifType(AliMpMotifType* motifType, Bool_t warn)
99{
100 /// Add a motif to the map
101
102 AliDebug(1,Form("Adding motifType %s",motifType->GetID().Data()));
103
104 AliMpMotifType* found = FindMotifType(motifType->GetID());
105 if (found) {
106 if (warn && found == motifType)
107 {
108 AliWarning(Form("The motifType %s is already in map",
109 motifType->GetID().Data()));
110 }
111 if (warn && found != motifType)
112 {
113 AliError(Form("Another motifType with the same ID=%s is already in map",
114 motifType->GetID().Data()));
115 }
116 return false;
117 }
118
119 fMotifTypes.Add(new TObjString(motifType->GetID()),motifType);
120 return true;
121
122}
123
124//_____________________________________________________________________________
125AliMpVMotif*
126AliMpSlatMotifMap::FindMotif(const TString& id) const
127{
128 /// Search a given motif in the map and returns it if it's there.
129
130 AliDebug(1,Form("Looking for motif %s",id.Data()));
131
132 TObject* object = fMotifs.GetValue(id.Data());
133
134 if (object)
135 {
136 AliMpVMotif* motif = static_cast<AliMpVMotif*>(object);
137 AliDebug(1,Form("Found : %p id=%s",motif,motif->GetID().Data()));
138 return motif;
139 }
140 AliDebug(1,"Not found");
141 return 0x0;
142}
143
144//_____________________________________________________________________________
145AliMpMotifType*
146AliMpSlatMotifMap::FindMotifType(const TString& id) const
147{
148 /// Search a given motifType in the map and returns it if it's there.
149 AliDebug(1,Form("Looking for motifType %s",id.Data()));
150
151 TObject* object = fMotifTypes.GetValue(id.Data());
152
153 if (object)
154 {
155 AliMpMotifType* motifType = static_cast<AliMpMotifType*>(object);
156 AliDebug(1,Form("Found : %p id=%s",motifType,motifType->GetID().Data()));
157 return motifType;
158 }
159 AliDebug(1,"Not found");
160 return 0x0;
161
162}
163
164//_____________________________________________________________________________
165void
166AliMpSlatMotifMap::Print(Option_t*) const
167{
168 /// printout
169 cout << "Motifs=" << endl;
170 TObject* key;
171 TIter next(&fMotifs);
172 while ( ( key = next() ) )
173 {
174 AliMpVMotif* motif = dynamic_cast<AliMpVMotif*>(fMotifs.GetValue(key));
175 if (motif) cout << motif->GetID() << endl;
176 }
177
178 cout << "MotifTypes=" << endl;
179 TIter tnext(&fMotifTypes);
180 while ( ( key = tnext() ) )
181 {
182 AliMpMotifType* motifType = dynamic_cast<AliMpMotifType*>(fMotifTypes.GetValue(key));
183 if (motifType) cout << motifType->GetID() << endl;
184 }
185
186}