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();
56 void SetSpecificStorage(const char* calibType, const char* dbString);
57 void SetSpecificStorage(const char* calibType, AliCDBParam* param);
59 AliCDBStorage* GetSpecificStorage(const char* calibType);
61 void SetDrain(const char* dbString);
62 void SetDrain(const AliCDBParam* param);
63 void SetDrain(AliCDBStorage *storage);
65 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
67 Bool_t Drain(AliCDBEntry* entry);
69 void UnsetDrain(){fDrainStorage = 0x0;}
71 AliCDBEntry* Get(const AliCDBId& query);
72 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
73 Int_t version = -1, Int_t subVersion = -1);
74 AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
75 Int_t version = -1, Int_t subVersion = -1);
77 const char* GetURI(const char* path);
79 AliCDBId* GetId(const AliCDBId& query);
80 AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber=-1,
81 Int_t version = -1, Int_t subVersion = -1);
82 AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange,
83 Int_t version = -1, Int_t subVersion = -1);
85 TList* GetAll(const AliCDBId& query);
86 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
87 Int_t version = -1, Int_t subVersion = -1);
88 TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
89 Int_t version = -1, Int_t subVersion = -1);
91 Bool_t Put(TObject* object, AliCDBId& id,
92 AliCDBMetaData* metaData, DataType type=kPrivate);
93 Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
95 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
96 Bool_t GetCacheFlag() const {return fCache;}
98 void SetLock(Bool_t lockFlag=kTRUE);
99 Bool_t GetLock() const {return fLock;}
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);
116 const TMap* GetEntryCache() const {return &fEntryCache;}
118 Bool_t IsShortLived(const char* path);
120 static AliCDBManager* Instance(TMap *entryCache = NULL, Int_t run = -1);
124 static TString fgkCondUri; // URI of the Conditions data base folder
125 static TString fgkRefUri; // URI of the Reference data base folder
128 AliCDBManager(const AliCDBManager & source);
129 AliCDBManager & operator=(const AliCDBManager & source);
131 static AliCDBManager* fgInstance; // AliCDBManager instance
133 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
134 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
136 void CacheEntry(const char* path, AliCDBEntry* entry);
138 AliCDBParam* SelectSpecificStorage(const TString& path);
142 void InitShortLived();
143 void InitFromCache(TMap *entryCache, Int_t run);
146 TList fFactories; //! list of registered storage factories
147 TMap fActiveStorages; //! list of active storages
148 TMap fSpecificStorages; //! list of detector-specific storages
149 TMap fEntryCache; //! cache of the retrieved objects
151 TList* fIds; //! List of the retrieved object Id's (to be streamed to file)
152 TMap* fStorageMap; //! list of storages (to be streamed to file)
153 TList* fShortLived; //! List of short lived objects
155 AliCDBStorage *fDefaultStorage; //! pointer to default storage
156 AliCDBStorage *fDrainStorage; //! pointer to drain storage
158 AliCDBParam* fCondParam; // Conditions data storage parameters
159 AliCDBParam* fRefParam; // Reference data storage parameters
161 Int_t fRun; //! The run number
162 Bool_t fCache; //! The cache flag
163 Bool_t fLock; //! Lock flag, if ON default storage and run number cannot be reset
166 ClassDef(AliCDBManager, 0);
170 /////////////////////////////////////////////////////////////////////
172 // class AliCDBStorageFactory //
174 /////////////////////////////////////////////////////////////////////
177 class AliCDBStorageFactory: public TObject {
178 friend class AliCDBManager;
181 virtual ~AliCDBStorageFactory(){}
182 virtual Bool_t Validate(const char* dbString) = 0;
183 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
186 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
188 ClassDef(AliCDBStorageFactory, 0);
191 /////////////////////////////////////////////////////////////////////
193 // class AliCDBParam //
195 /////////////////////////////////////////////////////////////////////
197 class AliCDBParam: public TObject {
202 virtual ~AliCDBParam();
204 const TString& GetType() const {return fType;};
205 const TString& GetURI() const {return fURI;};
207 virtual AliCDBParam* CloneParam() const = 0;
211 void SetType(const char* type) {fType = type;};
212 void SetURI(const char* uri) {fURI = uri;};
216 TString fType; //! CDB type
217 TString fURI; //! CDB URI
219 ClassDef(AliCDBParam, 0);