New version of CDB storage framework (A.Colla)
[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
17#include "AliCDBEntry.h"
18
19class AliCDBStorage;
20class AliCDBStorageFactory;
21class AliCDBParam;
22
23class AliCDBManager: public TObject {
24
25 public:
26
27 void RegisterFactory(AliCDBStorageFactory* factory);
28
29 Bool_t HasStorage(const char* dbString);
30
31 AliCDBParam* CreateParameter(const char* dbString);
32
33 AliCDBStorage* GetStorage(const char* dbString);
34 AliCDBStorage* GetStorage(const AliCDBParam* param);
35
36 TList* GetActiveStorages();
37
38 void SetDefaultStorage(const char* dbString);
39 void SetDefaultStorage(const AliCDBParam* param);
40 void SetDefaultStorage(AliCDBStorage *storage);
41
42 Bool_t IsDefaultStorageSet() {return fDefaultStorage != 0;}
43
44 AliCDBStorage* GetDefaultStorage() {return fDefaultStorage;}
45
46 void RemoveDefaultStorage();
47
48 void SetDrain(const char* dbString);
49 void SetDrain(const AliCDBParam* param);
50 void SetDrain(AliCDBStorage *storage);
51
52 Bool_t IsDrainSet() {return fDrainStorage != 0;}
53
54 Bool_t Drain(AliCDBEntry* entry);
55
56 void RemoveDrain();
57
58 void DestroyActiveStorages();
59 void DestroyActiveStorage(AliCDBStorage* storage);
60
61 static void Destroy();
62 ~AliCDBManager();
63
64 static AliCDBManager* Instance();
65
66 private:
67
68 AliCDBManager();
69 static AliCDBManager* fgInstance;
70
71 AliCDBStorage* GetActiveStorage(const AliCDBParam* param);
72 void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage);
73
74 void Init();
75
76 TList fFactories; // list of registered storage factories
77 TMap fActiveStorages; // list of active storages
78 AliCDBStorage *fDefaultStorage; // pointer to default storage
79 AliCDBStorage *fDrainStorage; // pointer to drain storage
80
81 ClassDef(AliCDBManager, 0);
82};
83
84
85/////////////////////////////////////////////////////////////////////
86// //
87// class AliCDBStorageFactory //
88// //
89/////////////////////////////////////////////////////////////////////
90
91class AliCDBParam;
92class AliCDBStorageFactory: public TObject {
93 friend class AliCDBManager;
94
95public:
96 virtual Bool_t Validate(const char* dbString) = 0;
97 virtual AliCDBParam* CreateParameter(const char* dbString) = 0;
98
99protected:
100 virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
101
102 ClassDef(AliCDBStorageFactory, 0);
103};
104
105/////////////////////////////////////////////////////////////////////
106// //
107// class AliCDBParam //
108// //
109/////////////////////////////////////////////////////////////////////
110
111class AliCDBParam: public TObject {
112
113public:
114
115 AliCDBParam();
116 virtual ~AliCDBParam();
117
118 const TString& GetType() const {return fType;};
119 const TString& GetURI() const {return fURI;};
120
121 virtual AliCDBParam* CloneParam() const = 0;
122
123protected:
124
125 void SetType(const char* type) {fType = type;};
126 void SetURI(const char* uri) {fURI = uri;};
127
128private:
129
130 TString fType;
131 TString fURI;
132
133 ClassDef(AliCDBParam, 0);
134};
135
136#endif