ROOT logo
#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                               */

/////////////////////////////////////////////////////////////////////
//                                                                 //
//  class AliCDBStorage						   //
//  interface to specific storage classes                          //
//  (AliCDBGrid, AliCDBLocal, AliCDBDump)			   //
//                                                                 //
/////////////////////////////////////////////////////////////////////

#include "AliCDBId.h"
#include "AliCDBMetaData.h"
#include "AliCDBManager.h"

#include <TList.h>
#include <TObjArray.h>

class AliCDBEntry;
class AliCDBPath;
class AliCDBParam;
class TFile;

class AliCDBStorage: public TObject {

  public:

    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, const char* mirrors="",
        AliCDBManager::DataType type=AliCDBManager::kPrivate);
    Bool_t Put(AliCDBEntry* entry, const char* mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate);

    virtual void SetMirrorSEs(const char* mirrors);
    virtual const char* GetMirrorSEs() const;

    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 void SetRetry(Int_t nretry, Int_t initsec) = 0;

  protected:

    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, const char* mirrors="") = 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
    Short_t    fNretry;              // Number of retries in opening the file
    Short_t    fInitRetrySeconds;        // Seconds for first retry

  private:
    AliCDBStorage(const AliCDBStorage & source);
    AliCDBStorage & operator=(const AliCDBStorage & source);

    ClassDef(AliCDBStorage, 0);
};

#endif
 AliCDBStorage.h:1
 AliCDBStorage.h:2
 AliCDBStorage.h:3
 AliCDBStorage.h:4
 AliCDBStorage.h:5
 AliCDBStorage.h:6
 AliCDBStorage.h:7
 AliCDBStorage.h:8
 AliCDBStorage.h:9
 AliCDBStorage.h:10
 AliCDBStorage.h:11
 AliCDBStorage.h:12
 AliCDBStorage.h:13
 AliCDBStorage.h:14
 AliCDBStorage.h:15
 AliCDBStorage.h:16
 AliCDBStorage.h:17
 AliCDBStorage.h:18
 AliCDBStorage.h:19
 AliCDBStorage.h:20
 AliCDBStorage.h:21
 AliCDBStorage.h:22
 AliCDBStorage.h:23
 AliCDBStorage.h:24
 AliCDBStorage.h:25
 AliCDBStorage.h:26
 AliCDBStorage.h:27
 AliCDBStorage.h:28
 AliCDBStorage.h:29
 AliCDBStorage.h:30
 AliCDBStorage.h:31
 AliCDBStorage.h:32
 AliCDBStorage.h:33
 AliCDBStorage.h:34
 AliCDBStorage.h:35
 AliCDBStorage.h:36
 AliCDBStorage.h:37
 AliCDBStorage.h:38
 AliCDBStorage.h:39
 AliCDBStorage.h:40
 AliCDBStorage.h:41
 AliCDBStorage.h:42
 AliCDBStorage.h:43
 AliCDBStorage.h:44
 AliCDBStorage.h:45
 AliCDBStorage.h:46
 AliCDBStorage.h:47
 AliCDBStorage.h:48
 AliCDBStorage.h:49
 AliCDBStorage.h:50
 AliCDBStorage.h:51
 AliCDBStorage.h:52
 AliCDBStorage.h:53
 AliCDBStorage.h:54
 AliCDBStorage.h:55
 AliCDBStorage.h:56
 AliCDBStorage.h:57
 AliCDBStorage.h:58
 AliCDBStorage.h:59
 AliCDBStorage.h:60
 AliCDBStorage.h:61
 AliCDBStorage.h:62
 AliCDBStorage.h:63
 AliCDBStorage.h:64
 AliCDBStorage.h:65
 AliCDBStorage.h:66
 AliCDBStorage.h:67
 AliCDBStorage.h:68
 AliCDBStorage.h:69
 AliCDBStorage.h:70
 AliCDBStorage.h:71
 AliCDBStorage.h:72
 AliCDBStorage.h:73
 AliCDBStorage.h:74
 AliCDBStorage.h:75
 AliCDBStorage.h:76
 AliCDBStorage.h:77
 AliCDBStorage.h:78
 AliCDBStorage.h:79
 AliCDBStorage.h:80
 AliCDBStorage.h:81
 AliCDBStorage.h:82
 AliCDBStorage.h:83
 AliCDBStorage.h:84
 AliCDBStorage.h:85
 AliCDBStorage.h:86
 AliCDBStorage.h:87
 AliCDBStorage.h:88
 AliCDBStorage.h:89
 AliCDBStorage.h:90
 AliCDBStorage.h:91
 AliCDBStorage.h:92
 AliCDBStorage.h:93
 AliCDBStorage.h:94
 AliCDBStorage.h:95
 AliCDBStorage.h:96
 AliCDBStorage.h:97
 AliCDBStorage.h:98
 AliCDBStorage.h:99
 AliCDBStorage.h:100
 AliCDBStorage.h:101
 AliCDBStorage.h:102
 AliCDBStorage.h:103
 AliCDBStorage.h:104
 AliCDBStorage.h:105
 AliCDBStorage.h:106
 AliCDBStorage.h:107
 AliCDBStorage.h:108
 AliCDBStorage.h:109
 AliCDBStorage.h:110
 AliCDBStorage.h:111
 AliCDBStorage.h:112
 AliCDBStorage.h:113
 AliCDBStorage.h:114
 AliCDBStorage.h:115
 AliCDBStorage.h:116
 AliCDBStorage.h:117
 AliCDBStorage.h:118
 AliCDBStorage.h:119
 AliCDBStorage.h:120
 AliCDBStorage.h:121
 AliCDBStorage.h:122
 AliCDBStorage.h:123
 AliCDBStorage.h:124
 AliCDBStorage.h:125
 AliCDBStorage.h:126
 AliCDBStorage.h:127
 AliCDBStorage.h:128
 AliCDBStorage.h:129
 AliCDBStorage.h:130
 AliCDBStorage.h:131
 AliCDBStorage.h:132
 AliCDBStorage.h:133
 AliCDBStorage.h:134
 AliCDBStorage.h:135
 AliCDBStorage.h:136
 AliCDBStorage.h:137
 AliCDBStorage.h:138