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