]>
Commit | Line | Data |
---|---|---|
8cb048f5 | 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 | ||
b89ac3d6 | 18 | //----------------------------------------------------------------------------- |
19 | // Class AliMpExMapIterator | |
20 | // ------------------------ | |
21 | // Implementation of TIterator for AliMpExMap | |
22 | // Author: Laurent Aphecetche | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
8cb048f5 | 25 | #include "AliMpExMapIterator.h" |
168e9c4d | 26 | #include "AliMpExMap.h" |
8cb048f5 | 27 | |
28 | #include "AliLog.h" | |
168e9c4d | 29 | |
8cb048f5 | 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) | |
6805f5be | 40 | : TIterator(), |
41 | fIterator(new TExMapIter(&(theMap.fMap))) | |
8cb048f5 | 42 | { |
43 | /// Standard constructor | |
44 | } | |
45 | ||
46 | //_____________________________________________________________________________ | |
47 | AliMpExMapIterator::AliMpExMapIterator(const AliMpExMapIterator& rhs) | |
6805f5be | 48 | : TIterator(rhs), |
49 | fIterator(rhs.fIterator) | |
8cb048f5 | 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 | //_____________________________________________________________________________ | |
6805f5be | 68 | AliMpExMapIterator& |
8cb048f5 | 69 | AliMpExMapIterator::operator=(const TIterator& rhs) |
70 | { | |
6805f5be | 71 | /// Overriden operator= (imposed by Root's definition of TIterator::operator= ?) |
8cb048f5 | 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 | //_____________________________________________________________________________ | |
ccd5731f | 90 | #if ROOT_SVN_REVISION >= 29598 |
82280315 | 91 | Bool_t |
92 | AliMpExMapIterator::Next(Long64_t& index, TObject*& object) | |
93 | #else | |
8cb048f5 | 94 | Bool_t |
95 | AliMpExMapIterator::Next(Long_t& index, TObject*& object) | |
82280315 | 96 | #endif |
8cb048f5 | 97 | { |
98 | /// Move to next object in iteration | |
99 | ||
ccd5731f | 100 | #if ROOT_SVN_REVISION >= 29598 |
82280315 | 101 | Long64_t value(0); |
102 | #else | |
8cb048f5 | 103 | Long_t value(0); |
82280315 | 104 | #endif |
8cb048f5 | 105 | |
106 | object = 0; | |
107 | ||
108 | Bool_t rv = fIterator->Next(index,value); | |
109 | ||
110 | if ( rv ) | |
111 | { | |
112 | object = reinterpret_cast<TObject*> (value); | |
113 | } | |
114 | ||
115 | return rv; | |
116 | } | |
117 | ||
118 | //_____________________________________________________________________________ | |
119 | TObject* | |
120 | AliMpExMapIterator::Next() | |
121 | { | |
122 | /// Return the next object in iteration. | |
123 | /// The returned object must not be deleted by the user. | |
124 | ||
ccd5731f | 125 | #if ROOT_SVN_REVISION >= 29598 |
82280315 | 126 | Long64_t dummy; |
127 | #else | |
8cb048f5 | 128 | Long_t dummy; |
82280315 | 129 | #endif |
8cb048f5 | 130 | TObject* o(0x0); |
131 | Next(dummy,o); | |
132 | return o; | |
133 | } | |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | TObject* | |
137 | AliMpExMapIterator::Next(Int_t& key) | |
138 | { | |
139 | /// Return the next object in iteration and fill the key. | |
140 | /// The returned object must not be deleted by the user. | |
141 | ||
142 | TObject* o; | |
ccd5731f | 143 | #if ROOT_SVN_REVISION >= 29598 |
82280315 | 144 | Long64_t index; |
145 | #else | |
8cb048f5 | 146 | Long_t index; |
82280315 | 147 | #endif |
8cb048f5 | 148 | Next(index,o); |
149 | key = (Int_t)(index); | |
150 | return o; | |
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | TObject* | |
168e9c4d | 155 | AliMpExMapIterator::Next(Int_t& keyFirst, Int_t& keySecond) |
8cb048f5 | 156 | { |
157 | /// Return the next object in iteration and fill the key. | |
158 | /// The returned object must not be deleted by the user. | |
159 | ||
ccd5731f | 160 | #if ROOT_SVN_REVISION >= 29598 |
82280315 | 161 | Long64_t index; |
162 | #else | |
8cb048f5 | 163 | Long_t index; |
82280315 | 164 | #endif |
8cb048f5 | 165 | TObject* o(0x0); |
166 | Next(index,o); | |
168e9c4d | 167 | keyFirst = AliMpExMap::GetPairFirst(index); |
168 | keySecond = AliMpExMap::GetPairSecond(index); | |
8cb048f5 | 169 | return o; |
170 | } | |
171 | ||
172 | //_____________________________________________________________________________ | |
173 | TObject* | |
174 | AliMpExMapIterator::Next(TString& key) | |
175 | { | |
176 | /// Return the next object in iteration and fill the key. | |
177 | /// The returned object must not be deleted by the user. | |
178 | ||
ccd5731f | 179 | #if ROOT_SVN_REVISION >= 29598 |
82280315 | 180 | Long64_t index; |
181 | #else | |
8cb048f5 | 182 | Long_t index; |
82280315 | 183 | #endif |
8cb048f5 | 184 | TObject* o(0x0); |
185 | Next(index,o); | |
186 | key = AliMpExMap::GetString(index); | |
187 | return o; | |
188 | } | |
189 | ||
190 | //_____________________________________________________________________________ | |
191 | void | |
192 | AliMpExMapIterator::Reset() | |
193 | { | |
194 | /// Reset | |
195 | ||
196 | fIterator->Reset(); | |
197 | } | |
198 | ||
199 | //_____________________________________________________________________________ | |
200 | const TCollection* | |
201 | AliMpExMapIterator::GetCollection() const | |
202 | { | |
203 | /// Nothing to be returned here, AliMpExMap is not a TCollection | |
204 | ||
205 | return 0x0; | |
206 | } |