]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpExMap.h
First big commit of the mchview program and its accompanying library,
[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
26 class TString;
27
28 class AliMpExMap : public TObject
29 {
30   public:
31     AliMpExMap();
32     AliMpExMap(Bool_t standardConstructor);
33     AliMpExMap(const AliMpExMap& rhs);
34     AliMpExMap& operator=(const AliMpExMap& rhs);
35     virtual ~AliMpExMap();
36     
37     // static methods
38     // conversion between varius keys and Long_t
39     //
40     static Long_t  GetIndex(const AliMpIntPair& pair);
41     static Long_t  GetIndex(const TString& s);
42     static AliMpIntPair  GetPair(Long_t index);
43     static TString       GetString(Long_t index);
44
45     // set methods
46     void Add(const AliMpIntPair& key, TObject* object);
47     void Add(const TString& key, TObject* object);
48     void Add(Int_t key, TObject* object);
49
50     void SetSize(Int_t size);
51     void SetOwner(Bool_t owner);
52     
53     // get methods
54     Int_t       GetSize() const;
55     TExMapIter  GetIterator() const;
56     TObject*    GetObject(Int_t index) const;
57     TObject*    GetObjectFast(Int_t index) const;
58
59     TObject*    GetValue(const AliMpIntPair& key) const;
60     TObject*    GetValue(const TString& key) const;
61     TObject*    GetValue(Int_t key) const;
62
63     void Copy(TObject& dest) const;
64     
65   private:  
66     // methods
67     void FillMap();
68     void AddKey(Long_t key);
69     
70     // static data members
71     static const Int_t    fgkDefaultSize;      ///< Default initial size
72     static const Bool_t   fgkDefaultOwnership; ///< Default ownership
73
74     static const Int_t    fgkSeparator1; ///< \brief the separator used for conversion
75                                          ///  of AliMpIntPair to Int_t
76     static const Int_t    fgkSeparator2; ///< \brief the separator used for conversion
77                                          ///  of TString to Int_t
78     static const TString  fgkCharacterMap; ///< \brief the string mapping characters 
79                                            ///  to integers 
80     
81     // data members
82     mutable TExMap  fMap;     //!<  Transient map class
83     TObjArray       fObjects; ///<  Array of objects 
84     TArrayL         fKeys;    ///<  Array of keys 
85
86   ClassDef(AliMpExMap,1)  // Root persistent TExMap
87 };
88
89 #endif //ALI_MP_EX_MAP_H
90