]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCDBManager.h
No default selection on the ESD tracks
[u/mrichter/AliRoot.git] / STEER / AliCDBManager.h
1 #ifndef ALI_CDB_MANAGER_H
2 #define ALI_CDB_MANAGER_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /////////////////////////////////////////////////////////////////////
8 //                                                                 //
9 //  class AliCDBManager                                            //
10 //                                                                 //
11 /////////////////////////////////////////////////////////////////////
12
13 #include <TObject.h>
14 #include <TList.h>
15 #include <TMap.h>
16
17 class AliCDBEntry;
18 class AliCDBId;
19 class AliCDBPath;
20 class AliCDBRunRange;
21 class AliCDBMetaData;
22 class AliCDBStorage;
23 class AliCDBStorageFactory;
24 class AliCDBParam;
25
26 class AliCDBManager: public TObject {
27
28  public:
29
30         void RegisterFactory(AliCDBStorageFactory* factory);
31
32         Bool_t HasStorage(const char* dbString) const;
33
34         AliCDBParam* CreateParameter(const char* dbString) const;
35
36         AliCDBStorage* GetStorage(const char* dbString);
37         AliCDBStorage* GetStorage(const AliCDBParam* param);
38         
39         TList* GetActiveStorages();
40
41         void SetDefaultStorage(const char* dbString);
42         void SetDefaultStorage(const AliCDBParam* param);
43         void SetDefaultStorage(AliCDBStorage *storage);
44         
45         Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
46         AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
47         void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
48         
49         void SetSpecificStorage(const char* detName, const char* dbString);
50         void SetSpecificStorage(const char* detName, AliCDBParam* param);
51
52         AliCDBStorage* GetSpecificStorage(const char* detName);
53
54         void SetDrain(const char* dbString);
55         void SetDrain(const AliCDBParam* param);
56         void SetDrain(AliCDBStorage *storage);
57
58         Bool_t IsDrainSet() const {return fDrainStorage != 0;}
59
60         Bool_t Drain(AliCDBEntry* entry);
61
62         void UnsetDrain(){fDrainStorage = 0x0;}
63
64         AliCDBEntry* Get(const AliCDBId& query);
65         AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber, 
66                                 Int_t version = -1, Int_t subVersion = -1);
67         AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
68                                  Int_t version = -1, Int_t subVersion = -1);
69
70         TList* GetAll(const AliCDBId& query);
71         TList* GetAll(const AliCDBPath& path, Int_t runNumber, 
72                                 Int_t version = -1, Int_t subVersion = -1);
73         TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
74                                  Int_t version = -1, Int_t subVersion = -1); 
75
76         Bool_t Put(TObject* object, AliCDBId& id,  AliCDBMetaData* metaData);
77         Bool_t Put(AliCDBEntry* entry);
78                 
79         void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
80         Bool_t GetCacheFlag() {return fCache;}
81
82         void SetRun(Long64_t run);
83         Long64_t GetRun() {return fRun;}
84
85         AliCDBEntry* Get(const char* path);
86
87         void DestroyActiveStorages();
88         void DestroyActiveStorage(AliCDBStorage* storage);
89         
90         static void Destroy();
91         ~AliCDBManager();
92
93         static AliCDBManager* Instance(); 
94
95  private:
96                 
97         AliCDBManager();
98         static AliCDBManager* fgInstance; // AliCDBManager instance
99         
100         AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
101         void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
102         
103         void ClearCache();
104         void CacheEntry(const char* path, AliCDBEntry* entry);
105         
106
107         void Init();
108         
109         TList fFactories;               //! list of registered storage factories
110         TMap fActiveStorages;           //! list of active storages
111         TMap fSpecificStorages;         //! list of detector-specific storages
112
113         AliCDBStorage *fDefaultStorage; //! pointer to default storage
114         AliCDBStorage *fDrainStorage;   //! pointer to drain storage
115
116         TMap fEntryCache;       //! cache of the retrieved objects
117
118         Bool_t fCache;                  //! The cache flag
119         Long64_t fRun;                  //! The run number
120
121         ClassDef(AliCDBManager, 0);
122 };
123
124
125 /////////////////////////////////////////////////////////////////////
126 //                                                                 //
127 //  class AliCDBStorageFactory                                     //
128 //                                                                 //
129 /////////////////////////////////////////////////////////////////////
130
131 class AliCDBParam;
132 class AliCDBStorageFactory: public TObject {
133         friend class AliCDBManager;
134         
135 public:
136         virtual Bool_t Validate(const char* dbString) = 0;
137         virtual AliCDBParam* CreateParameter(const char* dbString) = 0; 
138
139 protected:
140         virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
141
142         ClassDef(AliCDBStorageFactory, 0);
143 };
144
145 /////////////////////////////////////////////////////////////////////
146 //                                                                 //
147 //  class AliCDBParam                                              //
148 //                                                                 //
149 /////////////////////////////////////////////////////////////////////
150
151 class AliCDBParam: public TObject {
152
153 public:
154
155         AliCDBParam();
156         virtual ~AliCDBParam();
157
158         const TString& GetType() const {return fType;};
159         const TString& GetURI() const {return fURI;};
160
161         virtual AliCDBParam* CloneParam() const = 0;
162
163 protected:
164
165         void SetType(const char* type) {fType = type;};
166         void SetURI(const char* uri) {fURI = uri;};
167
168 private:
169
170         TString fType; // CDB type
171         TString fURI;  // CDB URI
172
173         ClassDef(AliCDBParam, 0);
174 };
175
176 #endif