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 void SetDefaultStorage(const char* dbString);
46 void SetDefaultStorage(const AliCDBParam* param);
47 void SetDefaultStorage(AliCDBStorage *storage);
49 Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
50 AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
51 void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
53 void SetRemoteStorage(const char* dbString);
54 void SetRemoteStorage(const AliCDBParam* param);
55 void SetRemoteStorage(AliCDBStorage *storage);
57 Bool_t IsRemoteStorageSet() const {return fRemoteStorage != 0;}
58 AliCDBStorage* GetRemoteStorage() const {return fRemoteStorage;}
59 void UnsetRemoteStorage() {fRemoteStorage = 0x0;}
61 void SetSpecificStorage(const char* calibType, const char* dbString);
62 void SetSpecificStorage(const char* calibType, AliCDBParam* param);
64 AliCDBStorage* GetSpecificStorage(const char* calibType);
66 void SetDrain(const char* dbString);
67 void SetDrain(const AliCDBParam* param);
68 void SetDrain(AliCDBStorage *storage);
70 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
72 Bool_t Drain(AliCDBEntry* entry);
74 void UnsetDrain(){fDrainStorage = 0x0;}
76 AliCDBEntry* Get(const AliCDBId& query);
77 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
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);
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);
88 TList* GetAll(const AliCDBId& query);
89 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
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);
94 Bool_t Put(TObject* object, AliCDBId& id,
95 AliCDBMetaData* metaData, DataType type=kPrivate);
96 Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
98 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
99 Bool_t GetCacheFlag() const {return fCache;}
101 void SetRun(Int_t run);
102 Int_t GetRun() const {return fRun;}
104 void DestroyActiveStorages();
105 void DestroyActiveStorage(AliCDBStorage* storage);
109 void Print(Option_t* option="") const;
111 static void Destroy();
115 void UnloadFromCache(const char* path);
117 Bool_t IsShortLived(const char* path);
119 static AliCDBManager* Instance();
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
129 AliCDBManager(const AliCDBManager & source);
130 AliCDBManager & operator=(const AliCDBManager & source);
132 static AliCDBManager* fgInstance; // AliCDBManager instance
134 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
135 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
137 void CacheEntry(const char* path, AliCDBEntry* entry);
139 AliCDBParam* SelectSpecificStorage(const TString& path);
143 void InitShortLived();
146 TList fFactories; //! list of registered storage factories
147 TMap fActiveStorages; //! list of active storages
148 TMap fSpecificStorages; //! list of detector-specific storages
150 AliCDBStorage *fDefaultStorage; //! pointer to default storage
151 AliCDBStorage *fRemoteStorage; //! pointer to remote storage
152 AliCDBStorage *fDrainStorage; //! pointer to drain storage
154 TMap fEntryCache; //! cache of the retrieved objects
156 Bool_t fCache; //! The cache flag
157 Int_t fRun; //! The run number
159 TList* fShortLived; //! List of short lived objects
161 ClassDef(AliCDBManager, 0);
165 /////////////////////////////////////////////////////////////////////
167 // class AliCDBStorageFactory //
169 /////////////////////////////////////////////////////////////////////
172 class AliCDBStorageFactory: public TObject {
173 friend class AliCDBManager;
176 virtual ~AliCDBStorageFactory(){}
177 virtual Bool_t Validate(const char* dbString) = 0;
178 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
181 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
183 ClassDef(AliCDBStorageFactory, 0);
186 /////////////////////////////////////////////////////////////////////
188 // class AliCDBParam //
190 /////////////////////////////////////////////////////////////////////
192 class AliCDBParam: public TObject {
197 virtual ~AliCDBParam();
199 const TString& GetType() const {return fType;};
200 const TString& GetURI() const {return fURI;};
202 virtual AliCDBParam* CloneParam() const = 0;
206 void SetType(const char* type) {fType = type;};
207 void SetURI(const char* uri) {fURI = uri;};
211 TString fType; //! CDB type
212 TString fURI; //! CDB URI
214 ClassDef(AliCDBParam, 0);