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
22#include "Bytes.h"
23#include "TBuffer.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__unlikely(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::kExternal, std::memory_order_relaxed);
120 return DeserializeType::kExternal; // 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::kExternal, 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::kExternal, std::memory_order_relaxed);
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Deserialize N events from an input buffer.
145{
146 if (R__unlikely(fDeserializeTypeCache.load(std::memory_order_relaxed) == DeserializeType::kInvalid))
147 GetDeserializeType(); // Set fDataTypeCache if need be.
148 EDataType type = fDataTypeCache.load(std::memory_order_consume);
149 return input_buf.ByteSwapBuffer(fLen*N, type);
150}
151
152////////////////////////////////////////////////////////////////////////////////
153/// Returns pointer to method corresponding to name name is a string
154/// with the general form "method(list of params)" If list of params is
155/// omitted, () is assumed;
156
158{
159 return 0;
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Return the full name (including the parent's branch names) of the leaf.
164
166{
167 TBranchElement *br = static_cast<TBranchElement*>(GetBranch());
168 if (br->GetType() == 3 || br->GetType() == 4) {
169 TString bname(br->GetFullName());
170 if (bname.Length() && bname[bname.Length()-1]=='.')
171 bname.Remove(bname.Length()-1);
172 return bname + "_";
173 } else
174 return GetBranch()->GetFullName();
175}
176
177////////////////////////////////////////////////////////////////////////////////
178/// Copy/set fMinimum and fMaximum to include/be wide than those of the parameter
179
181{
182 if (input) {
183 if (input->GetMaximum() > this->GetMaximum())
184 ((TBranchElement*)fBranch)->fMaximum = input->GetMaximum();
185 return kTRUE;
186 } else {
187 return kFALSE;
188 }
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Return true if this leaf is does not have any sub-branch/leaf.
193
195{
197 return kTRUE;
198}
#define R__unlikely(expr)
Definition: RConfig.hxx:595
const Bool_t kFALSE
Definition: RtypesCore.h:101
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassImp(name)
Definition: Rtypes.h:375
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition: TGX11.cxx:110
A Branch for the case of an object.
TString GetFullName() const override
Return the 'full' name of the branch.
Int_t GetType() const
A TTree is a list of TBranches.
Definition: TBranch.h:89
virtual TString GetFullName() const
Return the 'full' name of the branch.
Definition: TBranch.cxx:1956
TObjArray * GetListOfBranches()
Definition: TBranch.h:242
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:1772
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
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
Bool_t IsOnTerminalBranch() const override
Return true if this leaf is does not have any sub-branch/leaf.
TMethodCall * GetMethodCall(const char *name)
Returns pointer to method corresponding to name name is a string with the general form "method(list o...
Bool_t IncludeRange(TLeaf *) override
Copy/set fMinimum and fMaximum to include/be wide than those of the parameter.
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.
bool ReadBasketFast(TBuffer &, Long64_t) override
Deserialize N events from an input buffer.
Int_t fType
leaf type
Definition: TLeafElement.h:37
std::atomic< EDataType > fDataTypeCache
! Cache of the EDataType of deserialization.
Definition: TLeafElement.h:39
Int_t fID
element serial number in fInfo
Definition: TLeafElement.h:36
TString GetFullName() const override
Return the full name (including the parent's branch names) of the leaf.
DeserializeType GetDeserializeType() const override
Determine if this TLeafElement supports bulk IO.
TLeafElement()
Default constructor for LeafObject.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:57
Int_t fLenType
Number of bytes for this data type.
Definition: TLeaf.h:73
Int_t fLen
Number of fixed length elements in the leaf's data.
Definition: TLeaf.h:72
DeserializeType
Definition: TLeaf.h:99
TBranch * GetBranch() const
Definition: TLeaf.h:116
TBranch * fBranch
! Pointer to supporting branch (we do not own the branch)
Definition: TLeaf.h:78
virtual void SetUnsigned()
Definition: TLeaf.h:166
Method or function calling interface.
Definition: TMethodCall.h:37
Int_t GetEntriesFast() const
Definition: TObjArray.h:58
Basic string class.
Definition: TString.h:136
Ssiz_t Length() const
Definition: TString.h:410
TString & Remove(Ssiz_t pos)
Definition: TString.h:673