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 {
30 void RegisterFactory(AliCDBStorageFactory* factory);
32 Bool_t HasStorage(const char* dbString) const;
34 AliCDBParam* CreateParameter(const char* dbString) const;
36 AliCDBStorage* GetStorage(const char* dbString);
37 AliCDBStorage* GetStorage(const AliCDBParam* param);
39 TList* GetActiveStorages();
41 void SetDefaultStorage(const char* dbString);
42 void SetDefaultStorage(const AliCDBParam* param);
43 void SetDefaultStorage(AliCDBStorage *storage);
45 Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
46 AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
47 void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
49 void SetSpecificStorage(const char* calibType, const char* dbString);
50 void SetSpecificStorage(const char* calibType, AliCDBParam* param);
52 AliCDBStorage* GetSpecificStorage(const char* calibType);
54 void SetDrain(const char* dbString);
55 void SetDrain(const AliCDBParam* param);
56 void SetDrain(AliCDBStorage *storage);
58 Bool_t IsDrainSet() const {return fDrainStorage != 0;}
60 Bool_t Drain(AliCDBEntry* entry);
62 void UnsetDrain(){fDrainStorage = 0x0;}
64 AliCDBEntry* Get(const AliCDBId& query);
65 AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
66 Int_t version = -1, Int_t subVersion = -1);
67 AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
68 Int_t version = -1, Int_t subVersion = -1);
70 TList* GetAll(const AliCDBId& query);
71 TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
72 Int_t version = -1, Int_t subVersion = -1);
73 TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
74 Int_t version = -1, Int_t subVersion = -1);
76 Bool_t Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData);
77 Bool_t Put(AliCDBEntry* entry);
79 void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
80 Bool_t GetCacheFlag() const {return fCache;}
82 void SetRun(Long64_t run);
83 Long64_t GetRun() const {return fRun;}
85 // AliCDBEntry* Get(const char* path);
87 void DestroyActiveStorages();
88 void DestroyActiveStorage(AliCDBStorage* storage);
90 static void Destroy();
93 static AliCDBManager* Instance();
98 static AliCDBManager* fgInstance; // AliCDBManager instance
100 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
101 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
104 void CacheEntry(const char* path, AliCDBEntry* entry);
106 AliCDBParam* SelectSpecificStorage(const TString& path);
111 TList fFactories; //! list of registered storage factories
112 TMap fActiveStorages; //! list of active storages
113 TMap fSpecificStorages; //! list of detector-specific storages
115 AliCDBStorage *fDefaultStorage; //! pointer to default storage
116 AliCDBStorage *fDrainStorage; //! pointer to drain storage
118 TMap fEntryCache; //! cache of the retrieved objects
120 Bool_t fCache; //! The cache flag
121 Long64_t fRun; //! The run number
123 ClassDef(AliCDBManager, 0);
127 /////////////////////////////////////////////////////////////////////
129 // class AliCDBStorageFactory //
131 /////////////////////////////////////////////////////////////////////
134 class AliCDBStorageFactory: public TObject {
135 friend class AliCDBManager;
138 virtual ~AliCDBStorageFactory(){}
139 virtual Bool_t Validate(const char* dbString) = 0;
140 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
143 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
145 ClassDef(AliCDBStorageFactory, 0);
148 /////////////////////////////////////////////////////////////////////
150 // class AliCDBParam //
152 /////////////////////////////////////////////////////////////////////
154 class AliCDBParam: public TObject {
159 virtual ~AliCDBParam();
161 const TString& GetType() const {return fType;};
162 const TString& GetURI() const {return fURI;};
164 virtual AliCDBParam* CloneParam() const = 0;
168 void SetType(const char* type) {fType = type;};
169 void SetURI(const char* uri) {fURI = uri;};
173 TString fType; // CDB type
174 TString fURI; // CDB URI
176 ClassDef(AliCDBParam, 0);