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