]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpExMap.h
Finally correcting the second (known and long overdue) bug in slat mapping
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpExMap.h
1 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2  * See cxx source for full Copyright notice                               */
3
4 // $Id$
5 // $MpId: AliMpExMap.h,v 1.4 2006/05/24 13:58:07 ivana Exp $
6
7 /// \ingroup core
8 /// \class AliMpExMap
9 /// \brief Helper class making Root persistent TExMap
10 ///
11 /// The objects and keys from TExMap are store in additional
12 /// arrays which are Root persistent.
13 ///
14 /// \author Ivana Hrivnacova; IPN Orsay
15
16 #ifndef ALI_MP_EX_MAP_H
17 #define ALI_MP_EX_MAP_H
18
19 #include <TObject.h>
20 #include <TObjArray.h>
21 #include <TArrayL.h>
22 #include <TExMap.h>
23
24 class AliMpIntPair;
25 class AliMpExMapIterator;
26
27 class TString;
28
29 class AliMpExMap : public TObject
30 {
31   friend class AliMpExMapIterator;
32   
33   public:
34     AliMpExMap();
35     AliMpExMap(TRootIOCtor* /*ioCtor*/);
36     AliMpExMap(const AliMpExMap& rhs);
37     AliMpExMap& operator=(const AliMpExMap& rhs);
38     virtual ~AliMpExMap();
39     
40     
41     // static methods
42     // conversion between varius keys and Long_t
43     //
44     static Long_t  GetIndex(const AliMpIntPair& pair);
45     static Long_t  GetIndex(const TString& s);
46
47     static AliMpIntPair  GetPair(Long_t index);
48     static TString       GetString(Long_t index);
49
50     // methods from base class
51     virtual void Clear(Option_t* opt="");
52     virtual void Print(Option_t* opt="") const;
53
54     // set methods
55     void Add(const AliMpIntPair& key, TObject* object);
56     void Add(const TString& key, TObject* object);
57     void Add(Int_t key, TObject* object);
58
59     void SetSize(Int_t size);
60     void SetOwner(Bool_t owner);
61     
62     // get methods
63     Int_t GetSize() const;
64     Int_t GetCapacity() const;
65     
66     TObject*    GetValue(const AliMpIntPair& key) const;
67     TObject*    GetValue(const TString& key) const;
68     TObject*    GetValue(Int_t key) const;
69
70     AliMpExMapIterator* CreateIterator() const;
71     
72   private:  
73     // methods
74     void FillMap();
75     void AddKey(Long_t key);
76     void Copy(TObject& dest) const;
77     
78     // static data members
79     static const Int_t    fgkDefaultSize;      ///< Default initial size
80     static const Bool_t   fgkDefaultOwnership; ///< Default ownership
81
82     static const Int_t    fgkSeparator1; ///< \brief the separator used for conversion
83                                          ///  of AliMpIntPair to Int_t
84     static const Int_t    fgkSeparator2; ///< \brief the separator used for conversion
85                                          ///  of TString to Int_t
86     static const TString  fgkCharacterMap; ///< \brief the string mapping characters 
87                                            ///  to integers 
88     
89     // data members
90     mutable TExMap  fMap;     //!<  Transient map class
91     TObjArray       fObjects; ///<  Array of objects 
92     TArrayL         fKeys;    ///<  Array of keys 
93
94   ClassDef(AliMpExMap,1)  // Root persistent TExMap
95 };
96
97 #endif //ALI_MP_EX_MAP_H
98