Improved diagnostic messages. Different access strings for AliCDBGrid. New or renamed...
[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 UnsetDefaultStorage() {fDefaultStorage = 0x0;}
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 UnsetDrain(){fDrainStorage = 0x0;}
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
98 protected:
99         virtual AliCDBStorage* Create(const AliCDBParam* param) = 0;
100
101         ClassDef(AliCDBStorageFactory, 0);
102 };
103
104 /////////////////////////////////////////////////////////////////////
105 //                                                                 //
106 //  class AliCDBParam                                              //
107 //                                                                 //
108 /////////////////////////////////////////////////////////////////////
109
110 class AliCDBParam: public TObject {
111
112 public:
113
114         AliCDBParam();
115         virtual ~AliCDBParam();
116
117         const TString& GetType() const {return fType;};
118         const TString& GetURI() const {return fURI;};
119
120         virtual AliCDBParam* CloneParam() const = 0;
121
122 protected:
123
124         void SetType(const char* type) {fType = type;};
125         void SetURI(const char* uri) {fURI = uri;};
126
127 private:
128
129         TString fType; // CDB type
130         TString fURI;  // CDB URI
131
132         ClassDef(AliCDBParam, 0);
133 };
134
135 #endif