]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCDBManager.h
I've tried to make some output messages lighter (and moved others
[u/mrichter/AliRoot.git] / STEER / AliCDBManager.h
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
17 class AliCDBEntry;
18 class AliCDBId;
19 class AliCDBPath;
20 class AliCDBRunRange;
21 class AliCDBMetaData;
22 class AliCDBStorage;
23 class AliCDBStorageFactory;
24 class AliCDBParam;
25
26 class AliCDBManager: public TObject {
27
28  public:
29         enum DataType {kCondition=0, kReference, kPrivate};
30
31         void RegisterFactory(AliCDBStorageFactory* factory);
32
33         Bool_t HasStorage(const char* dbString) const;
34
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);
39
40         AliCDBStorage* GetStorage(const char* dbString);
41         AliCDBStorage* GetStorage(const AliCDBParam* param);
42
43         TList* GetActiveStorages();
44
45         void SetDefaultStorage(const char* dbString);
46         void SetDefaultStorage(const AliCDBParam* param);
47         void SetDefaultStorage(AliCDBStorage *storage);
48         
49         Bool_t IsDefaultStorageSet() const {return fDefaultStorage != 0;}
50         AliCDBStorage* GetDefaultStorage() const {return fDefaultStorage;}
51         void UnsetDefaultStorage() {fDefaultStorage = 0x0;}
52
53         void SetSpecificStorage(const char* calibType, const char* dbString);
54         void SetSpecificStorage(const char* calibType, AliCDBParam* param);
55
56         AliCDBStorage* GetSpecificStorage(const char* calibType);
57
58         void SetDrain(const char* dbString);
59         void SetDrain(const AliCDBParam* param);
60         void SetDrain(AliCDBStorage *storage);
61
62         Bool_t IsDrainSet() const {return fDrainStorage != 0;}
63
64         Bool_t Drain(AliCDBEntry* entry);
65
66         void UnsetDrain(){fDrainStorage = 0x0;}
67
68         AliCDBEntry* Get(const AliCDBId& query);
69         AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber=-1,
70                                 Int_t version = -1, Int_t subVersion = -1);
71         AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
72                                  Int_t version = -1, Int_t subVersion = -1);
73
74         TList* GetAll(const AliCDBId& query);
75         TList* GetAll(const AliCDBPath& path, Int_t runNumber=-1,
76                                 Int_t version = -1, Int_t subVersion = -1);
77         TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
78                                  Int_t version = -1, Int_t subVersion = -1); 
79
80         Bool_t Put(TObject* object, AliCDBId& id,
81                         AliCDBMetaData* metaData, DataType type=kPrivate);
82         Bool_t Put(AliCDBEntry* entry, DataType type=kPrivate);
83
84         void SetCacheFlag(Bool_t cacheFlag) {fCache=cacheFlag;}
85         Bool_t GetCacheFlag() const {return fCache;}
86
87         void SetRun(Int_t run);
88         Int_t GetRun() const {return fRun;}
89
90         // AliCDBEntry* Get(const char* path);
91
92         void DestroyActiveStorages();
93         void DestroyActiveStorage(AliCDBStorage* storage);
94
95         void QueryCDB();
96
97         void Print(Option_t* option="") const;
98
99         static void Destroy();
100         ~AliCDBManager();
101
102         static AliCDBManager* Instance(); 
103
104  private:
105
106         static TString fgkCondUri;      // URI of the Conditions data base folder
107         static TString fgkRefUri;       // URI of the Reference data base folder
108         AliCDBParam* fCondParam;        // Conditions data storage parameters
109         AliCDBParam* fRefParam;         // Reference data storage parameters
110
111         AliCDBManager();
112         AliCDBManager(const AliCDBManager & source);
113         AliCDBManager & operator=(const AliCDBManager & source);
114
115         static AliCDBManager* fgInstance; // AliCDBManager instance
116         
117         AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
118         void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
119
120         void ClearCache();
121         void CacheEntry(const char* path, AliCDBEntry* entry);
122         
123         AliCDBParam* SelectSpecificStorage(const TString& path);
124         
125
126         void Init();
127         
128         TList fFactories;               //! list of registered storage factories
129         TMap fActiveStorages;           //! list of active storages
130         TMap fSpecificStorages;         //! list of detector-specific storages
131
132         AliCDBStorage *fDefaultStorage; //! pointer to default storage
133         AliCDBStorage *fDrainStorage;   //! pointer to drain storage
134
135         TMap fEntryCache;       //! cache of the retrieved objects
136
137         Bool_t fCache;                  //! The cache flag
138         Int_t fRun;                     //! The run number
139
140         ClassDef(AliCDBManager, 0);
141 };
142
143
144 /////////////////////////////////////////////////////////////////////
145 //                                                                 //
146 //  class AliCDBStorageFactory                                     //
147 //                                                                 //
148 /////////////////////////////////////////////////////////////////////
149
150 class AliCDBParam;
151 class AliCDBStorageFactory: public TObject {
152         friend class AliCDBManager;
153         
154 public:
155         virtual ~AliCDBStorageFactory(){}
156         virtual Bool_t Validate(const char* dbString) = 0;
157         virtual AliCDBParam* CreateParameter(const char* dbString) = 0; 
158
159 protected:
160         virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
161
162         ClassDef(AliCDBStorageFactory, 0);
163 };
164
165 /////////////////////////////////////////////////////////////////////
166 //                                                                 //
167 //  class AliCDBParam                                              //
168 //                                                                 //
169 /////////////////////////////////////////////////////////////////////
170
171 class AliCDBParam: public TObject {
172
173 public:
174
175         AliCDBParam();
176         virtual ~AliCDBParam();
177
178         const TString& GetType() const {return fType;};
179         const TString& GetURI() const {return fURI;};
180
181         virtual AliCDBParam* CloneParam() const = 0;
182
183 protected:
184
185         void SetType(const char* type) {fType = type;};
186         void SetURI(const char* uri) {fURI = uri;};
187
188 private:
189
190         TString fType; //! CDB type
191         TString fURI;  //! CDB URI
192
193         ClassDef(AliCDBParam, 0);
194 };
195
196 #endif