]>
Commit | Line | Data |
---|---|---|
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 | 17 | class AliCDBEntry; |
02c4845e | 18 | class AliCDBId; |
19 | class AliCDBPath; | |
20 | class AliCDBRunRange; | |
21 | class AliCDBMetaData; | |
9e1ceb13 | 22 | class AliCDBStorage; |
23 | class AliCDBStorageFactory; | |
24 | class AliCDBParam; | |
25 | ||
26 | class 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;} |
b05400be | 54 | void UnsetDefaultStorage() {fDefaultStorage = 0x0;} |
b8ec52f6 | 55 | |
4667c116 | 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 | ||
024cf675 | 64 | void SetSpecificStorage(const char* calibType, const char* dbString); |
65 | void SetSpecificStorage(const char* calibType, AliCDBParam* param); | |
02c4845e | 66 | |
024cf675 | 67 | AliCDBStorage* GetSpecificStorage(const char* calibType); |
9e1ceb13 | 68 | |
69 | void SetDrain(const char* dbString); | |
70 | void SetDrain(const AliCDBParam* param); | |
71 | void SetDrain(AliCDBStorage *storage); | |
72 | ||
fdf65bb5 | 73 | Bool_t IsDrainSet() const {return fDrainStorage != 0;} |
9e1ceb13 | 74 | |
75 | Bool_t Drain(AliCDBEntry* entry); | |
76 | ||
b05400be | 77 | void UnsetDrain(){fDrainStorage = 0x0;} |
9e1ceb13 | 78 | |
02c4845e | 79 | AliCDBEntry* Get(const AliCDBId& query); |
62032124 | 80 | AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 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 | ||
4667c116 | 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 | ||
02c4845e | 91 | TList* GetAll(const AliCDBId& query); |
62032124 | 92 | TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 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 | ||
b8ec52f6 | 97 | Bool_t Put(TObject* object, AliCDBId& id, |
98 | AliCDBMetaData* metaData, DataType type=kPrivate); | |
99 | Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate); | |
100 | ||
4b5e0dce | 101 | void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;} |
e1e6896f | 102 | Bool_t GetCacheFlag() const {return fCache;} |
4b5e0dce | 103 | |
c3a7b59a | 104 | void SetRun(Int_t run); |
105 | Int_t GetRun() const {return fRun;} | |
4b5e0dce | 106 | |
9e1ceb13 | 107 | void DestroyActiveStorages(); |
108 | void DestroyActiveStorage(AliCDBStorage* storage); | |
917a098b | 109 | |
62032124 | 110 | void QueryCDB(); |
111 | ||
917a098b | 112 | void Print(Option_t* option="") const; |
113 | ||
9e1ceb13 | 114 | static void Destroy(); |
115 | ~AliCDBManager(); | |
116 | ||
8e245d15 | 117 | void ClearCache(); |
4005d0b5 | 118 | void UnloadFromCache(const char* path); |
8e245d15 | 119 | |
4667c116 | 120 | Bool_t IsShortLived(const char* path); |
121 | ||
4005d0b5 | 122 | static AliCDBManager* Instance(); |
9e1ceb13 | 123 | |
124 | private: | |
b8ec52f6 | 125 | |
126 | static TString fgkCondUri; // URI of the Conditions data base folder | |
127 | static TString fgkRefUri; // URI of the Reference data base folder | |
b8ec52f6 | 128 | |
9e1ceb13 | 129 | AliCDBManager(); |
fe12e09c | 130 | AliCDBManager(const AliCDBManager & source); |
131 | AliCDBManager & operator=(const AliCDBManager & source); | |
132 | ||
fdf65bb5 | 133 | static AliCDBManager* fgInstance; // AliCDBManager instance |
9e1ceb13 | 134 | |
135 | AliCDBStorage* GetActiveStorage(const AliCDBParam* param); | |
136 | void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage); | |
917a098b | 137 | |
4b5e0dce | 138 | void CacheEntry(const char* path, AliCDBEntry* entry); |
8e245d15 | 139 | |
024cf675 | 140 | AliCDBParam* SelectSpecificStorage(const TString& path); |
141 | ||
9e1ceb13 | 142 | |
143 | void Init(); | |
4667c116 | 144 | void InitShortLived(); |
145 | ||
146 | ||
b05400be | 147 | TList fFactories; //! list of registered storage factories |
148 | TMap fActiveStorages; //! list of active storages | |
02c4845e | 149 | TMap fSpecificStorages; //! list of detector-specific storages |
b21e3194 | 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 | |
4b5e0dce | 155 | |
b05400be | 156 | AliCDBStorage *fDefaultStorage; //! pointer to default storage |
4667c116 | 157 | AliCDBStorage *fRemoteStorage; //! pointer to remote storage |
b05400be | 158 | AliCDBStorage *fDrainStorage; //! pointer to drain storage |
9e1ceb13 | 159 | |
b21e3194 | 160 | AliCDBParam* fCondParam; // Conditions data storage parameters |
161 | AliCDBParam* fRefParam; // Reference data storage parameters | |
4b5e0dce | 162 | |
b21e3194 | 163 | Int_t fRun; //! The run number |
4b5e0dce | 164 | Bool_t fCache; //! The cache flag |
4b5e0dce | 165 | |
4667c116 | 166 | |
9e1ceb13 | 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: | |
e1e6896f | 182 | virtual ~AliCDBStorageFactory(){} |
9e1ceb13 | 183 | virtual Bool_t Validate(const char* dbString) = 0; |
b05400be | 184 | virtual AliCDBParam* CreateParameter(const char* dbString) = 0; |
9e1ceb13 | 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 | ||
917a098b | 217 | TString fType; //! CDB type |
218 | TString fURI; //! CDB URI | |
9e1ceb13 | 219 | |
220 | ClassDef(AliCDBParam, 0); | |
221 | }; | |
222 | ||
223 | #endif |