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#include "TBuffer.h"
25
27
28////////////////////////////////////////////////////////////////////////////////
29/// Default constructor for LeafObject.
30
32{
33 fAbsAddress = 0;
34 fID = -1;
35 fType = -1;
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Create a LeafObject.
40
42 : TLeaf(parent, name,name)
43{
44 fLenType = 0;
45 fAbsAddress = 0;
46 fID = id;
47 fType = type;
49 Int_t bareType = type;
50 if (bareType > TVirtualStreamerInfo::kOffsetP)
52 else if (bareType > TVirtualStreamerInfo::kOffsetL)
54
55 if ((bareType >= TVirtualStreamerInfo::kUChar && bareType <= TVirtualStreamerInfo::kULong)
56 || bareType == TVirtualStreamerInfo::kULong64)
57 {
59 }
60
61 auto bareTypeCopy = static_cast<EDataType>(bareType);
62 switch (bareTypeCopy) {
63 case kChar_t: // fall-through
64 case kUChar_t: // fall-through
65 case kchar: // fall-through
66 case kBool_t:
67 fLenType = 1;
68 break;
69 case kShort_t: // fall-through
70 case kUShort_t: // fall-through
71 case kFloat16_t:
72 fLenType = 2;
73 break;
74 case kFloat_t: // fall-through
75 case kDouble32_t: // fall-through
76 case kInt_t: // fall-through
77 case kUInt_t:
78 fLenType = 4;
79 break;
80 case kLong_t: // fall-through
81 case kULong_t: // fall-through
82 case kLong64_t: // fall-through
83 case kULong64_t: // fall-through
84 case kDouble_t:
85 fLenType = 8;
86 break;
87 // All cases I don't know how to handle.
88 case kOther_t: // fall-through
89 case kNoType_t: // fall-through
90 case kCounter: // fall-through
91 case kCharStar: // fall-through
92 case kBits: // fall-through
93 case kVoid_t: // fall-through
94 case kDataTypeAliasUnsigned_t: // fall-through
95 case kDataTypeAliasSignedChar_t: // fall-through
96 case kNumDataTypes: // fall-through
97 fLenType = 0;
98 };
99 }
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Default destructor for a LeafObject.
104
106{
107}
108
109////////////////////////////////////////////////////////////////////////////////
110/// Determine if this TLeafElement supports bulk IO
113{
114 if (R__likely(fDeserializeTypeCache.load(std::memory_order_relaxed) != DeserializeType::kInvalid))
116
117 TClass *clptr = nullptr;
119 if (fBranch->GetExpectedType(clptr, type)) { // Returns non-zero in case of failure
120 fDeserializeTypeCache.store(DeserializeType::kDestructive, std::memory_order_relaxed);
121 return DeserializeType::kDestructive; // I don't know what it is, but we aren't going to use bulk IO.
122 }
123 fDataTypeCache.store(type, std::memory_order_release);
124 if (clptr) { // Something that requires a dictionary to read; skip.
125 fDeserializeTypeCache.store(DeserializeType::kDestructive, std::memory_order_relaxed);
127 }
128
130 fDeserializeTypeCache.store(DeserializeType::kZeroCopy, std::memory_order_relaxed);
132 } else if ((type == EDataType::kFloat_t) || (type == EDataType::kDouble_t) ||
135 fDeserializeTypeCache.store(DeserializeType::kInPlace, std::memory_order_relaxed);
137 }
138
139 fDeserializeTypeCache.store(DeserializeType::kDestructive, std::memory_order_relaxed);
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Deserialize N events from an input buffer.
146{
147 EDataType type = fDataTypeCache.load(std::memory_order_consume);
148 return input_buf.ByteSwapBuffer(fLen*N, type);
149}
150
151////////////////////////////////////////////////////////////////////////////////
152/// Returns pointer to method corresponding to name name is a string
153/// with the general form "method(list of params)" If list of params is
154/// omitted, () is assumed;
155
157{
158 return 0;
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Return the full name (including the parent's branch names) of the leaf.
163
165{
166 TBranchElement *br = static_cast<TBranchElement*>(GetBranch());
167 if (br->GetType() == 3 || br->GetType() == 4) {
168 // return TString(br->GetFullName()) + "." + GetName() + "_";
169 return TString(br->GetFullName()) + "_";
170 } else
171 return GetBranch()->GetFullName();
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Copy/set fMinimum and fMaximum to include/be wide than those of the parameter
176
178{
179 if (input) {
180 if (input->GetMaximum() > this->GetMaximum())
181 ((TBranchElement*)fBranch)->fMaximum = input->GetMaximum();
182 return kTRUE;
183 } else {
184 return kFALSE;
185 }
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Return true if this leaf is does not have any sub-branch/leaf.
190
192{
194 return kTRUE;
195}
#define R__likely(expr)
Definition: RConfig.hxx:605
const Bool_t kFALSE
Definition: RtypesCore.h:90
long long Long64_t
Definition: RtypesCore.h:71
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
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:1903
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:1719
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:80
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