]>
Commit | Line | Data |
---|---|---|
55ab3bd1 | 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 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
55ab3bd1 | 19 | /// \class AliMUONTOTCAStoreIterator |
20 | /// | |
21 | /// An iterator to access TObject stored in a TObjArray of TClonesArray | |
22 | /// | |
55ab3bd1 | 23 | /// \author Laurent Aphecetche, Subatech |
3d1463c8 | 24 | //----------------------------------------------------------------------------- |
55ab3bd1 | 25 | |
26 | #include "AliMUONTOTCAStoreIterator.h" | |
27 | ||
28 | #include <TClonesArray.h> | |
29 | #include <TObjArray.h> | |
30 | ||
31 | /// \cond CLASSIMP | |
32 | ClassImp(AliMUONTOTCAStoreIterator) | |
33 | /// \endcond | |
34 | ||
35 | //_____________________________________________________________________________ | |
36 | AliMUONTOTCAStoreIterator::AliMUONTOTCAStoreIterator(const TObjArray* data, | |
37 | Int_t firstChamberId, | |
38 | Int_t lastChamberId) | |
39 | : | |
40 | TIterator(), | |
41 | fData(data), | |
42 | fFirstChamberId(firstChamberId), | |
43 | fLastChamberId(lastChamberId), | |
44 | fCurrentTCA(0x0), | |
45 | fCurrentTCAIndex(-1), | |
46 | fCurrentChamberId(-1) | |
47 | { | |
48 | /// Standard constructor | |
49 | Reset(); | |
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
6805f5be | 53 | AliMUONTOTCAStoreIterator& |
55ab3bd1 | 54 | AliMUONTOTCAStoreIterator::operator=(const TIterator& rhs) |
55 | { | |
56 | /// Overriden operator= (imposed by Root's declaration of TIterator ?) | |
57 | if ( this != &rhs && rhs.IsA() == AliMUONTOTCAStoreIterator::Class() ) | |
58 | { | |
59 | const AliMUONTOTCAStoreIterator& rhs1 = | |
60 | static_cast<const AliMUONTOTCAStoreIterator&>(rhs); | |
61 | ||
62 | rhs1.CopyTo(*this); | |
63 | } | |
64 | return *this; | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliMUONTOTCAStoreIterator::AliMUONTOTCAStoreIterator(const AliMUONTOTCAStoreIterator& rhs) | |
69 | : | |
70 | TIterator(rhs), | |
71 | fData(0x0), | |
72 | fFirstChamberId(-1), | |
73 | fLastChamberId(-1), | |
74 | fCurrentTCA(0x0), | |
75 | fCurrentTCAIndex(-1), | |
76 | fCurrentChamberId(-1) | |
77 | { | |
78 | /// Copy constructor | |
79 | ||
80 | rhs.CopyTo(*this); | |
81 | } | |
82 | ||
83 | //_____________________________________________________________________________ | |
84 | AliMUONTOTCAStoreIterator::~AliMUONTOTCAStoreIterator() | |
85 | { | |
86 | /// Destructor | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | AliMUONTOTCAStoreIterator& | |
91 | AliMUONTOTCAStoreIterator::operator=(const AliMUONTOTCAStoreIterator& rhs) | |
92 | { | |
93 | /// Assignment operator | |
94 | ||
95 | rhs.CopyTo(*this); | |
96 | return *this; | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | void | |
101 | AliMUONTOTCAStoreIterator::CopyTo(AliMUONTOTCAStoreIterator& destination) const | |
102 | { | |
103 | /// Copy *this to destination | |
104 | destination.fData=fData; | |
105 | destination.fFirstChamberId=fFirstChamberId; | |
106 | destination.fLastChamberId=fLastChamberId; | |
107 | destination.fCurrentTCAIndex=fCurrentTCAIndex; | |
108 | destination.fCurrentChamberId=fCurrentChamberId; | |
109 | destination.fCurrentTCA=fCurrentTCA; | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | const TCollection* | |
114 | AliMUONTOTCAStoreIterator::GetCollection() const | |
115 | { | |
116 | /// The top level collection we're iterating upon, i.e. a TObjArray | |
117 | return fData; | |
118 | } | |
119 | ||
120 | //_____________________________________________________________________________ | |
121 | TObject* | |
122 | AliMUONTOTCAStoreIterator::Next() | |
123 | { | |
124 | /// Find and return next element in the store | |
125 | ||
126 | if ( fCurrentTCA && fCurrentTCAIndex < fCurrentTCA->GetLast() ) | |
127 | { | |
128 | ++fCurrentTCAIndex; | |
129 | } | |
130 | else | |
131 | { | |
132 | fCurrentTCAIndex = 0; | |
133 | fCurrentTCA = 0; | |
134 | ||
135 | while ( ( !fCurrentTCA || fCurrentTCA->GetLast()==-1 ) && | |
136 | fCurrentChamberId < fLastChamberId ) | |
137 | { | |
138 | ++fCurrentChamberId; | |
139 | fCurrentTCA = static_cast<TClonesArray*>(fData->At(fCurrentChamberId)); | |
140 | } | |
141 | } | |
142 | ||
143 | if ( fCurrentTCA ) | |
144 | { | |
145 | // get the pointer to be returned | |
146 | return fCurrentTCA->At(fCurrentTCAIndex); | |
147 | } | |
148 | ||
149 | return 0x0; | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | void | |
154 | AliMUONTOTCAStoreIterator::Reset() | |
155 | { | |
156 | /// Reset the iterator | |
157 | fCurrentTCAIndex = -1; | |
158 | fCurrentChamberId = fFirstChamberId-1; | |
159 | fCurrentTCA = 0x0; | |
160 | } |