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