]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUON2DMap.cxx
- Reordering includes from most specific to more general ones
[u/mrichter/AliRoot.git] / MUON / AliMUON2DMap.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 "AliMUON2DMap.h"
19
20 #include "AliLog.h"
21 #include "AliMpExMap.h"
22
23 #include <cassert>
24
25 ClassImp(AliMUON2DMap)
26
27 //_____________________________________________________________________________
28 AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true))
29 {
30   //
31   // ctor.
32   //
33 }
34
35 //______________________________________________________________________________
36 AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& right) 
37   : AliMUONV2DStore(right) 
38 {  
39 /// Protected copy constructor (not implemented)
40
41   AliFatal("Copy constructor not provided.");
42 }
43
44 //_____________________________________________________________________________
45 AliMUON2DMap::~AliMUON2DMap()
46 {
47   //
48   // dtor. we delete the map, which will delete the objects, as we're owner.
49   //
50   delete fMap;
51 }
52
53 //______________________________________________________________________________
54 AliMUON2DMap& 
55 AliMUON2DMap::operator=(const AliMUON2DMap& right)
56 {
57 /// Protected assignement operator (not implemented)
58
59   // check assignement to self
60   if (this == &right) return *this;
61
62   AliFatal("Assignement operator not provided.");
63     
64   return *this;  
65 }    
66
67 //_____________________________________________________________________________
68 TObject* 
69 AliMUON2DMap::Get(Int_t i, Int_t j) const
70 {
71   //
72   // Return the value at position (i,j).
73   //
74   TObject* o = fMap->GetValue(i);
75   if ( o )
76   {
77     AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
78     if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
79     return m->GetValue(j);
80   }
81   return 0x0;
82 }
83
84 //_____________________________________________________________________________
85 void
86 AliMUON2DMap::Print(Option_t*) const
87 {
88   //
89   // Not implemented (yet?)
90   //
91 }
92
93 //_____________________________________________________________________________
94 Bool_t 
95 AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace)
96 {
97   //
98   // Set the object at position (i,j).
99   // If replace==kTRUE, we don't care if there's an object there already,
100   // otherwise we might refuse to set if the (i,j) location is already
101   // filled (in which case we return kFALSE).
102   
103   TObject* o = fMap->GetValue(i);
104   if ( !o )
105   {
106     AliMpExMap* m = new AliMpExMap(true);
107     fMap->Add(i,m);
108     o = fMap->GetValue(i);
109     assert(m==o);
110   }
111   AliMpExMap* m = dynamic_cast<AliMpExMap*>(o);
112   if (!m) AliFatal(Form("fMap[%d] not of the expected type",i));
113   o = m->GetValue(j);
114   if ( !o || ( o && replace ) )
115   {
116     if ( IsOwner() ) 
117     {
118       delete o;
119     }
120     m->Add(j,object);
121   }
122   else if ( o && !replace )
123   {
124     AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j));
125     return kFALSE;
126   }
127   return kTRUE;
128 }
129
130
131
132
133