]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCDBStorage.h
Correction.
[u/mrichter/AliRoot.git] / STEER / AliCDBStorage.h
index c9421dd4fcb7b6be551cc670246dcd3953f1179f..d8c3fcf558c93ab90032075affff043d01013c30 100644 (file)
-#ifndef ALICDBSTORAGE_H
-#define ALICDBSTORAGE_H
+#ifndef ALI_CDB_STORAGE_H
+#define ALI_CDB_STORAGE_H
+
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */
-
-///
-/// base class for data base access classes
-///
+/////////////////////////////////////////////////////////////////////
+//                                                                 //
+//  class AliCDBStorage                                                   //
+//  interface to specific storage classes                          //
+//  (AliCDBGrid, AliCDBLocal, AliCDBDump)                         //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
 
-#include <TObject.h>
-#include <TObjArray.h>
-#include "AliCDBMetaDataSelect.h"
+#include "AliCDBId.h"
 #include "AliCDBMetaData.h"
+#include "AliCDBManager.h"
 
+#include <TList.h>
+#include <TObjArray.h>
 
-class TFile;
-class AliCDBMetaDataSelect;
-class AliCDBMetaData;
 class AliCDBEntry;
+class AliCDBPath;
+class AliCDBParam;
+class TFile;
 
 class AliCDBStorage: public TObject {
-public:
-
-typedef enum {kDevelopment, kProduction} StorageMode_t;
-
-  virtual ~AliCDBStorage();
-
-  const TObject*         Get(const char* name, Int_t runNumber);       // Gets an object from the database
 
-  Bool_t                 Put(const TObject* object, 
-                            const AliCDBMetaData& metaData);   // Put an object into the database
-
-  void                   Select(const AliCDBMetaDataSelect& selMetaData);      // Add a selection criterion 
-
-  Bool_t                 DumpToFile(const char* fileName = "DB.root"); // prepares to dump the retrieved entries to a local file
-  
-  const AliCDBMetaData& GetCDBMetaData(const char* name);              // Gets the CDBMetaData of the retrieved entry (name=entry's name)
-  
-  virtual void          TagForProduction(const AliCDBMetaDataSelect& selMetaData, UInt_t prodVers) = 0;
-
-  static AliCDBStorage* Instance();            // Instance of the current AliCDBStorage object (AliCDBDump, AliCDBLocalFile etc...)
+public:
 
-  void                 SetStorageMode(StorageMode_t mode)         {fStorageMode = mode;}
-  StorageMode_t GetStorageMode()         {return fStorageMode;}
-  
+       AliCDBStorage();
+
+       void SetURI(const TString& uri) {fURI = uri;}
+       const TString& GetURI() const {return fURI;}
+       const TString& GetType() const {return fType;}
+       const TString& GetBaseFolder() const {return fBaseFolder;}
+       AliCDBManager::DataType GetDataType() const;
+
+
+       void ReadSelectionFromFile(const char *fileName);
+       
+       void AddSelection(const AliCDBId& selection);
+
+       void AddSelection(const AliCDBPath& path, 
+                       const AliCDBRunRange& runRange,
+                       Int_t version,
+                       Int_t subVersion = -1);
+       
+       void AddSelection(const AliCDBPath& path,
+                       Int_t firstRun,
+                       Int_t lastRun,
+                       Int_t version,
+                       Int_t subVersion = -1);
+                       
+       void RemoveSelection(const AliCDBId& selection);
+
+       void RemoveSelection(const AliCDBPath& path,
+                       const AliCDBRunRange& runRange);
+       
+       void RemoveSelection(const AliCDBPath& path,
+                       Int_t firstRun = -1,
+                       Int_t lastRun = -1);
+
+       void RemoveSelection(int position);
+       void RemoveAllSelections();
+               
+       void PrintSelectionList();
+
+       AliCDBEntry* Get(const AliCDBId& query);
+       AliCDBEntry* Get(const AliCDBPath& path, Int_t runNumber,
+                               Int_t version = -1, Int_t subVersion = -1);
+       AliCDBEntry* Get(const AliCDBPath& path, const AliCDBRunRange& runRange,
+                                Int_t version = -1, Int_t subVersion = -1);
+
+       TList* GetAll(const AliCDBId& query);
+       TList* GetAll(const AliCDBPath& path, Int_t runNumber, 
+                               Int_t version = -1, Int_t subVersion = -1);
+       TList* GetAll(const AliCDBPath& path, const AliCDBRunRange& runRange,
+                                Int_t version = -1, Int_t subVersion = -1);
+       
+       AliCDBId* GetId(const AliCDBId& query);
+       AliCDBId* GetId(const AliCDBPath& path, Int_t runNumber,
+                               Int_t version = -1, Int_t subVersion = -1);
+       AliCDBId* GetId(const AliCDBPath& path, const AliCDBRunRange& runRange,
+                                Int_t version = -1, Int_t subVersion = -1);
+
+       Bool_t Put(TObject* object, AliCDBId& id,  AliCDBMetaData* metaData,
+                               AliCDBManager::DataType type=AliCDBManager::kPrivate);
+       Bool_t Put(AliCDBEntry* entry, AliCDBManager::DataType type=AliCDBManager::kPrivate);
+
+       virtual Bool_t IsReadOnly() const = 0;
+       virtual Bool_t HasSubVersion() const = 0;
+       virtual Bool_t Contains(const char* path) const = 0;
+       virtual Bool_t IdToFilename(const AliCDBId& id, TString& filename) const = 0;
+
+       void QueryCDB(Int_t run, const char* pathFilter="*",
+                       Int_t version=-1, AliCDBMetaData *mdFilter=0);
+       void PrintQueryCDB();
+       TObjArray* GetQueryCDBList() {return &fValidFileIds;}
+
+       virtual Int_t GetLatestVersion(const char* path, Int_t run)=0;
+       virtual Int_t GetLatestSubVersion(const char* path, Int_t run, Int_t version=-1)=0;
 
 protected:
-  AliCDBStorage();
-
-  virtual AliCDBEntry*    GetEntry(AliCDBMetaDataSelect& selMetaData, Int_t runNumber) = 0;    // virtual, see the correspondent method of the derived classes
 
-  virtual Bool_t          PutEntry(AliCDBEntry* entry);                        // virtual, see the correspondent method of the derived classes
-
-  AliCDBEntry*            GetCurrentEntry(const char* name) const
-    {return (AliCDBEntry*) fEntries.FindObject(name);}
-  
-  StorageMode_t fStorageMode;
+       virtual ~AliCDBStorage();
+       void    GetSelection(/*const*/ AliCDBId* id);
+       virtual AliCDBEntry* GetEntry(const AliCDBId& query) = 0;
+       virtual AliCDBId* GetEntryId(const AliCDBId& query) = 0;
+       virtual TList* GetEntries(const AliCDBId& query) = 0;
+       virtual Bool_t PutEntry(AliCDBEntry* entry) = 0;
+       virtual TList *GetIdListFromFile(const char* fileName)=0;
+       virtual void   QueryValidFiles() = 0;
+       void    LoadTreeFromFile(AliCDBEntry* entry) const;
+       //void  SetTreeToFile(AliCDBEntry* entry, TFile* file) const;
+
+       TObjArray fValidFileIds;        // list of Id's of the files valid for a given run (cached as fRun)
+       Int_t fRun;             // run number, used to manage list of valid files
+       AliCDBPath fPathFilter; // path filter, used to manage list of valid files
+       Int_t fVersion;         // version, used to manage list of valid files
+       AliCDBMetaData* fMetaDataFilter; // metadata, used to manage list of valid files
+
+       TList fSelections;      // list of selection criteria
+       TString fURI;           // storage URI;
+       TString fType;    //! Local, Grid: base folder name - Dump: file name
+       TString fBaseFolder;    //! Local, Grid: base folder name - Dump: file name
 
 private:
-  AliCDBStorage(const AliCDBStorage& db);
-  AliCDBStorage& operator = (const AliCDBStorage& db);
-
-  TObjArray              fSelection;   //! meta data selection
-
-  TObjArray              fEntries;     //! array of current AliCDBEntry objects
-  TFile*                 fDumpFile;  //! file for dumped entries
-
-  static AliCDBStorage* fgInstance;   //! pointer to the DB instance
+       AliCDBStorage(const AliCDBStorage & source);
+       AliCDBStorage & operator=(const AliCDBStorage & source);
 
-  ClassDef(AliCDBStorage, 0)     // base class for data base access classes
+       ClassDef(AliCDBStorage, 0);
 };
 
 #endif