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