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