1 #ifndef ALI_CDB_MANAGER_H
2 #define ALI_CDB_MANAGER_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
7 /////////////////////////////////////////////////////////////////////
9 // class AliCDBManager //
11 /////////////////////////////////////////////////////////////////////
23 class AliCDBStorageFactory;
26 class AliCDBManager: public TObject {
29 enum DataType {kCondition=0, kReference, kPrivate};
31 void RegisterFactory(AliCDBStorageFactory* factory);
33 Bool_t HasStorage(const char* dbString) const;
35 AliCDBParam* CreateParameter(const char* dbString) const;
36 AliCDBParam* GetCondParam() const {return fCondParam;}
37 AliCDBParam* GetRefParam() const {return fRefParam;}
38 static const char* GetDataTypeName(DataType type);
40 AliCDBStorage* GetStorage(const char* dbString);
41 AliCDBStorage* GetStorage(const AliCDBParam* param);
43 TList* GetActiveStorages();
45 const TMap* GetStorageMap() const {return fStorageMap;}
46 const TList* GetRetrievedIds() const {return fIds;}
48 void SetDefaultStorage(const char* dbString);
49 void SetDefaultStorage(const AliCDBParam* param);
50 void SetDefaultStorage(AliCDBStorage *storage);
51 void SetDefaultStorage(const char* runType, const char* simType);
52 void SetDefaultStorageFromRun(Int_t run);
54 Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
55 AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
56 void UnsetDefaultStorage();
58 void SetSpecificStorage(const char* calibType, const char* dbString);
59 void SetSpecificStorage(const char* calibType, AliCDBParam* param);
61 AliCDBStorage* GetSpecificStorage(const char* calibType);
63 void SetDrain(const char* dbString);
64 void SetDrain(const AliCDBParam* param);
65 void SetDrain(AliCDBStorage *storage);
67 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
69 Bool_t Drain(AliCDBEntry* entry);
71 void UnsetDrain(){fDrainStorage = 0x0;}
73 AliCDBEntry* Get(const AliCDBId& query);
74 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
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);
79 const char* GetURI(const char* path);
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);
87 TList* GetAll(const AliCDBId& query);
88 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
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);
93 Bool_t Put(TObject* object, AliCDBId& id,
94 AliCDBMetaData* metaData, DataType type=kPrivate);
95 Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
97 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
98 Bool_t GetCacheFlag() const {return fCache;}
100 ULong_t SetLock(Bool_t lockFlag=kTRUE, ULong_t key=0);
101 Bool_t GetLock() const {return fLock;}
103 void SetRaw(Bool_t rawFlag){fRaw=rawFlag;}
104 Bool_t GetRaw() const {return fRaw;}
106 void SetRun(Int_t run);
107 Int_t GetRun() const {return fRun;}
109 void DestroyActiveStorages();
110 void DestroyActiveStorage(AliCDBStorage* storage);
114 void Print(Option_t* option="") const;
116 static void Destroy();
120 void UnloadFromCache(const char* path);
121 const TMap* GetEntryCache() const {return &fEntryCache;}
123 Bool_t IsShortLived(const char* path);
125 static AliCDBManager* Instance(TMap *entryCache = NULL, Int_t run = -1);
128 void InitFromCache(TMap *entryCache, Int_t run);
132 static TString fgkCondUri; // URI of the Conditions data base folder
133 static TString fgkRefUri; // URI of the Reference data base folder
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
140 AliCDBManager(const AliCDBManager & source);
141 AliCDBManager & operator=(const AliCDBManager & source);
143 static AliCDBManager* fgInstance; // AliCDBManager instance
145 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
146 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
148 void CacheEntry(const char* path, AliCDBEntry* entry);
150 AliCDBParam* SelectSpecificStorage(const TString& path);
154 void InitShortLived();
155 // void InitFromCache(TMap *entryCache, Int_t run);
158 TList fFactories; //! list of registered storage factories
159 TMap fActiveStorages; //! list of active storages
160 TMap fSpecificStorages; //! list of detector-specific storages
161 TMap fEntryCache; //! cache of the retrieved objects
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
167 AliCDBStorage *fDefaultStorage; //! pointer to default storage
168 AliCDBStorage *fDrainStorage; //! pointer to drain storage
170 AliCDBParam* fCondParam; // Conditions data storage parameters
171 AliCDBParam* fRefParam; // Reference data storage parameters
173 Int_t fRun; //! The run number
174 Bool_t fCache; //! The cache flag
175 Bool_t fLock; //! Lock flag, if ON default storage and run number cannot be reset
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
183 ULong_t fKey; //! Key for locking/unlocking
186 ClassDef(AliCDBManager, 0);
190 /////////////////////////////////////////////////////////////////////
192 // class AliCDBStorageFactory //
194 /////////////////////////////////////////////////////////////////////
197 class AliCDBStorageFactory: public TObject {
198 friend class AliCDBManager;
201 virtual ~AliCDBStorageFactory(){}
202 virtual Bool_t Validate(const char* dbString) = 0;
203 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
206 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
208 ClassDef(AliCDBStorageFactory, 0);
211 /////////////////////////////////////////////////////////////////////
213 // class AliCDBParam //
215 /////////////////////////////////////////////////////////////////////
217 class AliCDBParam: public TObject {
222 virtual ~AliCDBParam();
224 const TString& GetType() const {return fType;};
225 const TString& GetURI() const {return fURI;};
227 virtual AliCDBParam* CloneParam() const = 0;
231 void SetType(const char* type) {fType = type;};
232 void SetURI(const char* uri) {fURI = uri;};
236 TString fType; //! CDB type
237 TString fURI; //! CDB URI
239 ClassDef(AliCDBParam, 0);