]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUON1DMap.cxx
Add comments for Doxygen
[u/mrichter/AliRoot.git] / MUON / AliMUON1DMap.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 "AliMUON1DMap.h"
19
20 #include "AliLog.h"
21 #include "AliMpExMap.h"
22 #include "AliMUON1DMapIterator.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 /// \cond CLASSIMP
33 ClassImp(AliMUON1DMap)
34 /// \endcond
35
36 //_____________________________________________________________________________
37 AliMUON1DMap::AliMUON1DMap(Int_t theSize)
38 : AliMUONV1DStore(),
39   fMap(new AliMpExMap(true))
40 {
41 /// Default ctor
42
43   if ( theSize ) 
44   {
45     fMap->SetSize(theSize);
46   }
47     fMap->SetOwner(kTRUE);
48 }
49
50 //_____________________________________________________________________________
51 AliMUON1DMap::AliMUON1DMap(const AliMUON1DMap& other)
52 : AliMUONV1DStore(),
53   fMap(0x0)
54 {
55 /// Copy constructor
56
57   other.CopyTo(*this);
58 }
59
60 //_____________________________________________________________________________
61 AliMUON1DMap&
62 AliMUON1DMap::operator=(const AliMUON1DMap& other)
63 {
64 /// Assignment operator
65
66   other.CopyTo(*this);
67   return *this;
68 }
69
70 //_____________________________________________________________________________
71 AliMUON1DMap::~AliMUON1DMap()
72 {
73 /// dtor, we're the owner of our internal map.
74
75   delete fMap;
76 }
77
78 //_____________________________________________________________________________
79 void
80 AliMUON1DMap::CopyTo(AliMUON1DMap& dest) const
81 {
82 /// Make a deep copy
83
84   delete dest.fMap;
85   dest.fMap = fMap;
86 }
87
88 //_____________________________________________________________________________
89 TObject* 
90 AliMUON1DMap::Get(Int_t i) const
91 {
92 /// Get the object located at index i, if it exists, and if i is correct.
93
94   return fMap->GetValue(i);
95 }
96
97 //_____________________________________________________________________________
98 AliMUONVDataIterator*
99 AliMUON1DMap::Iterator() const
100 {
101   // Create and return an iterator on this map
102   // Returned iterator must be deleted by user.
103   if ( fMap ) 
104   {
105     return new AliMUON1DMapIterator(*fMap);
106   }
107   return 0x0;
108 }
109
110
111 //_____________________________________________________________________________
112 Bool_t 
113 AliMUON1DMap::Set(Int_t i, TObject* object, Bool_t replace)
114 {
115 /// Set the object located at i
116 /// If replace=kFALSE and there's already an object at location i,
117 /// this method fails and returns kFALSE, otherwise it returns kTRUE
118
119   TObject* o = Get(i);
120   if ( o && !replace )
121   {
122     AliError(Form("Object %p is already there for i=%d",o,i));
123     return kFALSE;
124   }
125   if ( replace ) 
126   {
127     delete o;
128   }
129   fMap->Add(i,object);
130   return kTRUE;
131 }
132
133
134