Logo ROOT  
Reference Guide
TLeafElement.cxx
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/** \class TLeafElement
13\ingroup tree
14
15A TLeaf for the general case when using the branches created via
16a TStreamerInfo (i.e. using TBranchElement).
17*/
18
19#include "TLeafElement.h"
20//#include "TMethodCall.h"
21
23#include "Bytes.h"
24
26
27////////////////////////////////////////////////////////////////////////////////
28/// Default constructor for LeafObject.
29
31{
32 fAbsAddress = 0;
33 fID = -1;
34 fType = -1;
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// Create a LeafObject.
39
41 : TLeaf(parent, name,name)
42{
43 fLenType = 0;
44 fAbsAddress = 0;
45 fID = id;
46 fType = type;
48 Int_t bareType = type;
49 if (bareType > TVirtualStreamerInfo::kOffsetP)
51 else if (bareType > TVirtualStreamerInfo::kOffsetL)
53
54 if ((bareType >= TVirtualStreamerInfo::kUChar && bareType <= TVirtualStreamerInfo::kULong)
55 || bareType == TVirtualStreamerInfo::kULong64)
56 {
58 }
59
60 auto bareTypeCopy = static_cast<EDataType>(bareType);
61 switch (bareTypeCopy) {
62 case kChar_t: // fall-through
63 case kUChar_t: // fall-through
64 case kchar: // fall-through
65 case kBool_t:
66 fLenType = 1;
67 break;
68 case kShort_t: // fall-through
69 case kUShort_t: // fall-through
70 case kFloat16_t:
71 fLenType = 2;
72 break;
73 case kFloat_t: // fall-through
74 case kDouble32_t: // fall-through
75 case kInt_t: // fall-through
76 case kUInt_t:
77 fLenType = 4;
78 break;
79 case kLong_t: // fall-through
80 case kULong_t: // fall-through
81 case kLong64_t: // fall-through
82 case kULong64_t: // fall-through
83 case kDouble_t:
84 fLenType = 8;
85 break;
86 // All cases I don't know how to handle.
87 case kOther_t: // fall-through
88 case kNoType_t: // fall-through
89 case kCounter: // fall-through
90 case kCharStar: // fall-through
91 case kBits: // fall-through
92 case kVoid_t: // fall-through
93 case kDataTypeAliasUnsigned_t: // fall-through
94 case kDataTypeAliasSignedChar_t: // fall-through
95 case kNumDataTypes: // fall-through
96 fLenType = 0;
97 };
98 }
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Default destructor for a LeafObject.
103
105{
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Determine if this TLeafElement supports bulk IO
112{
113 if (R__likely(fDeserializeTypeCache.load(std::memory_order_relaxed) != DeserializeType::kInvalid))
115
116 TClass *clptr = nullptr;
118 if (fBranch->GetExpectedType(clptr, type)) { // Returns non-zero in case of failure
119 fDeserializeTypeCache.store(DeserializeType::kDestructive, std::memory_order_relaxed);
120 return DeserializeType::kDestructive; // I don't know what it is, but we aren't going to use bulk IO.
121 }
122 fDataTypeCache.store(type, std::memory_order_release);
123 if (clptr) { // Something that requires a dictionary to read; skip.
124 fDeserializeTypeCache.store(DeserializeType::kDestructive, std::memory_order_relaxed);
126 }
127
129 fDeserializeTypeCache.store(DeserializeType::kZeroCopy, std::memory_order_relaxed);
131 } else if ((type == EDataType::kFloat_t) || (type == EDataType::kDouble_t) ||
134 fDeserializeTypeCache.store(DeserializeType::kInPlace, std::memory_order_relaxed);
136 }
137
138 fDeserializeTypeCache.store(DeserializeType::kDestructive, std::memory_order_relaxed);
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Deserialize N events from an input buffer.
145{
146 EDataType type = fDataTypeCache.load(std::memory_order_consume);
147 return input_buf.ByteSwapBuffer(fLen*N, type);
148}
149
150////////////////////////////////////////////////////////////////////////////////
151/// Returns pointer to method corresponding to name name is a string
152/// with the general form "method(list of params)" If list of params is
153/// omitted, () is assumed;
154
156{
157 return 0;
158}
159
160////////////////////////////////////////////////////////////////////////////////
161/// Return the full name (including the parent's branch names) of the leaf.
162
164{
165 TBranchElement *br = static_cast<TBranchElement*>(GetBranch());
166 if (br->GetType() == 3 || br->GetType() == 4) {
167 // return TString(br->GetFullName()) + "." + GetName() + "_";
168 return TString(br->GetFullName()) + "_";
169 } else
170 return GetBranch()->GetFullName();
171}
172
173////////////////////////////////////////////////////////////////////////////////
174/// Copy/set fMinimum and fMaximum to include/be wide than those of the parameter
175
177{
178 if (input) {
179 if (input->GetMaximum() > this->GetMaximum())
180 ((TBranchElement*)fBranch)->fMaximum = input->GetMaximum();
181 return kTRUE;
182 } else {
183 return kFALSE;
184 }
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Return true if this leaf is does not have any sub-branch/leaf.
189
191{
193 return kTRUE;
194}
#define R__likely(expr)
Definition: RConfig.hxx:612
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
EDataType
Definition: TDataType.h:28
@ kNoType_t
Definition: TDataType.h:33
@ kFloat_t
Definition: TDataType.h:31
@ kULong64_t
Definition: TDataType.h:32
@ kInt_t
Definition: TDataType.h:30
@ kNumDataTypes
Definition: TDataType.h:40
@ kchar
Definition: TDataType.h:31
@ kLong_t
Definition: TDataType.h:30
@ kDouble32_t
Definition: TDataType.h:31
@ kShort_t
Definition: TDataType.h:29
@ kBool_t
Definition: TDataType.h:32
@ kBits
Definition: TDataType.h:34
@ kDataTypeAliasSignedChar_t
Definition: TDataType.h:38
@ kULong_t
Definition: TDataType.h:30
@ kLong64_t
Definition: TDataType.h:32
@ kVoid_t
Definition: TDataType.h:35
@ kUShort_t
Definition: TDataType.h:29
@ kDouble_t
Definition: TDataType.h:31
@ kCharStar
Definition: TDataType.h:34
@ kChar_t
Definition: TDataType.h:29
@ kUChar_t
Definition: TDataType.h:29
@ kDataTypeAliasUnsigned_t
Definition: TDataType.h:37
@ kCounter
Definition: TDataType.h:34
@ kUInt_t
Definition: TDataType.h:30
@ kFloat16_t
Definition: TDataType.h:33
@ kOther_t
Definition: TDataType.h:32
#define N
XFontStruct * id
Definition: TGX11.cxx:108
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
A Branch for the case of an object.
virtual TString GetFullName() const
Return the 'full' name of the branch.
Int_t GetType() const
A TTree is a list of TBranches.
Definition: TBranch.h:91
virtual TString GetFullName() const
Return the 'full' name of the branch.
Definition: TBranch.cxx:1891
TObjArray * GetListOfBranches()
Definition: TBranch.h:244
virtual Int_t GetExpectedType(TClass *&clptr, EDataType &type)
Fill expectedClass and expectedType with information on the data type of the object/values contained ...
Definition: TBranch.cxx:1707
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
Bool_t ByteSwapBuffer(Long64_t n, EDataType type)
Byte-swap N primitive-elements in the buffer.
Definition: TBuffer.cxx:392
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
A TLeaf for the general case when using the branches created via a TStreamerInfo (i....
Definition: TLeafElement.h:32
TMethodCall * GetMethodCall(const char *name)
Returns pointer to method corresponding to name name is a string with the general form "method(list o...
char * fAbsAddress
! Absolute leaf Address
Definition: TLeafElement.h:35
std::atomic< DeserializeType > fDeserializeTypeCache
! Cache of the type of deserialization.
Definition: TLeafElement.h:38
virtual ~TLeafElement()
Default destructor for a LeafObject.
virtual Bool_t IsOnTerminalBranch() const
Return true if this leaf is does not have any sub-branch/leaf.
Int_t fType
leaf type
Definition: TLeafElement.h:37
virtual DeserializeType GetDeserializeType() const
Determine if this TLeafElement supports bulk IO.
virtual TString GetFullName() const
Return the full name (including the parent's branch names) of the leaf.
std::atomic< EDataType > fDataTypeCache
! Cache of the EDataType of deserialization.
Definition: TLeafElement.h:39
virtual Bool_t IncludeRange(TLeaf *)
Copy/set fMinimum and fMaximum to include/be wide than those of the parameter.
Int_t fID
element serial number in fInfo
Definition: TLeafElement.h:36
virtual bool ReadBasketFast(TBuffer &, Long64_t)
Deserialize N events from an input buffer.
TLeafElement()
Default constructor for LeafObject.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:49
Int_t fLenType
Number of bytes for this data type.
Definition: TLeaf.h:65
virtual Int_t GetMaximum() const
Definition: TLeaf.h:125
Int_t fLen
Number of fixed length elements in the leaf's data.
Definition: TLeaf.h:64
DeserializeType
Definition: TLeaf.h:91
TBranch * GetBranch() const
Definition: TLeaf.h:107
TBranch * fBranch
! Pointer to supporting branch (we do not own the branch)
Definition: TLeaf.h:70
virtual void SetUnsigned()
Definition: TLeaf.h:157
Method or function calling interface.
Definition: TMethodCall.h:37
Int_t GetEntriesFast() const
Definition: TObjArray.h:64
Basic string class.
Definition: TString.h:131