]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCDBManager.h
No HLT specific for HMPID (not needed)
[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         enum DataType {kCondition=0, kReference, kPrivate};
30
31         void RegisterFactory(AliCDBStorageFactory* factory);
32
33         Bool_t HasStorage(const char* dbString) const;
34
35         AliCDBParam* CreateParameter(const char* dbString) const;
36         AliCDBParam* GetCondParam() const {return fCondParam;}
37         AliCDBParam* GetRefParam() const {return fRefParam;}
38         static const char* GetDataTypeName(DataType type);
39
40         AliCDBStorage* GetStorage(const char* dbString);
41         AliCDBStorage* GetStorage(const AliCDBParam* param);
42
43         TList* GetActiveStorages();
44
45         const TMap* GetStorageMap() const {return fStorageMap;}
46         const TList* GetRetrievedIds() const {return fIds;}
47
48         void SetDefaultStorage(const char* dbString);
49         void SetDefaultStorage(const AliCDBParam* param);
50         void SetDefaultStorage(AliCDBStorage *storage);
51
52         Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
53         AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
54         void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
55
56         void SetRemoteStorage(const char* dbString);
57         void SetRemoteStorage(const AliCDBParam* param);
58         void SetRemoteStorage(AliCDBStorage *storage);
59
60         Bool_t IsRemoteStorageSet() const {return fRemoteStorage != 0;}
61         AliCDBStorage* GetRemoteStorage() const {return fRemoteStorage;}
62         void UnsetRemoteStorage() {fRemoteStorage = 0x0;}
63
64         void SetSpecificStorage(const char* calibType, const char* dbString);
65         void SetSpecificStorage(const char* calibType, AliCDBParam* param);
66
67         AliCDBStorage* GetSpecificStorage(const char* calibType);
68
69         void SetDrain(const char* dbString);
70         void SetDrain(const AliCDBParam* param);
71         void SetDrain(AliCDBStorage *storage);
72
73         Bool_t IsDrainSet() const {return fDrainStorage != 0;}
74
75         Bool_t Drain(AliCDBEntry* entry);
76
77         void UnsetDrain(){fDrainStorage = 0x0;}
78
79         AliCDBEntry* Get(const AliCDBId& query);
80         AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
81                                 Int_t version = -1, Int_t subVersion = -1);
82         AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
83                                  Int_t version = -1, Int_t subVersion = -1);
84
85         AliCDBId* GetId(const AliCDBId& query);
86         AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1,
87                                 Int_t version = -1, Int_t subVersion = -1);
88         AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange,
89                                  Int_t version = -1, Int_t subVersion = -1);
90
91         TList* GetAll(const AliCDBId& query);
92         TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
93                                 Int_t version = -1, Int_t subVersion = -1);
94         TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
95                                  Int_t version = -1, Int_t subVersion = -1); 
96
97         Bool_t Put(TObject* object, AliCDBId& id,
98                         AliCDBMetaData* metaData, DataType type=kPrivate);
99         Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
100
101         void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
102         Bool_t GetCacheFlag() const {return fCache;}
103
104         void SetRun(Int_t run);
105         Int_t GetRun() const {return fRun;}
106
107         void DestroyActiveStorages();
108         void DestroyActiveStorage(AliCDBStorage* storage);
109
110         void QueryCDB();
111
112         void Print(Option_t* option="") const;
113
114         static void Destroy();
115         ~AliCDBManager();
116
117         void ClearCache();
118         void UnloadFromCache(const char* path);
119
120         Bool_t IsShortLived(const char* path);
121
122         static AliCDBManager* Instance();
123
124  private:
125
126         static TString fgkCondUri;      // URI of the Conditions data base folder
127         static TString fgkRefUri;       // URI of the Reference data base folder
128
129         AliCDBManager();
130         AliCDBManager(const AliCDBManager & source);
131         AliCDBManager & operator=(const AliCDBManager & source);
132
133         static AliCDBManager* fgInstance; // AliCDBManager instance
134         
135         AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
136         void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
137
138         void CacheEntry(const char* path, AliCDBEntry* entry);
139
140         AliCDBParam* SelectSpecificStorage(const TString& path);
141         
142
143         void Init();
144         void InitShortLived();
145
146
147         TList fFactories;               //! list of registered storage factories
148         TMap fActiveStorages;           //! list of active storages
149         TMap fSpecificStorages;         //! list of detector-specific storages
150         TMap fEntryCache;               //! cache of the retrieved objects
151
152         TList* fIds;            //! List of the retrieved object Id's (to be streamed to file)
153         TMap* fStorageMap;      //! list of storages (to be streamed to file)
154         TList* fShortLived;     //! List of short lived objects
155
156         AliCDBStorage *fDefaultStorage; //! pointer to default storage
157         AliCDBStorage *fRemoteStorage;  //! pointer to remote storage
158         AliCDBStorage *fDrainStorage;   //! pointer to drain storage
159
160         AliCDBParam* fCondParam;        // Conditions data storage parameters
161         AliCDBParam* fRefParam;         // Reference data storage parameters
162
163         Int_t fRun;                     //! The run number
164         Bool_t fCache;                  //! The cache flag
165
166
167         ClassDef(AliCDBManager, 0);
168 };
169
170
171 /////////////////////////////////////////////////////////////////////
172 //                                                                 //
173 //  class AliCDBStorageFactory                                     //
174 //                                                                 //
175 /////////////////////////////////////////////////////////////////////
176
177 class AliCDBParam;
178 class AliCDBStorageFactory: public TObject {
179         friend class AliCDBManager;
180         
181 public:
182         virtual ~AliCDBStorageFactory(){}
183         virtual Bool_t Validate(const char* dbString) = 0;
184         virtual AliCDBParam* CreateParameter(const char* dbString) = 0; 
185
186 protected:
187         virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
188
189         ClassDef(AliCDBStorageFactory, 0);
190 };
191
192 /////////////////////////////////////////////////////////////////////
193 //                                                                 //
194 //  class AliCDBParam                                              //
195 //                                                                 //
196 /////////////////////////////////////////////////////////////////////
197
198 class AliCDBParam: public TObject {
199
200 public:
201
202         AliCDBParam();
203         virtual ~AliCDBParam();
204
205         const TString& GetType() const {return fType;};
206         const TString& GetURI() const {return fURI;};
207
208         virtual AliCDBParam* CloneParam() const = 0;
209
210 protected:
211
212         void SetType(const char* type) {fType = type;};
213         void SetURI(const char* uri) {fURI = uri;};
214
215 private:
216
217         TString fType; //! CDB type
218         TString fURI;  //! CDB URI
219
220         ClassDef(AliCDBParam, 0);
221 };
222
223 #endif