]>
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); | |
7de84b33 | 51 | void SetDefaultStorage(const char* runType, const char* simType); |
52 | void SetDefaultStorageFromRun(Int_t run); | |
4667c116 | 53 | |
02c4845e | 54 | Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;} |
fdf65bb5 | 55 | AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;} |
1f341624 | 56 | void UnsetDefaultStorage(); |
4667c116 | 57 | |
024cf675 | 58 | void SetSpecificStorage(const char* calibType, const char* dbString); |
59 | void SetSpecificStorage(const char* calibType, AliCDBParam* param); | |
02c4845e | 60 | |
024cf675 | 61 | AliCDBStorage* GetSpecificStorage(const char* calibType); |
9e1ceb13 | 62 | |
63 | void SetDrain(const char* dbString); | |
64 | void SetDrain(const AliCDBParam* param); | |
65 | void SetDrain(AliCDBStorage *storage); | |
66 | ||
fdf65bb5 | 67 | Bool_t IsDrainSet() const {return fDrainStorage != 0;} |
9e1ceb13 | 68 | |
69 | Bool_t Drain(AliCDBEntry* entry); | |
70 | ||
b05400be | 71 | void UnsetDrain(){fDrainStorage = 0x0;} |
9e1ceb13 | 72 | |
02c4845e | 73 | AliCDBEntry* Get(const AliCDBId& query); |
62032124 | 74 | AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 75 | Int_t version = -1, Int_t subVersion = -1); |
76 | AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
77 | Int_t version = -1, Int_t subVersion = -1); | |
78 | ||
0f40a831 | 79 | const char* GetURI(const char* path); |
80 | ||
4667c116 | 81 | AliCDBId* GetId(const AliCDBId& query); |
82 | AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1, | |
83 | Int_t version = -1, Int_t subVersion = -1); | |
84 | AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
85 | Int_t version = -1, Int_t subVersion = -1); | |
86 | ||
02c4845e | 87 | TList* GetAll(const AliCDBId& query); |
62032124 | 88 | TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 89 | Int_t version = -1, Int_t subVersion = -1); |
90 | TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange, | |
91 | Int_t version = -1, Int_t subVersion = -1); | |
92 | ||
b8ec52f6 | 93 | Bool_t Put(TObject* object, AliCDBId& id, |
94 | AliCDBMetaData* metaData, DataType type=kPrivate); | |
95 | Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate); | |
96 | ||
4b5e0dce | 97 | void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;} |
e1e6896f | 98 | Bool_t GetCacheFlag() const {return fCache;} |
1f341624 | 99 | |
100 | void SetLock(Bool_t lockFlag=kTRUE); | |
101 | Bool_t GetLock() const {return fLock;} | |
4b5e0dce | 102 | |
7de84b33 | 103 | void SetRaw(Bool_t rawFlag){fRaw=rawFlag;} |
104 | Bool_t GetRaw() const {return fRaw;} | |
105 | ||
c3a7b59a | 106 | void SetRun(Int_t run); |
107 | Int_t GetRun() const {return fRun;} | |
4b5e0dce | 108 | |
9e1ceb13 | 109 | void DestroyActiveStorages(); |
110 | void DestroyActiveStorage(AliCDBStorage* storage); | |
917a098b | 111 | |
62032124 | 112 | void QueryCDB(); |
113 | ||
917a098b | 114 | void Print(Option_t* option="") const; |
115 | ||
9e1ceb13 | 116 | static void Destroy(); |
117 | ~AliCDBManager(); | |
118 | ||
8e245d15 | 119 | void ClearCache(); |
4005d0b5 | 120 | void UnloadFromCache(const char* path); |
d1982b43 | 121 | const TMap* GetEntryCache() const {return &fEntryCache;} |
8e245d15 | 122 | |
4667c116 | 123 | Bool_t IsShortLived(const char* path); |
124 | ||
d1982b43 | 125 | static AliCDBManager* Instance(TMap *entryCache = NULL, Int_t run = -1); |
9e1ceb13 | 126 | |
b03591ab | 127 | void Init(); |
128 | void InitFromCache(TMap *entryCache, Int_t run); | |
129 | ||
130 | protected: | |
b8ec52f6 | 131 | |
132 | static TString fgkCondUri; // URI of the Conditions data base folder | |
133 | static TString fgkRefUri; // URI of the Reference data base folder | |
7de84b33 | 134 | static TString fgkMCIdealStorage; // URI of the MC-Ideal Conditions data base folder form MC data |
135 | static TString fgkMCFullStorage; // URI of the MC-Full Conditions data base folder form MC data | |
136 | static TString fgkMCResidualStorage; // URI of the MC-Residual Conditions data base folder form MC data | |
137 | static TString fgkOCDBFolderXMLfile; // alien path of the XML file for OCDB folder <--> Run range correspondance | |
b8ec52f6 | 138 | |
b03591ab | 139 | AliCDBManager() ; |
fe12e09c | 140 | AliCDBManager(const AliCDBManager & source); |
141 | AliCDBManager & operator=(const AliCDBManager & source); | |
142 | ||
fdf65bb5 | 143 | static AliCDBManager* fgInstance; // AliCDBManager instance |
9e1ceb13 | 144 | |
145 | AliCDBStorage* GetActiveStorage(const AliCDBParam* param); | |
146 | void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage); | |
917a098b | 147 | |
4b5e0dce | 148 | void CacheEntry(const char* path, AliCDBEntry* entry); |
8e245d15 | 149 | |
024cf675 | 150 | AliCDBParam* SelectSpecificStorage(const TString& path); |
151 | ||
9e1ceb13 | 152 | |
b03591ab | 153 | // void Init(); |
4667c116 | 154 | void InitShortLived(); |
b03591ab | 155 | // void InitFromCache(TMap *entryCache, Int_t run); |
4667c116 | 156 | |
157 | ||
b05400be | 158 | TList fFactories; //! list of registered storage factories |
159 | TMap fActiveStorages; //! list of active storages | |
02c4845e | 160 | TMap fSpecificStorages; //! list of detector-specific storages |
b21e3194 | 161 | TMap fEntryCache; //! cache of the retrieved objects |
162 | ||
163 | TList* fIds; //! List of the retrieved object Id's (to be streamed to file) | |
164 | TMap* fStorageMap; //! list of storages (to be streamed to file) | |
165 | TList* fShortLived; //! List of short lived objects | |
4b5e0dce | 166 | |
b05400be | 167 | AliCDBStorage *fDefaultStorage; //! pointer to default storage |
168 | AliCDBStorage *fDrainStorage; //! pointer to drain storage | |
9e1ceb13 | 169 | |
b21e3194 | 170 | AliCDBParam* fCondParam; // Conditions data storage parameters |
171 | AliCDBParam* fRefParam; // Reference data storage parameters | |
4b5e0dce | 172 | |
b21e3194 | 173 | Int_t fRun; //! The run number |
4b5e0dce | 174 | Bool_t fCache; //! The cache flag |
1f341624 | 175 | Bool_t fLock; //! Lock flag, if ON default storage and run number cannot be reset |
4b5e0dce | 176 | |
7de84b33 | 177 | Bool_t fRaw; // flag to say whether we are in the raw case |
178 | Int_t fStartRunLHCPeriod; // 1st run of the LHC period set | |
179 | Int_t fEndRunLHCPeriod; // last run of the LHC period set | |
180 | TString fLHCPeriod; // LHC period alien folder | |
181 | ||
4667c116 | 182 | |
9e1ceb13 | 183 | ClassDef(AliCDBManager, 0); |
184 | }; | |
185 | ||
186 | ||
187 | ///////////////////////////////////////////////////////////////////// | |
188 | // // | |
189 | // class AliCDBStorageFactory // | |
190 | // // | |
191 | ///////////////////////////////////////////////////////////////////// | |
192 | ||
193 | class AliCDBParam; | |
194 | class AliCDBStorageFactory: public TObject { | |
195 | friend class AliCDBManager; | |
196 | ||
197 | public: | |
e1e6896f | 198 | virtual ~AliCDBStorageFactory(){} |
9e1ceb13 | 199 | virtual Bool_t Validate(const char* dbString) = 0; |
b05400be | 200 | virtual AliCDBParam* CreateParameter(const char* dbString) = 0; |
9e1ceb13 | 201 | |
202 | protected: | |
203 | virtual AliCDBStorage* Create(const AliCDBParam* param) = 0; | |
204 | ||
205 | ClassDef(AliCDBStorageFactory, 0); | |
206 | }; | |
207 | ||
208 | ///////////////////////////////////////////////////////////////////// | |
209 | // // | |
210 | // class AliCDBParam // | |
211 | // // | |
212 | ///////////////////////////////////////////////////////////////////// | |
213 | ||
214 | class AliCDBParam: public TObject { | |
215 | ||
216 | public: | |
217 | ||
218 | AliCDBParam(); | |
219 | virtual ~AliCDBParam(); | |
220 | ||
221 | const TString& GetType() const {return fType;}; | |
222 | const TString& GetURI() const {return fURI;}; | |
223 | ||
224 | virtual AliCDBParam* CloneParam() const = 0; | |
225 | ||
226 | protected: | |
227 | ||
228 | void SetType(const char* type) {fType = type;}; | |
229 | void SetURI(const char* uri) {fURI = uri;}; | |
230 | ||
231 | private: | |
232 | ||
917a098b | 233 | TString fType; //! CDB type |
234 | TString fURI; //! CDB URI | |
9e1ceb13 | 235 | |
236 | ClassDef(AliCDBParam, 0); | |
237 | }; | |
238 | ||
239 | #endif |