]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCDBStorage.h
Virual base classes for AOD and ESD, organized in libSTEERBase (Markus)
[u/mrichter/AliRoot.git] / STEER / AliCDBStorage.h
1 #ifndef ALI_CDB_STORAGE_H
2 #define ALI_CDB_STORAGE_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 AliCDBStorage                                            //
10 //  interface to specific storage classes                          //
11 //  (AliCDBGrid, AliCDBLocal, AliCDBDump)                          //
12 //                                                                 //
13 /////////////////////////////////////////////////////////////////////
14
15 #include "AliCDBId.h"
16 #include "AliCDBMetaData.h"
17 #include "AliCDBManager.h"
18
19 #include <TList.h>
20 #include <TObjArray.h>
21
22 class AliCDBEntry;
23 class AliCDBPath;
24 class AliCDBParam;
25 class TFile;
26
27 class AliCDBStorage: public TObject {
28
29 public:
30
31         AliCDBStorage();
32
33         void SetURI(const TString& uri) {fURI = uri;}
34         const TString& GetURI() const {return fURI;}
35         const TString& GetType() const {return fType;}
36         const TString& GetBaseFolder() const {return fBaseFolder;}
37         AliCDBManager::DataType GetDataType() const;
38
39
40         void ReadSelectionFromFile(const char *fileName);
41         
42         void AddSelection(const AliCDBId& selection);
43
44         void AddSelection(const AliCDBPath& path, 
45                         const AliCDBRunRange& runRange,
46                         Int_t version,
47                         Int_t subVersion = -1);
48         
49         void AddSelection(const AliCDBPath& path,
50                         Int_t firstRun,
51                         Int_t lastRun,
52                         Int_t version,
53                         Int_t subVersion = -1);
54                         
55         void RemoveSelection(const AliCDBId& selection);
56
57         void RemoveSelection(const AliCDBPath& path,
58                         const AliCDBRunRange& runRange);
59         
60         void RemoveSelection(const AliCDBPath& path,
61                         Int_t firstRun = -1,
62                         Int_t lastRun = -1);
63
64         void RemoveSelection(int position);
65         void RemoveAllSelections();
66                 
67         void PrintSelectionList();
68
69         AliCDBEntry* Get(const AliCDBId& query);
70         AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber, 
71                                 Int_t version = -1, Int_t subVersion = -1);
72         AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
73                                  Int_t version = -1, Int_t subVersion = -1);
74
75         TList* GetAll(const AliCDBId& query);
76         TList* GetAll(const AliCDBPath& path, Int_t runNumber, 
77                                 Int_t version = -1, Int_t subVersion = -1);
78         TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
79                                  Int_t version = -1, Int_t subVersion = -1);
80         
81         Bool_t Put(TObject* object, AliCDBId& id,  AliCDBMetaData* metaData,
82                                 AliCDBManager::DataType type=AliCDBManager::kPrivate);
83         Bool_t Put(AliCDBEntry* entry, AliCDBManager::DataType type=AliCDBManager::kPrivate);
84
85         virtual Bool_t IsReadOnly() const = 0;
86         virtual Bool_t HasSubVersion() const = 0;
87         virtual Bool_t Contains(const char* path) const = 0;
88         virtual Bool_t IdToFilename(const AliCDBId& id, TString& filename) const = 0;
89
90         void QueryCDB(Int_t run, const char* pathFilter="*",
91                         Int_t version=-1, AliCDBMetaData *mdFilter=0);
92         void PrintQueryCDB();
93         TObjArray* GetQueryCDBList() {return &fValidFileIds;}
94
95         virtual Int_t GetLatestVersion(const char* path, Int_t run)=0;
96         virtual Int_t GetLatestSubVersion(const char* path, Int_t run, Int_t version=-1)=0;
97
98 protected:
99
100         virtual ~AliCDBStorage();
101         void    GetSelection(/*const*/ AliCDBId* id);
102         virtual AliCDBEntry* GetEntry(const AliCDBId& query) = 0;
103         virtual TList* GetEntries(const AliCDBId& query) = 0;
104         virtual Bool_t PutEntry(AliCDBEntry* entry) = 0;
105         virtual TList *GetIdListFromFile(const char* fileName)=0;
106         virtual void   QueryValidFiles() = 0;
107         void    LoadTreeFromFile(AliCDBEntry* entry) const;
108         //void  SetTreeToFile(AliCDBEntry* entry, TFile* file) const;
109
110         TObjArray fValidFileIds;        // list of Id's of the files valid for a given run (cached as fRun)
111         Int_t fRun;             // run number, used to manage list of valid files
112         AliCDBPath fPathFilter; // path filter, used to manage list of valid files
113         Int_t fVersion;         // version, used to manage list of valid files
114         AliCDBMetaData* fMetaDataFilter; // metadata, used to manage list of valid files
115
116         TList fSelections;      // list of selection criteria
117         TString fURI;           // storage URI;
118         TString fType;    //! Local, Grid: base folder name - Dump: file name
119         TString fBaseFolder;    //! Local, Grid: base folder name - Dump: file name
120
121 private:
122         AliCDBStorage(const AliCDBStorage & source);
123         AliCDBStorage & operator=(const AliCDBStorage & source);
124
125         ClassDef(AliCDBStorage, 0);
126 };
127
128 #endif