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 | |
49 | void SetSpecificStorage(const char* detName, const char* dbString); |
50 | void SetSpecificStorage(const char* detName, AliCDBParam* param); |
51 | |
52 | AliCDBStorage* GetSpecificStorage(const char* detName); |
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); |
65 | AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber, |
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); |
71 | TList* GetAll(const AliCDBPath& path, Int_t runNumber, |
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); |
78 | |
9e1ceb13 |
79 | void DestroyActiveStorages(); |
80 | void DestroyActiveStorage(AliCDBStorage* storage); |
81 | |
82 | static void Destroy(); |
83 | ~AliCDBManager(); |
84 | |
b05400be |
85 | static AliCDBManager* Instance(); |
9e1ceb13 |
86 | |
87 | private: |
88 | |
89 | AliCDBManager(); |
fdf65bb5 |
90 | static AliCDBManager* fgInstance; // AliCDBManager instance |
9e1ceb13 |
91 | |
92 | AliCDBStorage* GetActiveStorage(const AliCDBParam* param); |
93 | void PutActiveStorage(AliCDBParam* param, AliCDBStorage* storage); |
94 | |
95 | void Init(); |
96 | |
b05400be |
97 | TList fFactories; //! list of registered storage factories |
98 | TMap fActiveStorages; //! list of active storages |
02c4845e |
99 | TMap fSpecificStorages; //! list of detector-specific storages |
b05400be |
100 | AliCDBStorage *fDefaultStorage; //! pointer to default storage |
101 | AliCDBStorage *fDrainStorage; //! pointer to drain storage |
9e1ceb13 |
102 | |
103 | ClassDef(AliCDBManager, 0); |
104 | }; |
105 | |
106 | |
107 | ///////////////////////////////////////////////////////////////////// |
108 | // // |
109 | // class AliCDBStorageFactory // |
110 | // // |
111 | ///////////////////////////////////////////////////////////////////// |
112 | |
113 | class AliCDBParam; |
114 | class AliCDBStorageFactory: public TObject { |
115 | friend class AliCDBManager; |
116 | |
117 | public: |
118 | virtual Bool_t Validate(const char* dbString) = 0; |
b05400be |
119 | virtual AliCDBParam* CreateParameter(const char* dbString) = 0; |
9e1ceb13 |
120 | |
121 | protected: |
122 | virtual AliCDBStorage* Create(const AliCDBParam* param) = 0; |
123 | |
124 | ClassDef(AliCDBStorageFactory, 0); |
125 | }; |
126 | |
127 | ///////////////////////////////////////////////////////////////////// |
128 | // // |
129 | // class AliCDBParam // |
130 | // // |
131 | ///////////////////////////////////////////////////////////////////// |
132 | |
133 | class AliCDBParam: public TObject { |
134 | |
135 | public: |
136 | |
137 | AliCDBParam(); |
138 | virtual ~AliCDBParam(); |
139 | |
140 | const TString& GetType() const {return fType;}; |
141 | const TString& GetURI() const {return fURI;}; |
142 | |
143 | virtual AliCDBParam* CloneParam() const = 0; |
144 | |
145 | protected: |
146 | |
147 | void SetType(const char* type) {fType = type;}; |
148 | void SetURI(const char* uri) {fURI = uri;}; |
149 | |
150 | private: |
151 | |
b05400be |
152 | TString fType; // CDB type |
153 | TString fURI; // CDB URI |
9e1ceb13 |
154 | |
155 | ClassDef(AliCDBParam, 0); |
156 | }; |
157 | |
158 | #endif |