]>
Commit | Line | Data |
---|---|---|
9e1ceb13 | 1 | #ifndef ALI_CDB_MANAGER_H |
2 | #define ALI_CDB_MANAGER_H | |
3 | ||
4 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | ||
7 | ///////////////////////////////////////////////////////////////////// | |
8 | // // | |
9 | // class AliCDBManager // | |
10 | // // | |
11 | ///////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #include <TObject.h> | |
14 | #include <TList.h> | |
15 | #include <TMap.h> | |
16 | ||
fdf65bb5 | 17 | class AliCDBEntry; |
02c4845e | 18 | class AliCDBId; |
19 | class AliCDBPath; | |
20 | class AliCDBRunRange; | |
21 | class AliCDBMetaData; | |
9e1ceb13 | 22 | class AliCDBStorage; |
23 | class AliCDBStorageFactory; | |
24 | class AliCDBParam; | |
25 | ||
26 | class AliCDBManager: public TObject { | |
27 | ||
28 | public: | |
29 | ||
30 | void RegisterFactory(AliCDBStorageFactory* factory); | |
31 | ||
fdf65bb5 | 32 | Bool_t HasStorage(const char* dbString) const; |
9e1ceb13 | 33 | |
fdf65bb5 | 34 | AliCDBParam* CreateParameter(const char* dbString) const; |
9e1ceb13 | 35 | |
36 | AliCDBStorage* GetStorage(const char* dbString); | |
37 | AliCDBStorage* GetStorage(const AliCDBParam* param); | |
38 | ||
39 | TList* GetActiveStorages(); | |
40 | ||
41 | void SetDefaultStorage(const char* dbString); | |
42 | void SetDefaultStorage(const AliCDBParam* param); | |
43 | void SetDefaultStorage(AliCDBStorage *storage); | |
9e1ceb13 | 44 | |
02c4845e | 45 | Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;} |
fdf65bb5 | 46 | AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;} |
b05400be | 47 | void UnsetDefaultStorage() {fDefaultStorage = 0x0;} |
02c4845e | 48 | |
024cf675 | 49 | void SetSpecificStorage(const char* calibType, const char* dbString); |
50 | void SetSpecificStorage(const char* calibType, AliCDBParam* param); | |
02c4845e | 51 | |
024cf675 | 52 | AliCDBStorage* GetSpecificStorage(const char* calibType); |
9e1ceb13 | 53 | |
54 | void SetDrain(const char* dbString); | |
55 | void SetDrain(const AliCDBParam* param); | |
56 | void SetDrain(AliCDBStorage *storage); | |
57 | ||
fdf65bb5 | 58 | Bool_t IsDrainSet() const {return fDrainStorage != 0;} |
9e1ceb13 | 59 | |
60 | Bool_t Drain(AliCDBEntry* entry); | |
61 | ||
b05400be | 62 | void UnsetDrain(){fDrainStorage = 0x0;} |
9e1ceb13 | 63 | |
02c4845e | 64 | AliCDBEntry* Get(const AliCDBId& query); |
024cf675 | 65 | AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 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); | |
69 | ||
70 | TList* GetAll(const AliCDBId& query); | |
024cf675 | 71 | TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1, |
02c4845e | 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); | |
75 | ||
76 | Bool_t Put(TObject* object, AliCDBId& id, AliCDBMetaData* metaData); | |
77 | Bool_t Put(AliCDBEntry* entry); | |
4b5e0dce | 78 | |
79 | void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;} | |
e1e6896f | 80 | Bool_t GetCacheFlag() const {return fCache;} |
4b5e0dce | 81 | |
82 | void SetRun(Long64_t run); | |
e1e6896f | 83 | Long64_t GetRun() const {return fRun;} |
4b5e0dce | 84 | |
024cf675 | 85 | // AliCDBEntry* Get(const char* path); |
02c4845e | 86 | |
9e1ceb13 | 87 | void DestroyActiveStorages(); |
88 | void DestroyActiveStorage(AliCDBStorage* storage); | |
89 | ||
90 | static void Destroy(); | |
91 | ~AliCDBManager(); | |
92 | ||
b05400be | 93 | static AliCDBManager* Instance(); |
9e1ceb13 | 94 | |
95 | private: | |
96 | ||
97 | AliCDBManager(); | |
fdf65bb5 | 98 | static AliCDBManager* fgInstance; // AliCDBManager instance |
9e1ceb13 | 99 | |
100 | AliCDBStorage* GetActiveStorage(const AliCDBParam* param); | |
101 | void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage); | |
4b5e0dce | 102 | |
103 | void ClearCache(); | |
104 | void CacheEntry(const char* path, AliCDBEntry* entry); | |
105 | ||
024cf675 | 106 | AliCDBParam* SelectSpecificStorage(const TString& path); |
107 | ||
9e1ceb13 | 108 | |
109 | void Init(); | |
110 | ||
b05400be | 111 | TList fFactories; //! list of registered storage factories |
112 | TMap fActiveStorages; //! list of active storages | |
02c4845e | 113 | TMap fSpecificStorages; //! list of detector-specific storages |
4b5e0dce | 114 | |
b05400be | 115 | AliCDBStorage *fDefaultStorage; //! pointer to default storage |
116 | AliCDBStorage *fDrainStorage; //! pointer to drain storage | |
9e1ceb13 | 117 | |
4b5e0dce | 118 | TMap fEntryCache; //! cache of the retrieved objects |
119 | ||
120 | Bool_t fCache; //! The cache flag | |
121 | Long64_t fRun; //! The run number | |
122 | ||
9e1ceb13 | 123 | ClassDef(AliCDBManager, 0); |
124 | }; | |
125 | ||
126 | ||
127 | ///////////////////////////////////////////////////////////////////// | |
128 | // // | |
129 | // class AliCDBStorageFactory // | |
130 | // // | |
131 | ///////////////////////////////////////////////////////////////////// | |
132 | ||
133 | class AliCDBParam; | |
134 | class AliCDBStorageFactory: public TObject { | |
135 | friend class AliCDBManager; | |
136 | ||
137 | public: | |
e1e6896f | 138 | virtual ~AliCDBStorageFactory(){} |
9e1ceb13 | 139 | virtual Bool_t Validate(const char* dbString) = 0; |
b05400be | 140 | virtual AliCDBParam* CreateParameter(const char* dbString) = 0; |
9e1ceb13 | 141 | |
142 | protected: | |
143 | virtual AliCDBStorage* Create(const AliCDBParam* param) = 0; | |
144 | ||
145 | ClassDef(AliCDBStorageFactory, 0); | |
146 | }; | |
147 | ||
148 | ///////////////////////////////////////////////////////////////////// | |
149 | // // | |
150 | // class AliCDBParam // | |
151 | // // | |
152 | ///////////////////////////////////////////////////////////////////// | |
153 | ||
154 | class AliCDBParam: public TObject { | |
155 | ||
156 | public: | |
157 | ||
158 | AliCDBParam(); | |
159 | virtual ~AliCDBParam(); | |
160 | ||
161 | const TString& GetType() const {return fType;}; | |
162 | const TString& GetURI() const {return fURI;}; | |
163 | ||
164 | virtual AliCDBParam* CloneParam() const = 0; | |
165 | ||
166 | protected: | |
167 | ||
168 | void SetType(const char* type) {fType = type;}; | |
169 | void SetURI(const char* uri) {fURI = uri;}; | |
170 | ||
171 | private: | |
172 | ||
b05400be | 173 | TString fType; // CDB type |
174 | TString fURI; // CDB URI | |
9e1ceb13 | 175 | |
176 | ClassDef(AliCDBParam, 0); | |
177 | }; | |
178 | ||
179 | #endif |