Warning, file /include/root/TBranchElement.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TBranchElement
0013 #define ROOT_TBranchElement
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "TBranch.h"
0025
0026 #include "TClassRef.h"
0027
0028 #include "TTree.h"
0029
0030 class TFolder;
0031 class TStreamerInfo;
0032 class TVirtualCollectionProxy;
0033 class TVirtualCollectionIterators;
0034 class TVirtualCollectionPtrIterators;
0035 class TVirtualArray;
0036
0037 #include "TStreamerInfoActions.h"
0038
0039 class TBranchElement : public TBranch {
0040
0041
0042 friend class TTreeCloner;
0043 friend class TLeafElement;
0044
0045
0046 protected:
0047 enum EStatusBits {
0048 kBranchFolder = BIT(14),
0049 kDeleteObject = BIT(16),
0050 kCache = BIT(18),
0051 kOwnOnfileObj = BIT(19),
0052 kAddressSet = BIT(20),
0053 kMakeClass = BIT(21),
0054 kDecomposedObj = BIT(21)
0055 };
0056
0057
0058
0059 protected:
0060 TString fClassName;
0061 TString fParentName;
0062 TString fClonesName;
0063 TVirtualCollectionProxy *fCollProxy;
0064 UInt_t fCheckSum;
0065 Version_t fClassVersion;
0066 Int_t fID;
0067 Int_t fType;
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 Int_t fStreamerType;
0080 Int_t fMaximum;
0081 Int_t fSTLtype;
0082 Int_t fNdata;
0083 TBranchElement *fBranchCount;
0084 TBranchElement *fBranchCount2;
0085 TStreamerInfo *fInfo;
0086 char *fObject;
0087 TVirtualArray *fOnfileObject;
0088 bool fInit : 1;
0089 bool fInInitInfo : 1;
0090 bool fInitOffsets: 1;
0091 TClassRef fTargetClass;
0092 TClassRef fCurrentClass;
0093 TClassRef fParentClass;
0094 TClassRef fBranchClass;
0095 TClassRef fClonesClass;
0096 Int_t *fBranchOffset;
0097 Int_t fBranchID;
0098 TStreamerInfoActions::TIDs fNewIDs;
0099 TStreamerInfoActions::TActionSequence *fReadActionSequence;
0100 TStreamerInfoActions::TActionSequence *fFillActionSequence;
0101 TVirtualCollectionIterators *fIterators;
0102 TVirtualCollectionIterators *fWriteIterators;
0103 TVirtualCollectionPtrIterators *fPtrIterators;
0104
0105
0106 private:
0107 TBranchElement(const TBranchElement&) = delete;
0108 TBranchElement& operator=(const TBranchElement&) = delete;
0109
0110 static void SwitchContainer(TObjArray *);
0111
0112
0113 protected:
0114 void BuildTitle(const char* name);
0115 virtual void InitializeOffsets();
0116 virtual void InitInfo();
0117 bool IsMissingCollection() const;
0118 TStreamerInfo *FindOnfileInfo(TClass *valueClass, const TObjArray &branches) const;
0119 TClass *GetParentClass();
0120 TStreamerInfo *GetInfoImp() const;
0121 void ReleaseObject();
0122 void SetupInfo();
0123 void SetBranchCount(TBranchElement* bre);
0124 void SetBranchCount2(TBranchElement* bre) { fBranchCount2 = bre; }
0125 Int_t Unroll(const char* name, TClass* cltop, TClass* cl, char* ptr, Int_t basketsize, Int_t splitlevel, Int_t btype);
0126 inline void ValidateAddress() const;
0127
0128 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);
0129 void Init(TTree *tree, TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit);
0130 void Init(TTree *tree, TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit);
0131
0132 void SetActionSequence(TClass *originalClass, TStreamerInfo *localInfo, TStreamerInfoActions::TActionSequence::SequenceGetter_t create, TStreamerInfoActions::TActionSequence *&actionSequence);
0133 void ReadLeavesImpl(TBuffer& b);
0134 void ReadLeavesMakeClass(TBuffer& b);
0135 void ReadLeavesCollection(TBuffer& b);
0136 void ReadLeavesCollectionSplitPtrMember(TBuffer& b);
0137 void ReadLeavesCollectionSplitVectorPtrMember(TBuffer& b);
0138 void ReadLeavesCollectionMember(TBuffer& b);
0139 void ReadLeavesClones(TBuffer& b);
0140 void ReadLeavesClonesMember(TBuffer& b);
0141 void ReadLeavesCustomStreamer(TBuffer& b);
0142 void ReadLeavesMember(TBuffer& b);
0143 void ReadLeavesMemberBranchCount(TBuffer& b);
0144 void ReadLeavesMemberCounter(TBuffer& b);
0145 void SetReadLeavesPtr();
0146 void SetReadActionSequence();
0147 void SetupAddressesImpl();
0148 void SetAddressImpl(void *addr, bool implied) override;
0149
0150 void FillLeavesImpl(TBuffer& b);
0151 void FillLeavesMakeClass(TBuffer& b);
0152 void FillLeavesCollection(TBuffer& b);
0153 void FillLeavesCollectionSplitVectorPtrMember(TBuffer& b);
0154 void FillLeavesCollectionSplitPtrMember(TBuffer& b);
0155 void FillLeavesCollectionMember(TBuffer& b);
0156 void FillLeavesAssociativeCollectionMember(TBuffer& b);
0157 void FillLeavesClones(TBuffer& b);
0158 void FillLeavesClonesMember(TBuffer& b);
0159 void FillLeavesCustomStreamer(TBuffer& b);
0160 void FillLeavesMemberBranchCount(TBuffer& b);
0161 void FillLeavesMemberCounter(TBuffer& b);
0162 void FillLeavesMember(TBuffer& b);
0163 void SetFillLeavesPtr();
0164 void SetFillActionSequence();
0165
0166
0167 public:
0168 TBranchElement();
0169 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);
0170 TBranchElement(TTree *tree, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit);
0171 TBranchElement(TTree *tree, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit);
0172 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);
0173 TBranchElement(TBranch *parent, const char* name, TClonesArray* clones, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit);
0174 TBranchElement(TBranch *parent, const char* name, TVirtualCollectionProxy* cont, Int_t basketsize = 32000, Int_t splitlevel = 0, Int_t compress = ROOT::RCompressionSetting::EAlgorithm::kInherit);
0175
0176 ~TBranchElement() override;
0177
0178 void Browse(TBrowser* b) override;
0179 TBranch *FindBranch(const char *name) override;
0180 TLeaf *FindLeaf(const char *name) override;
0181 char *GetAddress() const override;
0182 TBranchElement *GetBranchCount() const { return fBranchCount; }
0183 TBranchElement *GetBranchCount2() const { return fBranchCount2; }
0184 Int_t *GetBranchOffset() const { return fBranchOffset; }
0185 UInt_t GetCheckSum() { return fCheckSum; }
0186 const char *GetClassName() const override { return fClassName.Data(); }
0187 virtual TClass *GetClass() const { return fBranchClass; }
0188 virtual const char *GetClonesName() const { return fClonesName.Data(); }
0189 TVirtualCollectionProxy *GetCollectionProxy();
0190 TClass *GetCurrentClass();
0191 Int_t GetEntry(Long64_t entry = 0, Int_t getall = 0) override;
0192 Int_t GetExpectedType(TClass *&clptr,EDataType &type) override;
0193 TString GetFullName() const override;
0194 const char *GetIconName() const override;
0195 Int_t GetID() const { return fID; }
0196 TStreamerInfo *GetInfo() const;
0197 bool GetMakeClass() const override;
0198 char *GetObject() const;
0199 TVirtualArray *GetOnfileObject() const { return fOnfileObject; }
0200 virtual const char *GetParentName() const { return fParentName.Data(); }
0201 virtual Int_t GetMaximum() const;
0202 Int_t GetNdata() const { return fNdata; }
0203 Int_t GetType() const { return fType; }
0204 Int_t GetStreamerType() const { return fStreamerType; }
0205 virtual TClass *GetTargetClass() { return fTargetClass; }
0206 virtual const char *GetTypeName() const;
0207 Double_t GetValue(Int_t i, Int_t len, bool subarr = false) const { return GetTypedValue<Double_t>(i, len, subarr); }
0208 template<typename T > T GetTypedValue(Int_t i, Int_t len, bool subarr = false) const;
0209 virtual void *GetValuePointer() const;
0210 Int_t GetClassVersion() { return fClassVersion; }
0211 bool IsBranchFolder() const { return TestBit(kBranchFolder); }
0212 bool IsFolder() const override;
0213 virtual bool IsObjectOwner() const { return TestBit(kDeleteObject); }
0214 bool Notify() override { if (fAddress) { ResetAddress(); } return true; }
0215 void Print(Option_t* option = "") const override;
0216 void PrintValue(Int_t i) const;
0217 void Reset(Option_t* option = "") override;
0218 void ResetAfterMerge(TFileMergeInfo *) override;
0219 void ResetAddress() override;
0220 virtual void ResetDeleteObject();
0221 virtual void ResetInitInfo(bool recurse);
0222 void SetAddress(void* addobj) override;
0223 bool SetMakeClass(bool decomposeObj = true) override;
0224 void SetObject(void *objadd) override;
0225 void SetBasketSize(Int_t buffsize) override;
0226 virtual void SetBranchFolder() { SetBit(kBranchFolder); }
0227 virtual void SetClassName(const char* name) { fClassName = name; }
0228 void SetOffset(Int_t offset) override;
0229 virtual void SetMissing();
0230 inline void SetParentClass(TClass* clparent);
0231 virtual void SetParentName(const char* name) { fParentName = name; }
0232 virtual void SetTargetClass(const char *name);
0233 void SetupAddresses() override;
0234 virtual void SetType(Int_t btype) { fType = btype; }
0235 void UpdateFile() override;
0236 void Unroll(const char *name, TClass *cl, TStreamerInfo *sinfo, char* objptr, Int_t bufsize, Int_t splitlevel);
0237
0238 enum EBranchElementType {
0239 kLeafNode = 0,
0240 kBaseClassNode = 1,
0241
0242
0243
0244
0245 kObjectNode = 2,
0246 kClonesNode = 3,
0247 kSTLNode = 4,
0248 kClonesMemberNode = 31,
0249 kSTLMemberNode = 41
0250 };
0251
0252 private:
0253 Int_t FillImpl(ROOT::Internal::TBranchIMTHelper *) override;
0254
0255 ClassDefOverride(TBranchElement,10)
0256 };
0257
0258 inline void TBranchElement::SetParentClass(TClass* clparent)
0259 {
0260 fParentClass = clparent;
0261 fParentName = clparent ? clparent->GetName() : "";
0262 }
0263
0264 inline void TBranchElement::ValidateAddress() const
0265 {
0266
0267
0268 if (fID < 0) {
0269
0270 if (!fTree->GetMakeClass() && fAddress && (*((char**) fAddress) != fObject)) {
0271
0272
0273
0274
0275
0276
0277 if (TestBit(kDeleteObject)) {
0278
0279 Error("ValidateAddress", "We owned an object whose address changed! our ptr: %p new ptr: %p",
0280 (void*)fObject, (void*)*((char**) fAddress));
0281 const_cast<TBranchElement*>(this)->ResetBit(kDeleteObject);
0282 }
0283 const_cast<TBranchElement*>(this)->SetAddress(fAddress);
0284 }
0285 }
0286 }
0287
0288 #endif