]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUON1DMap.cxx
Restored compilation on Windows/Cygwin
[u/mrichter/AliRoot.git] / MUON / AliMUON1DMap.cxx
... / ...
CommitLineData
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#include "AliMUON1DMapIterator.h"
20#include "AliMpExMap.h"
21
22#include "AliLog.h"
23
24//-----------------------------------------------------------------------------
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
31//-----------------------------------------------------------------------------
32
33/// \cond CLASSIMP
34ClassImp(AliMUON1DMap)
35/// \endcond
36
37//_____________________________________________________________________________
38AliMUON1DMap::AliMUON1DMap(Int_t theSize)
39: AliMUONVStore(),
40 fMap(new AliMpExMap(kTRUE))
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)
53: AliMUONVStore(),
54 fMap(new AliMpExMap(*other.fMap))
55{
56/// Copy constructor
57}
58
59//_____________________________________________________________________________
60AliMUON1DMap&
61AliMUON1DMap::operator=(const AliMUON1DMap& other)
62{
63/// Assignment operator
64 *fMap = *other.fMap;
65 return *this;
66}
67
68//_____________________________________________________________________________
69AliMUON1DMap::~AliMUON1DMap()
70{
71/// destructor
72 delete fMap;
73}
74
75//_____________________________________________________________________________
76Bool_t
77AliMUON1DMap::Add(TObject* object)
78{
79 /// Add an object to this, using uniqueID as the key
80 if (!object) return kFALSE;
81 return Set(object->GetUniqueID(),object);
82}
83
84//_____________________________________________________________________________
85void
86AliMUON1DMap::Clear(Option_t*)
87{
88 /// Reset
89 fMap->Clear();
90}
91
92//_____________________________________________________________________________
93AliMUON1DMap*
94AliMUON1DMap::Create() const
95{
96 /// Create an empty clone of this
97 return new AliMUON1DMap(fMap->GetSize());
98}
99
100//_____________________________________________________________________________
101TObject*
102AliMUON1DMap::FindObject(UInt_t i) const
103{
104/// Get the object located at index i, if it exists, and if i is correct.
105 return fMap->GetValue(i);
106}
107
108//_____________________________________________________________________________
109TObject*
110AliMUON1DMap::FindObject(Int_t i, Int_t j) const
111{
112 /// Get the object located at index (i,j), if it exists, and if i,j is correct.
113
114 UInt_t uid = ( ( ( j & 0xFFFF ) << 16 ) | ( i & 0xFFFF ) );
115
116 return fMap->GetValue(uid);
117}
118
119//_____________________________________________________________________________
120TIterator*
121AliMUON1DMap::CreateIterator() const
122{
123 /// Create and return an iterator on this map
124 /// Returned iterator must be deleted by user.
125 return new AliMUON1DMapIterator(*fMap);
126}
127
128//_____________________________________________________________________________
129Int_t
130AliMUON1DMap::GetSize() const
131{
132 /// Return the number of objects we hold
133 return fMap->GetSize();
134}
135
136//_____________________________________________________________________________
137Bool_t
138AliMUON1DMap::Set(Int_t i, TObject* object)
139{
140/// Set the object located at i
141/// If there's already an object at location i,
142/// this method fails and returns kFALSE, otherwise it returns kTRUE
143
144 TObject* o = FindObject(i);
145 if ( o )
146 {
147 AliError(Form("Object %p is already there for i=%d",o,i));
148 return kFALSE;
149 }
150 fMap->Add(i,object);
151 return kTRUE;
152}
153