]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCDBManager.h
moved AliSelector, AliSelectorRL to STEER
[u/mrichter/AliRoot.git] / STEER / AliCDBManager.h
CommitLineData
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 17class AliCDBEntry;
02c4845e 18class AliCDBId;
19class AliCDBPath;
20class AliCDBRunRange;
21class AliCDBMetaData;
9e1ceb13 22class AliCDBStorage;
23class AliCDBStorageFactory;
24class AliCDBParam;
25
26class 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);
62032124 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);
62032124 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
c3a7b59a 82 void SetRun(Int_t run);
83 Int_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);
917a098b 89
62032124 90 void QueryCDB();
91
917a098b 92 void Print(Option_t* option="") const;
93
9e1ceb13 94 static void Destroy();
95 ~AliCDBManager();
96
b05400be 97 static AliCDBManager* Instance();
9e1ceb13 98
99 private:
100
101 AliCDBManager();
fe12e09c 102 AliCDBManager(const AliCDBManager & source);
103 AliCDBManager & operator=(const AliCDBManager & source);
104
fdf65bb5 105 static AliCDBManager* fgInstance; // AliCDBManager instance
9e1ceb13 106
107 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
108 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
917a098b 109
4b5e0dce 110 void ClearCache();
111 void CacheEntry(const char* path, AliCDBEntry* entry);
112
024cf675 113 AliCDBParam* SelectSpecificStorage(const TString& path);
114
9e1ceb13 115
116 void Init();
117
b05400be 118 TList fFactories; //! list of registered storage factories
119 TMap fActiveStorages; //! list of active storages
02c4845e 120 TMap fSpecificStorages; //! list of detector-specific storages
4b5e0dce 121
b05400be 122 AliCDBStorage *fDefaultStorage; //! pointer to default storage
123 AliCDBStorage *fDrainStorage; //! pointer to drain storage
9e1ceb13 124
4b5e0dce 125 TMap fEntryCache; //! cache of the retrieved objects
126
127 Bool_t fCache; //! The cache flag
c3a7b59a 128 Int_t fRun; //! The run number
4b5e0dce 129
9e1ceb13 130 ClassDef(AliCDBManager, 0);
131};
132
133
134/////////////////////////////////////////////////////////////////////
135// //
136// class AliCDBStorageFactory //
137// //
138/////////////////////////////////////////////////////////////////////
139
140class AliCDBParam;
141class AliCDBStorageFactory: public TObject {
142 friend class AliCDBManager;
143
144public:
e1e6896f 145 virtual ~AliCDBStorageFactory(){}
9e1ceb13 146 virtual Bool_t Validate(const char* dbString) = 0;
b05400be 147 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
9e1ceb13 148
149protected:
150 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
151
152 ClassDef(AliCDBStorageFactory, 0);
153};
154
155/////////////////////////////////////////////////////////////////////
156// //
157// class AliCDBParam //
158// //
159/////////////////////////////////////////////////////////////////////
160
161class AliCDBParam: public TObject {
162
163public:
164
165 AliCDBParam();
166 virtual ~AliCDBParam();
167
168 const TString& GetType() const {return fType;};
169 const TString& GetURI() const {return fURI;};
170
171 virtual AliCDBParam* CloneParam() const = 0;
172
173protected:
174
175 void SetType(const char* type) {fType = type;};
176 void SetURI(const char* uri) {fURI = uri;};
177
178private:
179
917a098b 180 TString fType; //! CDB type
181 TString fURI; //! CDB URI
9e1ceb13 182
183 ClassDef(AliCDBParam, 0);
184};
185
186#endif