00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TBranchElement
00013 #define ROOT_TBranchElement
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ROOT_TBranch
00025 #include "TBranch.h"
00026 #endif
00027
00028 #ifndef ROOT_TClassRef
00029 #include "TClassRef.h"
00030 #endif
00031
00032 #ifndef ROOT_TTree
00033 #include "TTree.h"
00034 #endif
00035
00036 #ifndef ROOT_TError
00037 #include "TError.h"
00038 #endif
00039
00040 #include <vector>
00041
00042 class TFolder;
00043 class TStreamerInfo;
00044 class TVirtualCollectionProxy;
00045 class TVirtualCollectionIterators;
00046 class TVirtualCollectionPtrIterators;
00047 class TVirtualArray;
00048
00049 namespace TStreamerInfoActions { class TActionSequence; }
00050
00051
00052 class TBranchElement : public TBranch {
00053
00054
00055 friend class TTreeCloner;
00056
00057
00058 protected:
00059 enum {
00060 kBranchFolder = BIT(14),
00061 kDeleteObject = BIT(16),
00062 kCache = BIT(18),
00063 kOwnOnfileObj = BIT(19),
00064 kAddressSet = BIT(20),
00065 kMakeClass = BIT(21),
00066 kDecomposedObj= BIT(21)
00067 };
00068
00069
00070 protected:
00071 TString fClassName;
00072 TString fParentName;
00073 TString fClonesName;
00074 TVirtualCollectionProxy *fCollProxy;
00075 UInt_t fCheckSum;
00076 Int_t fClassVersion;
00077 Int_t fID;
00078 Int_t fType;
00079 Int_t fStreamerType;
00080 Int_t fMaximum;
00081 Int_t fSTLtype;
00082 Int_t fNdata;
00083 TBranchElement *fBranchCount;
00084 TBranchElement *fBranchCount2;
00085 TStreamerInfo *fInfo;
00086 char *fObject;
00087 TVirtualArray *fOnfileObject;
00088 Bool_t fInit;
00089 Bool_t fInitOffsets;
00090 TClassRef fTargetClass;
00091 TClassRef fCurrentClass;
00092 TClassRef fParentClass;
00093 TClassRef fBranchClass;
00094 Int_t *fBranchOffset;
00095 Int_t fBranchID;
00096 std::vector<Int_t> fIDs;
00097 TStreamerInfoActions::TActionSequence *fReadActionSequence;
00098 TVirtualCollectionIterators *fIterators;
00099 TVirtualCollectionPtrIterators *fPtrIterators;
00100
00101
00102 private:
00103 TBranchElement(const TBranchElement&);
00104 TBranchElement& operator=(const TBranchElement&);
00105
00106 static void SwitchContainer(TObjArray *);
00107
00108
00109 protected:
00110 void BuildTitle(const char* name);
00111 virtual void InitializeOffsets();
00112 virtual void InitInfo();
00113 Bool_t IsMissingCollection() const;
00114 TClass *GetCurrentClass();
00115 TClass *GetParentClass();
00116 TStreamerInfo *GetInfoImp() const;
00117 void ReleaseObject();
00118 void SetBranchCount(TBranchElement* bre);
00119 void SetBranchCount2(TBranchElement* bre) { fBranchCount2 = bre; }
00120 Int_t Unroll(const char* name, TClass* cltop, TClass* cl, char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype);
00121 inline void ValidateAddress() const;
00122
00123 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);
00124 void Init(TTree *tree, TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
00125 void Init(TTree *tree, TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
00126
00127 void ReadLeavesImpl(TBuffer& b);
00128 void ReadLeavesMakeClass(TBuffer& b);
00129 void ReadLeavesCollection(TBuffer& b);
00130 void ReadLeavesCollectionSplitPtrMember(TBuffer& b);
00131 void ReadLeavesCollectionSplitVectorPtrMember(TBuffer& b);
00132 void ReadLeavesCollectionMember(TBuffer& b);
00133 void ReadLeavesClones(TBuffer& b);
00134 void ReadLeavesClonesMember(TBuffer& b);
00135 void ReadLeavesCustomStreamer(TBuffer& b);
00136 void ReadLeavesMember(TBuffer& b);
00137 void ReadLeavesMemberBranchCount(TBuffer& b);
00138 void ReadLeavesMemberCounter(TBuffer& b);
00139 void SetReadLeavesPtr();
00140 void SetReadActionSequence();
00141
00142
00143 public:
00144 TBranchElement();
00145 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);
00146 TBranchElement(TTree *tree, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
00147 TBranchElement(TTree *tree, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
00148 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);
00149 TBranchElement(TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
00150 TBranchElement(TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = -1);
00151
00152 virtual ~TBranchElement();
00153
00154 virtual void Browse(TBrowser* b);
00155 virtual Int_t Fill();
00156 virtual void FillLeaves(TBuffer& b);
00157 virtual TBranch *FindBranch(const char *name);
00158 virtual TLeaf *FindLeaf(const char *name);
00159 virtual char *GetAddress() const;
00160 TBranchElement *GetBranchCount() const { return fBranchCount; }
00161 TBranchElement *GetBranchCount2() const { return fBranchCount2; }
00162 Int_t *GetBranchOffset() const { return fBranchOffset; }
00163 UInt_t GetCheckSum() { return fCheckSum; }
00164 virtual const char *GetClassName() const { return fClassName.Data(); }
00165 virtual TClass *GetClass() const { return fBranchClass; }
00166 virtual const char *GetClonesName() const { return fClonesName.Data(); }
00167 TVirtualCollectionProxy *GetCollectionProxy();
00168 virtual Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0);
00169 virtual Int_t GetExpectedType(TClass *&clptr,EDataType &type);
00170 const char *GetIconName() const;
00171 Int_t GetID() const { return fID; }
00172 TStreamerInfo *GetInfo() const;
00173 Bool_t GetMakeClass() const;
00174 char *GetObject() const;
00175 virtual const char *GetParentName() const { return fParentName.Data(); }
00176 virtual Int_t GetMaximum() const;
00177 Int_t GetNdata() const { return fNdata; }
00178 Int_t GetType() const { return fType; }
00179 Int_t GetStreamerType() const { return fStreamerType; }
00180 virtual TClass *GetTargetClass() { return fTargetClass; }
00181 virtual const char *GetTypeName() const;
00182 Double_t GetValue(Int_t i, Int_t len, Bool_t subarr = kFALSE) const;
00183 virtual void *GetValuePointer() const;
00184 Int_t GetClassVersion() { return fClassVersion; }
00185 Bool_t IsBranchFolder() const { return TestBit(kBranchFolder); }
00186 Bool_t IsFolder() const;
00187 virtual Bool_t IsObjectOwner() const { return TestBit(kDeleteObject); }
00188 virtual Bool_t Notify() { if (fAddress) { ResetAddress(); } return 1; }
00189 virtual void Print(Option_t* option = "") const;
00190 void PrintValue(Int_t i) const;
00191 virtual void Reset(Option_t* option = "");
00192 virtual void ResetAddress();
00193 virtual void ResetDeleteObject();
00194 virtual void SetAddress(void* addobj);
00195 virtual Bool_t SetMakeClass(Bool_t decomposeObj = kTRUE);
00196 virtual void SetObject(void *objadd);
00197 virtual void SetBasketSize(Int_t buffsize);
00198 virtual void SetBranchFolder() { SetBit(kBranchFolder); }
00199 virtual void SetClassName(const char* name) { fClassName = name; }
00200 virtual void SetOffset(Int_t offset);
00201 inline void SetParentClass(TClass* clparent);
00202 virtual void SetParentName(const char* name) { fParentName = name; }
00203 virtual void SetTargetClass(const char *name);
00204 virtual void SetupAddresses();
00205 virtual void SetType(Int_t btype) { fType = btype; }
00206 virtual void UpdateFile();
00207
00208 ClassDef(TBranchElement,9)
00209 };
00210
00211 inline void TBranchElement::SetParentClass(TClass* clparent)
00212 {
00213 fParentClass = clparent;
00214 fParentName = clparent ? clparent->GetName() : "";
00215 }
00216
00217 inline void TBranchElement::ValidateAddress() const
00218 {
00219
00220
00221 if (fID < 0) {
00222
00223 if (!fTree->GetMakeClass() && fAddress && (*((char**) fAddress) != fObject)) {
00224
00225
00226
00227
00228
00229
00230 if (TestBit(kDeleteObject)) {
00231
00232 Error("ValidateAddress", "We owned an object whose address changed! our ptr: %p new ptr: %p", fObject, *((char**) fAddress));
00233 const_cast<TBranchElement*>(this)->ResetBit(kDeleteObject);
00234 }
00235 const_cast<TBranchElement*>(this)->SetAddress(fAddress);
00236 }
00237 }
00238 }
00239
00240 #endif // ROOT_TBranchElement