#ifndef ROOT_TBranchElement
#define ROOT_TBranchElement
#ifndef ROOT_TBranch
#include "TBranch.h"
#endif
#ifndef ROOT_TClassRef
#include "TClassRef.h"
#endif
#ifndef ROOT_TTree
#include "TTree.h"
#endif
#ifndef ROOT_TError
#include "TError.h"
#endif
#include <vector>
class TFolder;
class TStreamerInfo;
class TVirtualCollectionProxy;
class TVirtualCollectionIterators;
class TVirtualCollectionPtrIterators;
class TVirtualArray;
namespace TStreamerInfoActions { class TActionSequence; }
class TBranchElement : public TBranch {
friend class TTreeCloner;
protected:
enum {
kBranchFolder = BIT(14),
kDeleteObject = BIT(16),
kCache = BIT(18),
kOwnOnfileObj = BIT(19),
kAddressSet = BIT(20),
kMakeClass = BIT(21),
kDecomposedObj= BIT(21)
};
protected:
TString fClassName;
TString fParentName;
TString fClonesName;
TVirtualCollectionProxy *fCollProxy;
UInt_t fCheckSum;
Int_t fClassVersion;
Int_t fID;
Int_t fType;
Int_t fStreamerType;
Int_t fMaximum;
Int_t fSTLtype;
Int_t fNdata;
TBranchElement *fBranchCount;
TBranchElement *fBranchCount2;
TStreamerInfo *fInfo;
char *fObject;
TVirtualArray *fOnfileObject;
Bool_t fInit;
Bool_t fInitOffsets;
TClassRef fTargetClass;
TClassRef fCurrentClass;
TClassRef fParentClass;
TClassRef fBranchClass;
TClassRef fClonesClass;
Int_t *fBranchOffset;
Int_t fBranchID;
std::vector<Int_t> fIDs;
TStreamerInfoActions::TActionSequence *fReadActionSequence;
TStreamerInfoActions::TActionSequence *fFillActionSequence;
TVirtualCollectionIterators *fIterators;
TVirtualCollectionIterators *fWriteIterators;
TVirtualCollectionPtrIterators *fPtrIterators;
private:
TBranchElement(const TBranchElement&);
TBranchElement& operator=(const TBranchElement&);
static void SwitchContainer(TObjArray *);
protected:
void BuildTitle(const char* name);
virtual void InitializeOffsets();
virtual void InitInfo();
Bool_t IsMissingCollection() const;
TClass *GetParentClass();
TStreamerInfo *GetInfoImp() const;
void ReleaseObject();
void SetBranchCount(TBranchElement* bre);
void SetBranchCount2(TBranchElement* bre) { fBranchCount2 = bre; }
Int_t Unroll(const char* name, TClass* cltop, TClass* cl, char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype);
inline void ValidateAddress() const;
void Init(TTree *tree, TBranch *parent, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0);
void Init(TTree *tree, TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
void Init(TTree *tree, TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
void ReadLeavesImpl(TBuffer& b);
void ReadLeavesMakeClass(TBuffer& b);
void ReadLeavesCollection(TBuffer& b);
void ReadLeavesCollectionSplitPtrMember(TBuffer& b);
void ReadLeavesCollectionSplitVectorPtrMember(TBuffer& b);
void ReadLeavesCollectionMember(TBuffer& b);
void ReadLeavesClones(TBuffer& b);
void ReadLeavesClonesMember(TBuffer& b);
void ReadLeavesCustomStreamer(TBuffer& b);
void ReadLeavesMember(TBuffer& b);
void ReadLeavesMemberBranchCount(TBuffer& b);
void ReadLeavesMemberCounter(TBuffer& b);
void SetReadLeavesPtr();
void SetReadActionSequence();
void SetupAddressesImpl();
void FillLeavesImpl(TBuffer& b);
void FillLeavesMakeClass(TBuffer& b);
void FillLeavesCollection(TBuffer& b);
void FillLeavesCollectionSplitVectorPtrMember(TBuffer& b);
void FillLeavesCollectionSplitPtrMember(TBuffer& b);
void FillLeavesCollectionMember(TBuffer& b);
void FillLeavesAssociativeCollectionMember(TBuffer& b);
void FillLeavesClones(TBuffer& b);
void FillLeavesClonesMember(TBuffer& b);
void FillLeavesCustomStreamer(TBuffer& b);
void FillLeavesMemberBranchCount(TBuffer& b);
void FillLeavesMemberCounter(TBuffer& b);
void FillLeavesMember(TBuffer& b);
void SetFillLeavesPtr();
void SetFillActionSequence();
public:
TBranchElement();
TBranchElement(TTree *tree, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0);
TBranchElement(TTree *tree, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
TBranchElement(TTree *tree, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
TBranchElement(TBranch *parent, const char* name, TStreamerInfo* sinfo, Int_t id, char* pointer, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t btype = 0);
TBranchElement(TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
TBranchElement(TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
virtual ~TBranchElement();
virtual void Browse(TBrowser* b);
virtual Int_t Fill();
virtual TBranch *FindBranch(const char *name);
virtual TLeaf *FindLeaf(const char *name);
virtual char *GetAddress() const;
TBranchElement *GetBranchCount() const { return fBranchCount; }
TBranchElement *GetBranchCount2() const { return fBranchCount2; }
Int_t *GetBranchOffset() const { return fBranchOffset; }
UInt_t GetCheckSum() { return fCheckSum; }
virtual const char *GetClassName() const { return fClassName.Data(); }
virtual TClass *GetClass() const { return fBranchClass; }
virtual const char *GetClonesName() const { return fClonesName.Data(); }
TVirtualCollectionProxy *GetCollectionProxy();
TClass *GetCurrentClass();
virtual Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0);
virtual Int_t GetExpectedType(TClass *&clptr,EDataType &type);
const char *GetIconName() const;
Int_t GetID() const { return fID; }
TStreamerInfo *GetInfo() const;
Bool_t GetMakeClass() const;
char *GetObject() const;
virtual const char *GetParentName() const { return fParentName.Data(); }
virtual Int_t GetMaximum() const;
Int_t GetNdata() const { return fNdata; }
Int_t GetType() const { return fType; }
Int_t GetStreamerType() const { return fStreamerType; }
virtual TClass *GetTargetClass() { return fTargetClass; }
virtual const char *GetTypeName() const;
Double_t GetValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const { return GetTypedValue<Double_t>(i, len, subarr); }
template<typename T > T GetTypedValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const;
virtual void *GetValuePointer() const;
Int_t GetClassVersion() { return fClassVersion; }
Bool_t IsBranchFolder() const { return TestBit(kBranchFolder); }
Bool_t IsFolder() const;
virtual Bool_t IsObjectOwner() const { return TestBit(kDeleteObject); }
virtual Bool_t Notify() { if (fAddress) { ResetAddress(); } return 1; }
virtual void Print(Option_t* option = "") const;
void PrintValue(Int_t i) const;
virtual void Reset(Option_t* option = "");
virtual void ResetAfterMerge(TFileMergeInfo *);
virtual void ResetAddress();
virtual void ResetDeleteObject();
virtual void SetAddress(void* addobj);
virtual Bool_t SetMakeClass(Bool_t decomposeObj = kTRUE);
virtual void SetObject(void *objadd);
virtual void SetBasketSize(Int_t buffsize);
virtual void SetBranchFolder() { SetBit(kBranchFolder); }
virtual void SetClassName(const char* name) { fClassName = name; }
virtual void SetOffset(Int_t offset);
inline void SetParentClass(TClass* clparent);
virtual void SetParentName(const char* name) { fParentName = name; }
virtual void SetTargetClass(const char *name);
virtual void SetupAddresses();
virtual void SetType(Int_t btype) { fType = btype; }
virtual void UpdateFile();
enum EBranchElementType {
kLeafNode = 0,
kBaseClassNode = 1,
kObjectNode = 2,
kClonesNode = 3,
kSTLNode = 4,
kClonesMemberNode = 31,
kSTLMemberNode = 41
};
ClassDef(TBranchElement,9)
};
inline void TBranchElement::SetParentClass(TClass* clparent)
{
fParentClass = clparent;
fParentName = clparent ? clparent->GetName() : "";
}
inline void TBranchElement::ValidateAddress() const
{
if (fID < 0) {
if (!fTree->GetMakeClass() && fAddress && (*((char**) fAddress) != fObject)) {
if (TestBit(kDeleteObject)) {
Error("ValidateAddress", "We owned an object whose address changed! our ptr: %p new ptr: %p", fObject, *((char**) fAddress));
const_cast<TBranchElement*>(this)->ResetBit(kDeleteObject);
}
const_cast<TBranchElement*>(this)->SetAddress(fAddress);
}
}
}
#endif // ROOT_TBranchElement