]>
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 | ||
45 | void SetDefaultStorage(const char* dbString); | |
46 | void SetDefaultStorage(const AliCDBParam* param); | |
47 | void SetDefaultStorage(AliCDBStorage *storage); | |
4667c116 | 48 | |
02c4845e | 49 | Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;} |
fdf65bb5 | 50 | AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;} |
b05400be | 51 | void UnsetDefaultStorage() {fDefaultStorage = 0x0;} |
b8ec52f6 | 52 | |
4667c116 | 53 | void SetRemoteStorage(const char* dbString); |
54 | void SetRemoteStorage(const AliCDBParam* param); | |
55 | void SetRemoteStorage(AliCDBStorage *storage); | |
56 | ||
57 | Bool_t IsRemoteStorageSet() const {return fRemoteStorage != 0;} | |
58 | AliCDBStorage* GetRemoteStorage() const {return fRemoteStorage;} | |
59 | void UnsetRemoteStorage() {fRemoteStorage = 0x0;} | |
60 | ||
024cf675 | 61 | void SetSpecificStorage(const char* calibType, const char* dbString); |
62 | void SetSpecificStorage(const char* calibType, AliCDBParam* param); | |
02c4845e | 63 | |
024cf675 | 64 | AliCDBStorage* GetSpecificStorage(const char* calibType); |
9e1ceb13 | 65 | |
66 | void SetDrain(const char* dbString); | |
67 | void SetDrain(const AliCDBParam* param); | |
68 | void SetDrain(AliCDBStorage *storage); | |
69 | ||
fdf65bb5 | 70 | Bool_t IsDrainSet() const {return fDrainStorage != 0;} |
9e1ceb13 | 71 | |
72 | Bool_t Drain(AliCDBEntry* entry); | |
73 | ||
b05400be | 74 | void UnsetDrain(){fDrainStorage = 0x0;} |
9e1ceb13 | 75 | |
02c4845e | 76 | AliCDBEntry* Get(const AliCDBId& query); |
62032124 | 77 | AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 78 | Int_t version = -1, Int_t subVersion = -1); |
79 | AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
80 | Int_t version = -1, Int_t subVersion = -1); | |
81 | ||
4667c116 | 82 | AliCDBId* GetId(const AliCDBId& query); |
83 | AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1, | |
84 | Int_t version = -1, Int_t subVersion = -1); | |
85 | AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
86 | Int_t version = -1, Int_t subVersion = -1); | |
87 | ||
02c4845e | 88 | TList* GetAll(const AliCDBId& query); |
62032124 | 89 | TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 90 | Int_t version = -1, Int_t subVersion = -1); |
91 | TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
92 | Int_t version = -1, Int_t subVersion = -1); | |
93 | ||
b8ec52f6 | 94 | Bool_t Put(TObject* object, AliCDBId& id, |
95 | AliCDBMetaData* metaData, DataType type=kPrivate); | |
96 | Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate); | |
97 | ||
4b5e0dce | 98 | void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;} |
e1e6896f | 99 | Bool_t GetCacheFlag() const {return fCache;} |
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); |
8e245d15 | 116 | |
4667c116 | 117 | Bool_t IsShortLived(const char* path); |
118 | ||
4005d0b5 | 119 | static AliCDBManager* Instance(); |
9e1ceb13 | 120 | |
121 | private: | |
b8ec52f6 | 122 | |
123 | static TString fgkCondUri; // URI of the Conditions data base folder | |
124 | static TString fgkRefUri; // URI of the Reference data base folder | |
125 | AliCDBParam* fCondParam; // Conditions data storage parameters | |
126 | AliCDBParam* fRefParam; // Reference data storage parameters | |
127 | ||
9e1ceb13 | 128 | AliCDBManager(); |
fe12e09c | 129 | AliCDBManager(const AliCDBManager & source); |
130 | AliCDBManager & operator=(const AliCDBManager & source); | |
131 | ||
fdf65bb5 | 132 | static AliCDBManager* fgInstance; // AliCDBManager instance |
9e1ceb13 | 133 | |
134 | AliCDBStorage* GetActiveStorage(const AliCDBParam* param); | |
135 | void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage); | |
917a098b | 136 | |
4b5e0dce | 137 | void CacheEntry(const char* path, AliCDBEntry* entry); |
8e245d15 | 138 | |
024cf675 | 139 | AliCDBParam* SelectSpecificStorage(const TString& path); |
140 | ||
9e1ceb13 | 141 | |
142 | void Init(); | |
4667c116 | 143 | void InitShortLived(); |
144 | ||
145 | ||
b05400be | 146 | TList fFactories; //! list of registered storage factories |
147 | TMap fActiveStorages; //! list of active storages | |
02c4845e | 148 | TMap fSpecificStorages; //! list of detector-specific storages |
4b5e0dce | 149 | |
b05400be | 150 | AliCDBStorage *fDefaultStorage; //! pointer to default storage |
4667c116 | 151 | AliCDBStorage *fRemoteStorage; //! pointer to remote storage |
b05400be | 152 | AliCDBStorage *fDrainStorage; //! pointer to drain storage |
9e1ceb13 | 153 | |
4b5e0dce | 154 | TMap fEntryCache; //! cache of the retrieved objects |
155 | ||
156 | Bool_t fCache; //! The cache flag | |
c3a7b59a | 157 | Int_t fRun; //! The run number |
4b5e0dce | 158 | |
4667c116 | 159 | TList* fShortLived; //! List of short lived objects |
160 | ||
9e1ceb13 | 161 | ClassDef(AliCDBManager, 0); |
162 | }; | |
163 | ||
164 | ||
165 | ///////////////////////////////////////////////////////////////////// | |
166 | // // | |
167 | // class AliCDBStorageFactory // | |
168 | // // | |
169 | ///////////////////////////////////////////////////////////////////// | |
170 | ||
171 | class AliCDBParam; | |
172 | class AliCDBStorageFactory: public TObject { | |
173 | friend class AliCDBManager; | |
174 | ||
175 | public: | |
e1e6896f | 176 | virtual ~AliCDBStorageFactory(){} |
9e1ceb13 | 177 | virtual Bool_t Validate(const char* dbString) = 0; |
b05400be | 178 | virtual AliCDBParam* CreateParameter(const char* dbString) = 0; |
9e1ceb13 | 179 | |
180 | protected: | |
181 | virtual AliCDBStorage* Create(const AliCDBParam* param) = 0; | |
182 | ||
183 | ClassDef(AliCDBStorageFactory, 0); | |
184 | }; | |
185 | ||
186 | ///////////////////////////////////////////////////////////////////// | |
187 | // // | |
188 | // class AliCDBParam // | |
189 | // // | |
190 | ///////////////////////////////////////////////////////////////////// | |
191 | ||
192 | class AliCDBParam: public TObject { | |
193 | ||
194 | public: | |
195 | ||
196 | AliCDBParam(); | |
197 | virtual ~AliCDBParam(); | |
198 | ||
199 | const TString& GetType() const {return fType;}; | |
200 | const TString& GetURI() const {return fURI;}; | |
201 | ||
202 | virtual AliCDBParam* CloneParam() const = 0; | |
203 | ||
204 | protected: | |
205 | ||
206 | void SetType(const char* type) {fType = type;}; | |
207 | void SetURI(const char* uri) {fURI = uri;}; | |
208 | ||
209 | private: | |
210 | ||
917a098b | 211 | TString fType; //! CDB type |
212 | TString fURI; //! CDB URI | |
9e1ceb13 | 213 | |
214 | ClassDef(AliCDBParam, 0); | |
215 | }; | |
216 | ||
217 | #endif |