#ifndef ROOT_TBranchProxy
#define ROOT_TBranchProxy
#ifndef ROOT_TBranchProxyDirector
#include "TBranchProxyDirector.h"
#endif
#ifndef ROOT_TTree
#include "TTree.h"
#endif
#ifndef ROOT_TBranch
#include "TBranch.h"
#endif
#ifndef ROOT_TClonesArray
#include "TClonesArray.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_Riostream
#include "Riostream.h"
#endif
#ifndef ROOT_TError
#include "TError.h"
#endif
#ifndef ROOT_TVirtualCollectionProxy
#include "TVirtualCollectionProxy.h"
#endif
#include <list>
#include <algorithm>
class TBranch;
class TStreamerElement;
namespace ROOT {
class TBranchProxyHelper {
public:
TString fName;
TBranchProxyHelper(const char *left,const char *right = 0) :
fName() {
if (left) {
fName = left;
if (strlen(left)&&right && fName[fName.Length()-1]!='.') fName += ".";
}
if (right) {
fName += right;
}
}
operator const char*() { return fName.Data(); };
};
class TBranchProxy {
protected:
TBranchProxyDirector *fDirector;
Bool_t fInitialized;
const TString fBranchName;
TBranchProxy *fParent;
const TString fDataMember;
const Bool_t fIsMember;
Bool_t fIsClone;
Bool_t fIsaPointer;
TString fClassName;
TClass *fClass;
TStreamerElement *fElement;
Int_t fMemberOffset;
Int_t fOffset;
TBranch *fBranch;
TBranch *fBranchCount;
TTree *fLastTree;
Long64_t fRead;
void *fWhere;
TVirtualCollectionProxy *fCollection;
public:
virtual void Print();
TBranchProxy();
TBranchProxy(TBranchProxyDirector* boss, const char* top, const char* name = 0);
TBranchProxy(TBranchProxyDirector* boss, const char *top, const char *name, const char *membername);
TBranchProxy(TBranchProxyDirector* boss, TBranchProxy *parent, const char* membername, const char* top = 0, const char* name = 0);
virtual ~TBranchProxy();
TBranchProxy* GetProxy() { return this; }
void Reset();
Bool_t Setup();
Bool_t IsInitialized() {
return (fLastTree == fDirector->GetTree()) && (fLastTree);
}
Bool_t IsaPointer() const {
return fIsaPointer;
}
Bool_t Read() {
if (fDirector==0) return false;
if (fDirector->GetReadEntry()!=fRead) {
if (!IsInitialized()) {
if (!Setup()) {
Error("Read",Form("Unable to initialize %s\n",fBranchName.Data()));
return false;
}
}
if (fParent) fParent->Read();
else {
if (fBranchCount) {
fBranchCount->GetEntry(fDirector->GetReadEntry());
}
fBranch->GetEntry(fDirector->GetReadEntry());
}
fRead = fDirector->GetReadEntry();
}
return IsInitialized();
}
Bool_t ReadEntries() {
if (fDirector==0) return false;
if (fDirector->GetReadEntry()!=fRead) {
if (!IsInitialized()) {
if (!Setup()) {
Error("Read",Form("Unable to initialize %s\n",fBranchName.Data()));
return false;
}
}
if (fParent) fParent->ReadEntries();
else {
if (fBranchCount) {
fBranchCount->TBranch::GetEntry(fDirector->GetReadEntry());
}
fBranch->TBranch::GetEntry(fDirector->GetReadEntry());
}
}
return IsInitialized();
}
TClass *GetClass() {
if (fDirector==0) return 0;
if (fDirector->GetReadEntry()!=fRead) {
if (!IsInitialized()) {
if (!Setup()) {
return 0;
}
}
}
return fClass;
}
void* GetWhere() const { return fWhere; }
TVirtualCollectionProxy *GetCollection() { return fCollection; }
virtual void *GetStart(UInt_t =0) {
if (fParent) {
fWhere = ((unsigned char*)fParent->GetStart()) + fMemberOffset;
}
if (IsaPointer()) {
if (fWhere) return *(void**)fWhere;
else return 0;
} else {
return fWhere;
}
}
virtual void *GetClaStart(UInt_t i=0) {
char *location;
if (fIsClone) {
TClonesArray *tca;
tca = (TClonesArray*)GetStart();
if (tca->GetLast()<(Int_t)i) return 0;
location = (char*)tca->At(i);
return location;
} else if (fParent) {
location = (char*)fParent->GetClaStart(i);
} else {
void *tcaloc;
tcaloc = fWhere;
TClonesArray *tca;
tca = (TClonesArray*)tcaloc;
if (tca->GetLast()<(Int_t)i) return 0;
location = (char*)tca->At(i);
}
if (location) location += fOffset;
else return 0;
if (IsaPointer()) {
return *(void**)(location);
} else {
return location;
}
}
virtual void *GetStlStart(UInt_t i=0) {
char *location=0;
if (fCollection) {
if (fCollection->Size()<i) return 0;
location = (char*)fCollection->At(i);
} else if (fParent) {
location = (char*)fParent->GetStlStart(i);
} else {
R__ASSERT(0);
}
if (location) location += fOffset;
else return 0;
if (IsaPointer()) {
return *(void**)(location);
} else {
return location;
}
}
};
class TArrayCharProxy : public TBranchProxy {
public:
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) cout << "value? " << *(unsigned char*)GetStart() << endl;
}
TArrayCharProxy() : TBranchProxy() {}
TArrayCharProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TArrayCharProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TArrayCharProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TArrayCharProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TArrayCharProxy() {};
unsigned char At(UInt_t i) {
static unsigned char default_val;
if (!Read()) return default_val;
unsigned char* str = (unsigned char*)GetStart();
return str[i];
}
unsigned char operator [](Int_t i) {
return At(i);
}
unsigned char operator [](UInt_t i) {
return At(i);
}
const char* c_str() {
if (!Read()) return "";
return (const char*)GetStart();
}
operator std::string() {
if (!Read()) return "";
return std::string((const char*)GetStart());
}
};
class TClaProxy : public TBranchProxy {
public:
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) {
if (IsaPointer()) {
cout << "location " << *(TClonesArray**)fWhere << endl;
} else {
cout << "location " << fWhere << endl;
}
}
}
TClaProxy() : TBranchProxy() {}
TClaProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TClaProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TClaProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TClaProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TClaProxy() {};
const TClonesArray* GetPtr() {
if (!Read()) return 0;
return (TClonesArray*)GetStart();
}
Int_t GetEntries() {
if (!ReadEntries()) return 0;
TClonesArray *arr = (TClonesArray*)GetStart();
if (arr) return arr->GetEntries();
return 0;
}
const TClonesArray* operator->() { return GetPtr(); }
};
class TStlProxy : public TBranchProxy {
public:
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) {
if (IsaPointer()) {
cout << "location " << *(TClonesArray**)fWhere << endl;
} else {
cout << "location " << fWhere << endl;
}
}
}
TStlProxy() : TBranchProxy() {}
TStlProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TStlProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TStlProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TStlProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TStlProxy() {};
const TVirtualCollectionProxy* GetPtr() {
if (!Read()) return 0;
return GetCollection();;
}
Int_t GetEntries() {
if (!ReadEntries()) return 0;
return GetPtr()->Size();
}
const TVirtualCollectionProxy* operator->() { return GetPtr(); }
};
template <class T>
class TImpProxy : public TBranchProxy {
public:
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) cout << "value? " << *(T*)GetStart() << endl;
}
TImpProxy() : TBranchProxy() {};
TImpProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TImpProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TImpProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TImpProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TImpProxy() {};
operator T() {
if (!Read()) return 0;
return *(T*)GetStart();
}
#ifdef private
#undef private
#define private_was_replaced
#endif
private:
TImpProxy(T);
TImpProxy &operator=(T);
#ifdef private_was_replaced
#define private public
#endif
};
template <class T, int d = 0> struct TArrayType {
typedef T type_t;
typedef T array_t[d];
};
template <class T> struct TArrayType<T,0> {
typedef T type_t;
typedef T array_t;
};
template <class T, int d> struct TMultiArrayType {
typedef typename T::type_t type_t;
typedef typename T::array_t array_t[d];
};
template <class T>
class TArrayProxy : public TBranchProxy {
public:
TArrayProxy() : TBranchProxy() {}
TArrayProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TArrayProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TArrayProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TArrayProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TArrayProxy() {};
typedef typename T::array_t array_t;
typedef typename T::type_t type_t;
void Print() {
TBranchProxy::Print();
cout << "fWhere " << GetWhere() << endl;
if (GetWhere()) cout << "value? " << *(type_t*)GetWhere() << endl;
}
const array_t &At(UInt_t i) {
static array_t default_val;
if (!Read()) return default_val;
array_t *arr = 0;
arr = (array_t*)((type_t*)(GetStart()));
if (arr) return arr[i];
else return default_val;
}
const array_t &operator [](Int_t i) { return At(i); }
const array_t &operator [](UInt_t i) { return At(i); }
};
template <class T>
class TClaImpProxy : public TBranchProxy {
public:
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) cout << "value? " << *(T*)GetStart() << endl;
}
TClaImpProxy() : TBranchProxy() {};
TClaImpProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TClaImpProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TClaImpProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TClaImpProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TClaImpProxy() {};
const T& At(UInt_t i) {
static T default_val;
if (!Read()) return default_val;
if (fWhere==0) return default_val;
T *temp = (T*)GetClaStart(i);
if (temp) return *temp;
else return default_val;
}
const T& operator [](Int_t i) { return At(i); }
const T& operator [](UInt_t i) { return At(i); }
#ifdef private
#undef private
#define private_was_replaced
#endif
private:
TClaImpProxy(T);
TClaImpProxy &operator=(T);
#ifdef private_was_replaced
#define private public
#endif
};
template <class T>
class TStlImpProxy : public TBranchProxy {
public:
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) cout << "value? " << *(T*)GetStart() << endl;
}
TStlImpProxy() : TBranchProxy() {};
TStlImpProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TStlImpProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TStlImpProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TStlImpProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TStlImpProxy() {};
const T& At(UInt_t i) {
static T default_val;
if (!Read()) return default_val;
if (fWhere==0) return default_val;
T *temp = (T*)GetStlStart(i);
if (temp) return *temp;
else return default_val;
}
const T& operator [](Int_t i) { return At(i); }
const T& operator [](UInt_t i) { return At(i); }
#ifdef private
#undef private
#define private_was_replaced
#endif
private:
TStlImpProxy(T);
TStlImpProxy &operator=(T);
#ifdef private_was_replaced
#define private public
#endif
};
template <class T>
class TClaArrayProxy : public TBranchProxy {
public:
typedef typename T::array_t array_t;
typedef typename T::type_t type_t;
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) cout << "value? " << *(type_t*)GetStart() << endl;
}
TClaArrayProxy() : TBranchProxy() {}
TClaArrayProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TClaArrayProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TClaArrayProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TClaArrayProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TClaArrayProxy() {};
array_t *At(UInt_t i) {
static array_t default_val;
if (!Read()) return &default_val;
if (fWhere==0) return &default_val;
return (array_t*)GetClaStart(i);
}
array_t *operator [](Int_t i) { return At(i); }
array_t *operator [](UInt_t i) { return At(i); }
};
template <class T>
class TStlArrayProxy : public TBranchProxy {
public:
typedef typename T::array_t array_t;
typedef typename T::type_t type_t;
void Print() {
TBranchProxy::Print();
cout << "fWhere " << fWhere << endl;
if (fWhere) cout << "value? " << *(type_t*)GetStart() << endl;
}
TStlArrayProxy() : TBranchProxy() {}
TStlArrayProxy(TBranchProxyDirector *director, const char *name) : TBranchProxy(director,name) {};
TStlArrayProxy(TBranchProxyDirector *director, const char *top, const char *name) :
TBranchProxy(director,top,name) {};
TStlArrayProxy(TBranchProxyDirector *director, const char *top, const char *name, const char *data) :
TBranchProxy(director,top,name,data) {};
TStlArrayProxy(TBranchProxyDirector *director, TBranchProxy *parent, const char *name, const char* top = 0, const char* mid = 0) :
TBranchProxy(director,parent, name, top, mid) {};
~TStlArrayProxy() {};
array_t *At(UInt_t i) {
static array_t default_val;
if (!Read()) return &default_val;
if (fWhere==0) return &default_val;
return (array_t*)GetStlStart(i);
}
array_t *operator [](Int_t i) { return At(i); }
array_t *operator [](UInt_t i) { return At(i); }
};
typedef TImpProxy<Double_t> TDoubleProxy;
typedef TImpProxy<Double32_t> TDouble32Proxy;
typedef TImpProxy<Float_t> TFloatProxy;
typedef TImpProxy<Float16_t> TFloat16Proxy;
typedef TImpProxy<UInt_t> TUIntProxy;
typedef TImpProxy<ULong_t> TULongProxy;
typedef TImpProxy<ULong64_t> TULong64Proxy;
typedef TImpProxy<UShort_t> TUShortProxy;
typedef TImpProxy<UChar_t> TUCharProxy;
typedef TImpProxy<Int_t> TIntProxy;
typedef TImpProxy<Long_t> TLongProxy;
typedef TImpProxy<Long64_t> TLong64Proxy;
typedef TImpProxy<Short_t> TShortProxy;
typedef TImpProxy<Char_t> TCharProxy;
typedef TImpProxy<Bool_t> TBoolProxy;
typedef TArrayProxy<TArrayType<Double_t> > TArrayDoubleProxy;
typedef TArrayProxy<TArrayType<Double32_t> > TArrayDouble32Proxy;
typedef TArrayProxy<TArrayType<Float_t> > TArrayFloatProxy;
typedef TArrayProxy<TArrayType<Float16_t> > TArrayFloat16Proxy;
typedef TArrayProxy<TArrayType<UInt_t> > TArrayUIntProxy;
typedef TArrayProxy<TArrayType<ULong_t> > TArrayULongProxy;
typedef TArrayProxy<TArrayType<ULong64_t> > TArrayULong64Proxy;
typedef TArrayProxy<TArrayType<UShort_t> > TArrayUShortProxy;
typedef TArrayProxy<TArrayType<UChar_t> > TArrayUCharProxy;
typedef TArrayProxy<TArrayType<Int_t> > TArrayIntProxy;
typedef TArrayProxy<TArrayType<Long_t> > TArrayLongProxy;
typedef TArrayProxy<TArrayType<Long64_t> > TArrayLong64Proxy;
typedef TArrayProxy<TArrayType<UShort_t> > TArrayShortProxy;
typedef TArrayProxy<TArrayType<Bool_t> > TArrayBoolProxy;
typedef TClaImpProxy<Double_t> TClaDoubleProxy;
typedef TClaImpProxy<Double32_t> TClaDouble32Proxy;
typedef TClaImpProxy<Float_t> TClaFloatProxy;
typedef TClaImpProxy<Float16_t> TClaFloat16Proxy;
typedef TClaImpProxy<UInt_t> TClaUIntProxy;
typedef TClaImpProxy<ULong_t> TClaULongProxy;
typedef TClaImpProxy<ULong64_t> TClaULong64Proxy;
typedef TClaImpProxy<UShort_t> TClaUShortProxy;
typedef TClaImpProxy<UChar_t> TClaUCharProxy;
typedef TClaImpProxy<Int_t> TClaIntProxy;
typedef TClaImpProxy<Long_t> TClaLongProxy;
typedef TClaImpProxy<Long64_t> TClaLong64Proxy;
typedef TClaImpProxy<Short_t> TClaShortProxy;
typedef TClaImpProxy<Char_t> TClaCharProxy;
typedef TClaImpProxy<Bool_t> TClaBoolProxy;
typedef TClaArrayProxy<TArrayType<Double_t> > TClaArrayDoubleProxy;
typedef TClaArrayProxy<TArrayType<Double32_t> > TClaArrayDouble32Proxy;
typedef TClaArrayProxy<TArrayType<Float_t> > TClaArrayFloatProxy;
typedef TClaArrayProxy<TArrayType<Float16_t> > TClaArrayFloat16Proxy;
typedef TClaArrayProxy<TArrayType<UInt_t> > TClaArrayUIntProxy;
typedef TClaArrayProxy<TArrayType<ULong_t> > TClaArrayULongProxy;
typedef TClaArrayProxy<TArrayType<ULong64_t> > TClaArrayULong64Proxy;
typedef TClaArrayProxy<TArrayType<UShort_t> > TClaArrayUShortProxy;
typedef TClaArrayProxy<TArrayType<UChar_t> > TClaArrayUCharProxy;
typedef TClaArrayProxy<TArrayType<Int_t> > TClaArrayIntProxy;
typedef TClaArrayProxy<TArrayType<Long_t> > TClaArrayLongProxy;
typedef TClaArrayProxy<TArrayType<Long64_t> > TClaArrayLong64Proxy;
typedef TClaArrayProxy<TArrayType<UShort_t> > TClaArrayShortProxy;
typedef TClaArrayProxy<TArrayType<Char_t> > TClaArrayCharProxy;
typedef TClaArrayProxy<TArrayType<Bool_t> > TClaArrayBoolProxy;
typedef TStlImpProxy<Double_t> TStlDoubleProxy;
typedef TStlImpProxy<Double32_t> TStlDouble32Proxy;
typedef TStlImpProxy<Float_t> TStlFloatProxy;
typedef TStlImpProxy<Float16_t> TStlFloat16Proxy;
typedef TStlImpProxy<UInt_t> TStlUIntProxy;
typedef TStlImpProxy<ULong_t> TStlULongProxy;
typedef TStlImpProxy<ULong64_t> TStlULong64Proxy;
typedef TStlImpProxy<UShort_t> TStlUShortProxy;
typedef TStlImpProxy<UChar_t> TStlUCharProxy;
typedef TStlImpProxy<Int_t> TStlIntProxy;
typedef TStlImpProxy<Long_t> TStlLongProxy;
typedef TStlImpProxy<Long64_t> TStlLong64Proxy;
typedef TStlImpProxy<Short_t> TStlShortProxy;
typedef TStlImpProxy<Char_t> TStlCharProxy;
typedef TStlImpProxy<Bool_t> TStlBoolProxy;
typedef TStlArrayProxy<TArrayType<Double_t> > TStlArrayDoubleProxy;
typedef TStlArrayProxy<TArrayType<Double32_t> > TStlArrayDouble32Proxy;
typedef TStlArrayProxy<TArrayType<Float_t> > TStlArrayFloatProxy;
typedef TStlArrayProxy<TArrayType<Float16_t> > TStlArrayFloat16Proxy;
typedef TStlArrayProxy<TArrayType<UInt_t> > TStlArrayUIntProxy;
typedef TStlArrayProxy<TArrayType<ULong_t> > TStlArrayULongProxy;
typedef TStlArrayProxy<TArrayType<ULong64_t> > TStlArrayULong64Proxy;
typedef TStlArrayProxy<TArrayType<UShort_t> > TStlArrayUShortProxy;
typedef TStlArrayProxy<TArrayType<UChar_t> > TStlArrayUCharProxy;
typedef TStlArrayProxy<TArrayType<Int_t> > TStlArrayIntProxy;
typedef TStlArrayProxy<TArrayType<Long_t> > TStlArrayLongProxy;
typedef TStlArrayProxy<TArrayType<Long64_t> > TStlArrayLong64Proxy;
typedef TStlArrayProxy<TArrayType<UShort_t> > TStlArrayShortProxy;
typedef TStlArrayProxy<TArrayType<Char_t> > TStlArrayCharProxy;
typedef TStlArrayProxy<TArrayType<Bool_t> > TStlArrayBoolProxy;
}
#endif
Last change: Wed Jun 25 08:31:08 2008
Last generated: 2008-06-25 08:31
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.