Adding comment lines to class description needed for Root documentation,
[u/mrichter/AliRoot.git] / MUON / AliMUON1DMap.cxx
CommitLineData
83c386fb 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 "AliMUON1DMap.h"
19
20#include "AliLog.h"
21#include "AliMpExMap.h"
22#include "AliMUON1DMapIterator.h"
23
3d1463c8 24//-----------------------------------------------------------------------------
83c386fb 25/// \class AliMUON1DMap
26/// This class is simply a wrapper to an AliMpExMap, offering in addition a
27/// control over the replacement policy when you add
28/// something to it.
29///
30/// \author Laurent Aphecetche
3d1463c8 31//-----------------------------------------------------------------------------
83c386fb 32
33/// \cond CLASSIMP
34ClassImp(AliMUON1DMap)
35/// \endcond
36
37//_____________________________________________________________________________
38AliMUON1DMap::AliMUON1DMap(Int_t theSize)
4178b5c7 39: AliMUONVStore(),
83c386fb 40 fMap(new AliMpExMap(true))
41{
42/// Default ctor
43
44 if ( theSize )
45 {
46 fMap->SetSize(theSize);
47 }
48 fMap->SetOwner(kTRUE);
49}
50
51//_____________________________________________________________________________
52AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
4178b5c7 53: AliMUONVStore(),
83c386fb 54 fMap(0x0)
55{
56/// Copy constructor
57
58 other.CopyTo(*this);
59}
60
61//_____________________________________________________________________________
62AliMUON1DMap&
63AliMUON1DMap::operator=(const AliMUON1DMap& other)
64{
65/// Assignment operator
66
67 other.CopyTo(*this);
68 return *this;
69}
70
71//_____________________________________________________________________________
72AliMUON1DMap::~AliMUON1DMap()
73{
74/// dtor, we're the owner of our internal map.
75
76 delete fMap;
77}
78
79//_____________________________________________________________________________
4178b5c7 80Bool_t
81AliMUON1DMap::Add(TObject* object)
82{
83 /// Add an object to this, using uniqueID as the key
84 if (!object) return kFALSE;
85 Set(object->GetUniqueID(),object,kFALSE);
86 return kTRUE;
87}
88
89//_____________________________________________________________________________
90void
91AliMUON1DMap::Clear(Option_t*)
92{
93 /// Reset
94 delete fMap;
95 fMap = 0x0;
96}
97
98//_____________________________________________________________________________
83c386fb 99void
100AliMUON1DMap::CopyTo(AliMUON1DMap& dest) const
101{
102/// Make a deep copy
103
104 delete dest.fMap;
105 dest.fMap = fMap;
106}
107
108//_____________________________________________________________________________
4178b5c7 109AliMUON1DMap*
110AliMUON1DMap::Create() const
111{
112 /// Create an empty clone of this
113 return new AliMUON1DMap(fMap->GetSize());
114}
115
116//_____________________________________________________________________________
83c386fb 117TObject*
4178b5c7 118AliMUON1DMap::FindObject(UInt_t i) const
83c386fb 119{
120/// Get the object located at index i, if it exists, and if i is correct.
121
122 return fMap->GetValue(i);
123}
124
125//_____________________________________________________________________________
4178b5c7 126TIterator*
127AliMUON1DMap::CreateIterator() const
83c386fb 128{
129 // Create and return an iterator on this map
130 // Returned iterator must be deleted by user.
131 if ( fMap )
132 {
133 return new AliMUON1DMapIterator(*fMap);
134 }
135 return 0x0;
136}
137
4178b5c7 138//_____________________________________________________________________________
139Int_t
140AliMUON1DMap::GetSize() const
141{
142 /// Return the number of objects we hold
143 return fMap->GetSize();
144}
83c386fb 145
146//_____________________________________________________________________________
147Bool_t
148AliMUON1DMap::Set(Int_t i, TObject* object, Bool_t replace)
149{
150/// Set the object located at i
151/// If replace=kFALSE and there's already an object at location i,
152/// this method fails and returns kFALSE, otherwise it returns kTRUE
153
4178b5c7 154 TObject* o = FindObject(i);
83c386fb 155 if ( o && !replace )
156 {
157 AliError(Form("Object %p is already there for i=%d",o,i));
158 return kFALSE;
159 }
160 if ( replace )
161 {
162 delete o;
163 }
164 fMap->Add(i,object);
165 return kTRUE;
166}
167
168
169