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);
52 Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
53 AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
54 void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
56 void SetRemoteStorage(const char* dbString);
57 void SetRemoteStorage(const AliCDBParam* param);
58 void SetRemoteStorage(AliCDBStorage *storage);
60 Bool_t IsRemoteStorageSet() const {return fRemoteStorage != 0;}
61 AliCDBStorage* GetRemoteStorage() const {return fRemoteStorage;}
62 void UnsetRemoteStorage() {fRemoteStorage = 0x0;}
64 void SetSpecificStorage(const char* calibType, const char* dbString);
65 void SetSpecificStorage(const char* calibType, AliCDBParam* param);
67 AliCDBStorage* GetSpecificStorage(const char* calibType);
69 void SetDrain(const char* dbString);
70 void SetDrain(const AliCDBParam* param);
71 void SetDrain(AliCDBStorage *storage);
73 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
75 Bool_t Drain(AliCDBEntry* entry);
77 void UnsetDrain(){fDrainStorage = 0x0;}
79 AliCDBEntry* Get(const AliCDBId& query);
80 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
81 Int_t version = -1, Int_t subVersion = -1);
82 AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
83 Int_t version = -1, Int_t subVersion = -1);
85 AliCDBId* GetId(const AliCDBId& query);
86 AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1,
87 Int_t version = -1, Int_t subVersion = -1);
88 AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange,
89 Int_t version = -1, Int_t subVersion = -1);
91 TList* GetAll(const AliCDBId& query);
92 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
93 Int_t version = -1, Int_t subVersion = -1);
94 TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
95 Int_t version = -1, Int_t subVersion = -1);
97 Bool_t Put(TObject* object, AliCDBId& id,
98 AliCDBMetaData* metaData, DataType type=kPrivate);
99 Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
101 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
102 Bool_t GetCacheFlag() const {return fCache;}
104 void SetRun(Int_t run);
105 Int_t GetRun() const {return fRun;}
107 void DestroyActiveStorages();
108 void DestroyActiveStorage(AliCDBStorage* storage);
112 void Print(Option_t* option="") const;
114 static void Destroy();
118 void UnloadFromCache(const char* path);
120 Bool_t IsShortLived(const char* path);
122 static AliCDBManager* Instance();
126 static TString fgkCondUri; // URI of the Conditions data base folder
127 static TString fgkRefUri; // URI of the Reference data base folder
130 AliCDBManager(const AliCDBManager & source);
131 AliCDBManager & operator=(const AliCDBManager & source);
133 static AliCDBManager* fgInstance; // AliCDBManager instance
135 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
136 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
138 void CacheEntry(const char* path, AliCDBEntry* entry);
140 AliCDBParam* SelectSpecificStorage(const TString& path);
144 void InitShortLived();
147 TList fFactories; //! list of registered storage factories
148 TMap fActiveStorages; //! list of active storages
149 TMap fSpecificStorages; //! list of detector-specific storages
150 TMap fEntryCache; //! cache of the retrieved objects
152 TList* fIds; //! List of the retrieved object Id's (to be streamed to file)
153 TMap* fStorageMap; //! list of storages (to be streamed to file)
154 TList* fShortLived; //! List of short lived objects
156 AliCDBStorage *fDefaultStorage; //! pointer to default storage
157 AliCDBStorage *fRemoteStorage; //! pointer to remote storage
158 AliCDBStorage *fDrainStorage; //! pointer to drain storage
160 AliCDBParam* fCondParam; // Conditions data storage parameters
161 AliCDBParam* fRefParam; // Reference data storage parameters
163 Int_t fRun; //! The run number
164 Bool_t fCache; //! The cache flag
167 ClassDef(AliCDBManager, 0);
171 /////////////////////////////////////////////////////////////////////
173 // class AliCDBStorageFactory //
175 /////////////////////////////////////////////////////////////////////
178 class AliCDBStorageFactory: public TObject {
179 friend class AliCDBManager;
182 virtual ~AliCDBStorageFactory(){}
183 virtual Bool_t Validate(const char* dbString) = 0;
184 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
187 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
189 ClassDef(AliCDBStorageFactory, 0);
192 /////////////////////////////////////////////////////////////////////
194 // class AliCDBParam //
196 /////////////////////////////////////////////////////////////////////
198 class AliCDBParam: public TObject {
203 virtual ~AliCDBParam();
205 const TString& GetType() const {return fType;};
206 const TString& GetURI() const {return fURI;};
208 virtual AliCDBParam* CloneParam() const = 0;
212 void SetType(const char* type) {fType = type;};
213 void SetURI(const char* uri) {fURI = uri;};
217 TString fType; //! CDB type
218 TString fURI; //! CDB URI
220 ClassDef(AliCDBParam, 0);