a95de14b9f35b124f11c3af60f923de2f1ebcc0a
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMapIterator.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 #include "AliMUON2DMapIterator.h"
19
20 //-----------------------------------------------------------------------------
21 /// \class AliMUON2DMapIterator
22 /// Implementation of TIterator for 2Dmaps
23 /// 
24 /// A simple implementation of VDataIterator for 2Dmaps.
25 ///
26 /// \author Laurent Aphecetche
27 //-----------------------------------------------------------------------------
28
29 #include "AliMpExMap.h"
30 #include "AliMpExMapIterator.h"
31 #include "AliLog.h"
32
33 /// \cond CLASSIMP
34 ClassImp(AliMUON2DMapIterator)
35 /// \endcond
36
37 //_____________________________________________________________________________
38 AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap)
39 : TIterator(),
40 fkMap(&theMap),
41 fIter1(theMap.CreateIterator()),
42 fIter2(NextIterator())
43 {
44   /// default ctor
45   Reset();
46 }
47
48 //_____________________________________________________________________________
49 AliMUON2DMapIterator& 
50 AliMUON2DMapIterator::operator=(const TIterator& /*rhs*/)
51 {
52   // overriden operator= (imposed by Root's definition of TIterator::operator= ?)
53   
54   AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor
55   return *this;
56 }
57
58 //_____________________________________________________________________________
59 AliMUON2DMapIterator::~AliMUON2DMapIterator()
60 {
61   /// dtor
62 }
63
64 //_____________________________________________________________________________
65 const TCollection* 
66 AliMUON2DMapIterator::GetCollection() const
67 {
68   /// Return 0 as we're not really dealing with a Root TCollection...
69   return 0x0;
70 }
71
72 //_____________________________________________________________________________
73 TIterator*
74 AliMUON2DMapIterator::NextIterator()
75 {
76   /// Get next map (from fIter1) and create an iterator to it
77   
78   AliMpExMap* m = static_cast<AliMpExMap*>(fIter1->Next());
79
80   if (!m) return 0x0;
81   
82   return m->CreateIterator();
83 }
84
85 //_____________________________________________________________________________
86 TObject*
87 AliMUON2DMapIterator::Next()
88 {
89   /// return next object
90   
91   if (!fIter2) return 0x0;
92
93   TObject* o = fIter2->Next();
94   
95   if (!o)
96   {
97     fIter2 = NextIterator();
98     return Next();
99   }
100   
101   return o;
102 }
103
104 //_____________________________________________________________________________
105 void
106 AliMUON2DMapIterator::Reset()
107 {
108   /// rewind the iterator
109   
110   delete fIter2;
111   fIter1->Reset();
112   fIter2 = NextIterator();
113 }
114