]>
Commit | Line | Data |
---|---|---|
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 |
34 | ClassImp(AliMUON2DMapIterator) | |
35 | /// \endcond | |
36 | ||
37 | //_____________________________________________________________________________ | |
7332f213 | 38 | AliMUON2DMapIterator::AliMUON2DMapIterator(const AliMpExMap& theMap) |
39 | : TIterator(), | |
40 | fkMap(&theMap), | |
630711ed | 41 | fIter1(theMap.CreateIterator()), |
42 | fIter2(NextIterator()) | |
f246123b | 43 | { |
c4ee792d | 44 | /// default ctor |
f246123b | 45 | Reset(); |
46 | } | |
47 | ||
cb6388d5 | 48 | //_____________________________________________________________________________ |
49 | TIterator& | |
50 | AliMUON2DMapIterator::operator=(const TIterator& rhs) | |
51 | { | |
52 | /// overriden operator= (imposed by Root's definition of TIterator::operator= ?) | |
53 | ||
54 | if ( this != &rhs && rhs.IsA() == AliMUON2DMapIterator::Class() ) | |
55 | { | |
630711ed | 56 | // const AliMUON2DMapIterator& rhs1 = static_cast<const AliMUON2DMapIterator&>(rhs); |
57 | AliFatalGeneral("operator=(TIterator&)",""); // as in copy ctor | |
cb6388d5 | 58 | } |
59 | return *this; | |
60 | } | |
61 | ||
f246123b | 62 | //_____________________________________________________________________________ |
63 | AliMUON2DMapIterator::~AliMUON2DMapIterator() | |
64 | { | |
c4ee792d | 65 | /// dtor |
f246123b | 66 | } |
67 | ||
cb6388d5 | 68 | //_____________________________________________________________________________ |
69 | const TCollection* | |
70 | AliMUON2DMapIterator::GetCollection() const | |
71 | { | |
72 | /// Return 0 as we're not really dealing with a Root TCollection... | |
73 | return 0x0; | |
74 | } | |
75 | ||
f246123b | 76 | //_____________________________________________________________________________ |
630711ed | 77 | TIterator* |
78 | AliMUON2DMapIterator::NextIterator() | |
f246123b | 79 | { |
630711ed | 80 | /// Get next map (from fIter1) and create an iterator to it |
81 | ||
82 | AliMpExMap* m = static_cast<AliMpExMap*>(fIter1->Next()); | |
83 | ||
84 | if (!m) return 0x0; | |
85 | ||
86 | return m->CreateIterator(); | |
f246123b | 87 | } |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | TObject* | |
91 | AliMUON2DMapIterator::Next() | |
92 | { | |
47a48067 | 93 | /// return next object |
94 | ||
630711ed | 95 | if (!fIter2) return 0x0; |
96 | ||
97 | TObject* o = fIter2->Next(); | |
f246123b | 98 | |
630711ed | 99 | if (!o) |
47a48067 | 100 | { |
630711ed | 101 | fIter2 = NextIterator(); |
102 | return Next(); | |
cb6388d5 | 103 | } |
630711ed | 104 | |
105 | return o; | |
f246123b | 106 | } |
107 | ||
108 | //_____________________________________________________________________________ | |
109 | void | |
110 | AliMUON2DMapIterator::Reset() | |
111 | { | |
c4ee792d | 112 | /// rewind the iterator |
47a48067 | 113 | |
630711ed | 114 | delete fIter2; |
115 | fIter1->Reset(); | |
116 | fIter2 = NextIterator(); | |
f246123b | 117 | } |
47a48067 | 118 |