]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpExMapIterator.cxx
Error message removed when data is posted by other than the owner.
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpExMapIterator.cxx
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
16 // $Id$
17
18 //-----------------------------------------------------------------------------
19 // Class AliMpExMapIterator
20 // ------------------------
21 // Implementation of TIterator for AliMpExMap
22 // Author: Laurent Aphecetche
23 //-----------------------------------------------------------------------------
24
25 #include "AliMpExMapIterator.h"
26
27 #include "AliLog.h"
28 #include "AliMpExMap.h"
29 #include "AliMpIntPair.h"
30 #include <TClass.h>
31 #include <TExMap.h>
32 #include <TString.h>
33
34 /// \cond CLASSIMP
35 ClassImp(AliMpExMapIterator)
36 /// \endcond
37
38 //_____________________________________________________________________________
39 AliMpExMapIterator::AliMpExMapIterator(const AliMpExMap& theMap)
40 : TIterator(),
41   fIterator(new TExMapIter(&(theMap.fMap)))
42 {
43 /// Standard constructor
44 }
45
46 //_____________________________________________________________________________
47 AliMpExMapIterator::AliMpExMapIterator(const AliMpExMapIterator& rhs)
48 : TIterator(rhs),
49   fIterator(rhs.fIterator)
50 {
51 /// Copy constructor
52 }
53
54 //_____________________________________________________________________________
55 AliMpExMapIterator& 
56 AliMpExMapIterator::operator=(const AliMpExMapIterator& rhs)
57 {
58 /// Assignment operator
59
60   if  ( this != &rhs )
61   {
62     fIterator = rhs.fIterator;
63   }
64   return *this;
65 }
66
67 //_____________________________________________________________________________
68 AliMpExMapIterator& 
69 AliMpExMapIterator::operator=(const TIterator& rhs)
70 {
71   /// Overriden operator= (imposed by Root's definition of TIterator::operator= ?)
72   
73   if ( this != &rhs && rhs.IsA() == AliMpExMapIterator::Class() ) 
74   {
75     const AliMpExMapIterator& rhs1 = static_cast<const AliMpExMapIterator&>(rhs);
76     fIterator = rhs1.fIterator;
77   }
78   return *this;
79 }
80
81 //_____________________________________________________________________________
82 AliMpExMapIterator::~AliMpExMapIterator()
83 {
84 /// Destructor
85
86   delete fIterator;
87 }
88
89 //_____________________________________________________________________________
90 Bool_t 
91 AliMpExMapIterator::Next(Long_t& index, TObject*& object)
92 {
93 /// Move to next object in iteration
94
95   Long_t value(0);
96
97   object = 0;
98   
99   Bool_t rv = fIterator->Next(index,value);
100
101   if ( rv )
102   {
103     object = reinterpret_cast<TObject*> (value);
104   }
105   
106   return rv;
107 }
108
109 //_____________________________________________________________________________
110 TObject* 
111 AliMpExMapIterator::Next()
112 {
113 /// Return the next object in iteration.
114 /// The returned object must not be deleted by the user.  
115
116   Long_t dummy;
117   TObject* o(0x0);
118   Next(dummy,o);
119   return o;
120 }
121
122 //_____________________________________________________________________________
123 TObject* 
124 AliMpExMapIterator::Next(Int_t& key)
125 {
126 /// Return the next object in iteration and fill the key.
127 /// The returned object must not be deleted by the user.  
128
129   TObject* o;
130   Long_t index;
131   Next(index,o);
132   key = (Int_t)(index);
133   return o;
134 }
135
136 //_____________________________________________________________________________
137 TObject* 
138 AliMpExMapIterator::Next(AliMpIntPair& key)
139 {
140 /// Return the next object in iteration and fill the key.
141 /// The returned object must not be deleted by the user.  
142
143   Long_t index;
144   TObject* o(0x0);
145   Next(index,o);
146   key = AliMpExMap::GetPair(index);
147   return o;
148 }
149
150 //_____________________________________________________________________________
151 TObject* 
152 AliMpExMapIterator::Next(TString& key)
153 {
154 /// Return the next object in iteration and fill the key.
155 /// The returned object must not be deleted by the user.  
156
157   Long_t index;
158   TObject* o(0x0);
159   Next(index,o);
160   key = AliMpExMap::GetString(index);
161   return o;
162 }
163
164 //_____________________________________________________________________________
165 void 
166 AliMpExMapIterator::Reset()
167 {
168 /// Reset
169
170   fIterator->Reset();
171 }
172
173 //_____________________________________________________________________________
174 const TCollection* 
175 AliMpExMapIterator::GetCollection() const 
176 {
177 /// Nothing to be returned here, AliMpExMap is not a TCollection
178
179   return 0x0;
180 }