#ifndef ROOT_TTreeReader
#define ROOT_TTreeReader
#ifndef ROOT_THashTable
#include "THashTable.h"
#endif
#ifndef ROOT_TTree
#include "TTree.h"
#endif
#ifndef ROOT_TTreeReaderUtils
#include "TTreeReaderUtils.h"
#endif
#include <deque>
class TDictionary;
class TDirectory;
class TFileCollection;
namespace ROOT {
class TBranchProxyDirector;
}
class TTreeReader: public TObject {
public:
enum EEntryStatus {
kEntryValid = 0,
kEntryNotLoaded,
kEntryNoTree,
kEntryNotFound,
kEntryChainSetupError,
kEntryChainFileError,
kEntryDictionaryError,
};
TTreeReader():
fDirectory(0),
fEntryStatus(kEntryNoTree),
fDirector(0)
{}
TTreeReader(TTree* tree);
TTreeReader(const char* keyname, TDirectory* dir = NULL );
TTreeReader(const char* , TFileCollection* ) { Error("TTreeReader()", "Not Implemented!");};
~TTreeReader();
void SetTree(TTree* tree);
void SetTree(const char* , TDirectory* ) { Error("SetTree()", "Not Implemented!");};
void SetChain(const char* , TFileCollection* ) { Error("SetChain()", "Not Implemented!");};
Bool_t IsChain() const { return TestBit(kBitIsChain); }
Bool_t Next() { return SetEntry(GetCurrentEntry() + 1) == kEntryValid; }
EEntryStatus SetEntry(Long64_t entry) { return SetEntryBase(entry, kFALSE); }
EEntryStatus SetLocalEntry(Long64_t entry) { return SetEntryBase(entry, kTRUE); }
EEntryStatus GetEntryStatus() const { return fEntryStatus; }
TTree* GetTree() const { return fTree; }
Long64_t GetEntries(Bool_t force) const { return fTree ? (force ? fTree->GetEntries() : fTree->GetEntriesFast() ) : -1; }
Long64_t GetCurrentEntry() const;
protected:
void Initialize();
ROOT::TNamedBranchProxy* FindProxy(const char* branchname) const {
return (ROOT::TNamedBranchProxy*) fProxies.FindObject(branchname); }
TCollection* GetProxies() { return &fProxies; }
void RegisterValueReader(ROOT::TTreeReaderValueBase* reader);
void DeregisterValueReader(ROOT::TTreeReaderValueBase* reader);
EEntryStatus SetEntryBase(Long64_t entry, Bool_t local);
private:
enum EPropertyBits {
kBitIsChain = BIT(14)
};
TTree* fTree;
TDirectory* fDirectory;
EEntryStatus fEntryStatus;
ROOT::TBranchProxyDirector* fDirector;
std::deque<ROOT::TTreeReaderValueBase*> fValues;
THashTable fProxies;
friend class ROOT::TTreeReaderValueBase;
friend class ROOT::TTreeReaderArrayBase;
ClassDef(TTreeReader, 0);
};
#endif // defined TTreeReader