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 SetSpecificStorage(const char* calibType, const char* dbString);
54 void SetSpecificStorage(const char* calibType, AliCDBParam* param);
56 AliCDBStorage* GetSpecificStorage(const char* calibType);
58 void SetDrain(const char* dbString);
59 void SetDrain(const AliCDBParam* param);
60 void SetDrain(AliCDBStorage *storage);
62 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
64 Bool_t Drain(AliCDBEntry* entry);
66 void UnsetDrain(){fDrainStorage = 0x0;}
68 AliCDBEntry* Get(const AliCDBId& query);
69 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
70 Int_t version = -1, Int_t subVersion = -1);
71 AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
72 Int_t version = -1, Int_t subVersion = -1);
74 TList* GetAll(const AliCDBId& query);
75 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
76 Int_t version = -1, Int_t subVersion = -1);
77 TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
78 Int_t version = -1, Int_t subVersion = -1);
80 Bool_t Put(TObject* object, AliCDBId& id,
81 AliCDBMetaData* metaData, DataType type=kPrivate);
82 Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
84 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
85 Bool_t GetCacheFlag() const {return fCache;}
87 void SetRun(Int_t run);
88 Int_t GetRun() const {return fRun;}
90 // AliCDBEntry* Get(const char* path);
92 void DestroyActiveStorages();
93 void DestroyActiveStorage(AliCDBStorage* storage);
97 void Print(Option_t* option="") const;
99 static void Destroy();
103 void UnloadFromCache(const char* path);
105 static AliCDBManager* Instance();
109 static TString fgkCondUri; // URI of the Conditions data base folder
110 static TString fgkRefUri; // URI of the Reference data base folder
111 AliCDBParam* fCondParam; // Conditions data storage parameters
112 AliCDBParam* fRefParam; // Reference data storage parameters
115 AliCDBManager(const AliCDBManager & source);
116 AliCDBManager & operator=(const AliCDBManager & source);
118 static AliCDBManager* fgInstance; // AliCDBManager instance
120 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
121 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
123 void CacheEntry(const char* path, AliCDBEntry* entry);
125 AliCDBParam* SelectSpecificStorage(const TString& path);
130 TList fFactories; //! list of registered storage factories
131 TMap fActiveStorages; //! list of active storages
132 TMap fSpecificStorages; //! list of detector-specific storages
134 AliCDBStorage *fDefaultStorage; //! pointer to default storage
135 AliCDBStorage *fDrainStorage; //! pointer to drain storage
137 TMap fEntryCache; //! cache of the retrieved objects
139 Bool_t fCache; //! The cache flag
140 Int_t fRun; //! The run number
142 ClassDef(AliCDBManager, 0);
146 /////////////////////////////////////////////////////////////////////
148 // class AliCDBStorageFactory //
150 /////////////////////////////////////////////////////////////////////
153 class AliCDBStorageFactory: public TObject {
154 friend class AliCDBManager;
157 virtual ~AliCDBStorageFactory(){}
158 virtual Bool_t Validate(const char* dbString) = 0;
159 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
162 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
164 ClassDef(AliCDBStorageFactory, 0);
167 /////////////////////////////////////////////////////////////////////
169 // class AliCDBParam //
171 /////////////////////////////////////////////////////////////////////
173 class AliCDBParam: public TObject {
178 virtual ~AliCDBParam();
180 const TString& GetType() const {return fType;};
181 const TString& GetURI() const {return fURI;};
183 virtual AliCDBParam* CloneParam() const = 0;
187 void SetType(const char* type) {fType = type;};
188 void SetURI(const char* uri) {fURI = uri;};
192 TString fType; //! CDB type
193 TString fURI; //! CDB URI
195 ClassDef(AliCDBParam, 0);