]>
Commit | Line | Data |
---|---|---|
f6e5d0e9 | 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 | ||
5398f946 | 23 | /// \class AliMUON2DMap |
24 | /// \brief Basic implementation of AliMUONV2DStore container using | |
9d5f6a64 | 25 | /// AliMpExMap internally. |
26 | /// What we store is a "double" map : an AliMpExMap of AliMpExMaps | |
27 | /// | |
5398f946 | 28 | /// \author Laurent Aphecetche |
f6e5d0e9 | 29 | |
5398f946 | 30 | /// \cond CLASSIMP |
f6e5d0e9 | 31 | ClassImp(AliMUON2DMap) |
5398f946 | 32 | /// \endcond |
f6e5d0e9 | 33 | |
34 | //_____________________________________________________________________________ | |
35 | AliMUON2DMap::AliMUON2DMap() : AliMUONV2DStore(), fMap(new AliMpExMap(true)) | |
36 | { | |
5398f946 | 37 | /// Default constructor. |
f6e5d0e9 | 38 | } |
39 | ||
9d5f6a64 | 40 | //_____________________________________________________________________________ |
41 | AliMUON2DMap::AliMUON2DMap(const AliMUON2DMap& other) | |
42 | : AliMUONV2DStore(), | |
43 | fMap(0x0) | |
44 | { | |
5398f946 | 45 | /// Copy constructor. |
46 | ||
47 | other.CopyTo(*this); | |
9d5f6a64 | 48 | } |
884a73f1 | 49 | |
9d5f6a64 | 50 | //_____________________________________________________________________________ |
51 | AliMUON2DMap& | |
52 | AliMUON2DMap::operator=(const AliMUON2DMap& other) | |
53 | { | |
5398f946 | 54 | /// Assignment operator |
55 | ||
9d5f6a64 | 56 | other.CopyTo(*this); |
57 | return *this; | |
884a73f1 | 58 | } |
59 | ||
f6e5d0e9 | 60 | //_____________________________________________________________________________ |
61 | AliMUON2DMap::~AliMUON2DMap() | |
62 | { | |
5398f946 | 63 | /// Destructor. |
64 | /// We delete the map, which will delete the objects, as we're owner. | |
65 | ||
f6e5d0e9 | 66 | delete fMap; |
67 | } | |
68 | ||
9d5f6a64 | 69 | //_____________________________________________________________________________ |
70 | void | |
71 | AliMUON2DMap::CopyTo(AliMUON2DMap&) const | |
884a73f1 | 72 | { |
5398f946 | 73 | /// Copy this into dest. |
74 | ||
9d5f6a64 | 75 | AliFatal("Implement me if needed"); |
76 | } | |
884a73f1 | 77 | |
f6e5d0e9 | 78 | //_____________________________________________________________________________ |
79 | TObject* | |
80 | AliMUON2DMap::Get(Int_t i, Int_t j) const | |
81 | { | |
5398f946 | 82 | /// Return the value at position (i,j). |
83 | ||
f6e5d0e9 | 84 | TObject* o = fMap->GetValue(i); |
85 | if ( o ) | |
86 | { | |
87 | AliMpExMap* m = dynamic_cast<AliMpExMap*>(o); | |
88 | if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); | |
89 | return m->GetValue(j); | |
90 | } | |
91 | return 0x0; | |
92 | } | |
93 | ||
f6e5d0e9 | 94 | //_____________________________________________________________________________ |
95 | void | |
96 | AliMUON2DMap::Print(Option_t*) const | |
97 | { | |
5398f946 | 98 | /// Not implemented (yet?) |
f6e5d0e9 | 99 | } |
100 | ||
101 | //_____________________________________________________________________________ | |
102 | Bool_t | |
103 | AliMUON2DMap::Set(Int_t i, Int_t j, TObject* object, Bool_t replace) | |
104 | { | |
5398f946 | 105 | /// Set the object at position (i,j). |
106 | /// If replace==kTRUE, we don't care if there's an object there already, | |
107 | /// otherwise we might refuse to set if the (i,j) location is already | |
108 | /// filled (in which case we return kFALSE). | |
e5cc543e | 109 | |
f6e5d0e9 | 110 | TObject* o = fMap->GetValue(i); |
111 | if ( !o ) | |
112 | { | |
113 | AliMpExMap* m = new AliMpExMap(true); | |
114 | fMap->Add(i,m); | |
115 | o = fMap->GetValue(i); | |
f6e5d0e9 | 116 | } |
117 | AliMpExMap* m = dynamic_cast<AliMpExMap*>(o); | |
118 | if (!m) AliFatal(Form("fMap[%d] not of the expected type",i)); | |
119 | o = m->GetValue(j); | |
120 | if ( !o || ( o && replace ) ) | |
121 | { | |
122 | if ( IsOwner() ) | |
123 | { | |
124 | delete o; | |
125 | } | |
126 | m->Add(j,object); | |
127 | } | |
128 | else if ( o && !replace ) | |
129 | { | |
130 | AliError(Form("Object %p is already there for (i,j)=(%d,%d)",o,i,j)); | |
131 | return kFALSE; | |
132 | } | |
133 | return kTRUE; | |
134 | } | |
135 | ||
136 | ||
137 | ||
138 | ||
139 |