Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TLeafElement.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 14/01/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TLeafElement
13 #define ROOT_TLeafElement
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TLeafElement //
19 // //
20 // A TLeaf for a general object derived from TObject. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include <atomic>
25 
26 #include "TDataType.h"
27 #include "TLeaf.h"
28 #include "TBranchElement.h"
29 
30 class TMethodCall;
31 
32 class TLeafElement : public TLeaf {
33 
34 protected:
35  char *fAbsAddress; ///<! Absolute leaf Address
36  Int_t fID; ///< element serial number in fInfo
37  Int_t fType; ///< leaf type
38  mutable std::atomic<DeserializeType> fDeserializeTypeCache{ DeserializeType::kInvalid }; ///<! Cache of the type of deserialization.
39  mutable std::atomic<EDataType> fDataTypeCache{EDataType::kOther_t}; ///<! Cache of the EDataType of deserialization.
40 
41 private:
42  virtual Int_t GetOffsetHeaderSize() const {return 1;}
43 
44 public:
45  TLeafElement();
46  TLeafElement(TBranch *parent, const char *name, Int_t id, Int_t type);
47  virtual ~TLeafElement();
48 
49  virtual Bool_t CanGenerateOffsetArray() { return fLeafCount && fLenType; }
50  virtual Int_t *GenerateOffsetArrayBase(Int_t /*base*/, Int_t /*events*/) { return nullptr; }
51  virtual DeserializeType GetDeserializeType() const;
52 
53  virtual Int_t GetLen() const {return ((TBranchElement*)fBranch)->GetNdata()*fLen;}
54  TMethodCall *GetMethodCall(const char *name);
55  virtual Int_t GetMaximum() const {return ((TBranchElement*)fBranch)->GetMaximum();}
56  virtual Int_t GetNdata() const {return ((TBranchElement*)fBranch)->GetNdata()*fLen;}
57  virtual const char *GetTypeName() const {return ((TBranchElement*)fBranch)->GetTypeName();}
58 
59  virtual Double_t GetValue(Int_t i=0) const { return ((TBranchElement*)fBranch)->GetValue(i, fLen, kFALSE);}
60  virtual Long64_t GetValueLong64(Int_t i = 0) const { return ((TBranchElement*)fBranch)->GetTypedValue<Long64_t>(i, fLen, kFALSE); }
61  virtual LongDouble_t GetValueLongDouble(Int_t i = 0) const { return ((TBranchElement*)fBranch)->GetTypedValue<LongDouble_t>(i, fLen, kFALSE); }
62  template<typename T> T GetTypedValueSubArray(Int_t i=0, Int_t j=0) const {return ((TBranchElement*)fBranch)->GetTypedValue<T>(i, j, kTRUE);}
63 
64  virtual bool ReadBasketFast(TBuffer&, Long64_t);
65  virtual bool ReadBasketSerialized(TBuffer&, Long64_t) { return GetDeserializeType() != DeserializeType::kDestructive; }
66 
67  virtual void *GetValuePointer() const { return ((TBranchElement*)fBranch)->GetValuePointer(); }
68  virtual Bool_t IncludeRange(TLeaf *);
69  virtual Bool_t IsOnTerminalBranch() const;
70  virtual void PrintValue(Int_t i=0) const {((TBranchElement*)fBranch)->PrintValue(i);}
71  virtual void SetLeafCount(TLeaf *leaf) {fLeafCount = leaf;}
72 
73  ClassDef(TLeafElement,1); //A TLeaf for a general object derived from TObject.
74 };
75 
76 #endif