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