Line data Source code
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 : #include "AliMpExMap.h"
27 :
28 : #include "AliLog.h"
29 :
30 : #include <TClass.h>
31 : #include <TExMap.h>
32 : #include <TString.h>
33 :
34 : /// \cond CLASSIMP
35 18 : ClassImp(AliMpExMapIterator)
36 : /// \endcond
37 :
38 : //_____________________________________________________________________________
39 : AliMpExMapIterator::AliMpExMapIterator(const AliMpExMap& theMap)
40 27024 : : TIterator(),
41 81072 : fIterator(new TExMapIter(&(theMap.fMap)))
42 135120 : {
43 : /// Standard constructor
44 54048 : }
45 :
46 : //_____________________________________________________________________________
47 : AliMpExMapIterator::AliMpExMapIterator(const AliMpExMapIterator& rhs)
48 0 : : TIterator(rhs),
49 0 : fIterator(rhs.fIterator)
50 0 : {
51 : /// Copy constructor
52 0 : }
53 :
54 : //_____________________________________________________________________________
55 : AliMpExMapIterator&
56 : AliMpExMapIterator::operator=(const AliMpExMapIterator& rhs)
57 : {
58 : /// Assignment operator
59 :
60 0 : if ( this != &rhs )
61 : {
62 0 : fIterator = rhs.fIterator;
63 0 : }
64 0 : 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 0 : if ( this != &rhs && rhs.IsA() == AliMpExMapIterator::Class() )
74 : {
75 0 : const AliMpExMapIterator& rhs1 = static_cast<const AliMpExMapIterator&>(rhs);
76 0 : fIterator = rhs1.fIterator;
77 0 : }
78 0 : return *this;
79 : }
80 :
81 : //_____________________________________________________________________________
82 : AliMpExMapIterator::~AliMpExMapIterator()
83 162144 : {
84 : /// Destructor
85 :
86 54048 : delete fIterator;
87 81072 : }
88 :
89 : //_____________________________________________________________________________
90 : Bool_t
91 : AliMpExMapIterator::Next(Index_t& index, TObject*& object)
92 : {
93 : /// Move to next object in iteration
94 :
95 3957286 : Index_t value = 0;
96 :
97 1978643 : object = 0;
98 :
99 1978643 : Bool_t rv = fIterator->Next(index,value);
100 :
101 1978643 : if ( rv )
102 : {
103 1966105 : object = reinterpret_cast<TObject*> (value);
104 1966105 : }
105 :
106 1978643 : return rv;
107 1978643 : }
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 3941444 : Index_t dummy;
116 1970722 : TObject* o(0x0);
117 1970722 : Next(dummy,o);
118 3941444 : return o;
119 1970722 : }
120 :
121 : //_____________________________________________________________________________
122 : TObject*
123 : AliMpExMapIterator::Next(Int_t& key)
124 : {
125 : /// Return the next object in iteration and fill the key.
126 : /// The returned object must not be deleted by the user.
127 :
128 15842 : TObject* o;
129 7921 : Index_t index;
130 7921 : Next(index,o);
131 7921 : key = (Int_t)(index);
132 15842 : return o;
133 7921 : }
134 :
135 : //_____________________________________________________________________________
136 : TObject*
137 : AliMpExMapIterator::Next(Int_t& keyFirst, Int_t& keySecond)
138 : {
139 : /// Return the next object in iteration and fill the key.
140 : /// The returned object must not be deleted by the user.
141 0 : Index_t index;
142 0 : TObject* o(0x0);
143 0 : Next(index,o);
144 0 : keyFirst = AliMpExMap::GetPairFirst(index);
145 0 : keySecond = AliMpExMap::GetPairSecond(index);
146 0 : return o;
147 0 : }
148 :
149 : //_____________________________________________________________________________
150 : TObject*
151 : AliMpExMapIterator::Next(TString& key)
152 : {
153 : /// Return the next object in iteration and fill the key.
154 : /// The returned object must not be deleted by the user.
155 0 : Index_t index;
156 0 : TObject* o(0x0);
157 0 : Next(index,o);
158 0 : key = AliMpExMap::GetString(index);
159 0 : return o;
160 0 : }
161 :
162 : //_____________________________________________________________________________
163 : void
164 : AliMpExMapIterator::Reset()
165 : {
166 : /// Reset
167 :
168 2578 : fIterator->Reset();
169 1289 : }
170 :
171 : //_____________________________________________________________________________
172 : const TCollection*
173 : AliMpExMapIterator::GetCollection() const
174 : {
175 : /// Nothing to be returned here, AliMpExMap is not a TCollection
176 :
177 0 : return 0x0;
178 : }
|