16#ifndef ROOT7_RField_Record
17#define ROOT7_RField_Record
20#error "Please include RField.hxx!"
33namespace Experimental {
49 RRecordDeleter(std::vector<std::unique_ptr<RDeleter>> itemDeleters,
const std::vector<std::size_t> &offsets)
53 void operator()(
void *objPtr,
bool dtorOnly)
final;
63 std::size_t
GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
65 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
68 std::unique_ptr<RDeleter>
GetDeleter() const final;
70 std::
size_t AppendImpl(const
void *from) final;
74 RRecordField(std::string_view fieldName, std::string_view typeName);
78 template <std::
size_t N>
82 for (
unsigned i = 0; i <
N; ++i) {
85 fTraits &= itemFields[i]->GetTraits();
86 Attach(std::move(itemFields[i]));
96 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> itemFields);
116 static std::string
GetTypeList(
const std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
119 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> itemFields,
120 const std::array<std::size_t, 2> &offsets);
123 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> itemFields);
129template <
typename T1,
typename T2>
131 using ContainerT =
typename std::pair<T1, T2>;
134 static std::array<std::unique_ptr<RFieldBase>, 2> BuildItemFields()
136 return {std::make_unique<RField<T1>>(
"_0"), std::make_unique<
RField<T2>>(
"_1")};
139 static std::array<std::size_t, 2> BuildItemOffsets()
141 auto pair = ContainerT();
142 auto offsetFirst =
reinterpret_cast<std::uintptr_t
>(&(pair.first)) -
reinterpret_cast<std::uintptr_t
>(&pair);
143 auto offsetSecond =
reinterpret_cast<std::uintptr_t
>(&(pair.second)) -
reinterpret_cast<std::uintptr_t
>(&pair);
144 return {offsetFirst, offsetSecond};
149 explicit RField(std::string_view
name) : RPairField(
name, BuildItemFields(), BuildItemOffsets())
166 static std::string
GetTypeList(
const std::vector<std::unique_ptr<RFieldBase>> &itemFields);
169 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> itemFields,
170 const std::vector<std::size_t> &offsets);
173 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> itemFields);
179template <
typename... ItemTs>
181 using ContainerT =
typename std::tuple<ItemTs...>;
184 template <
typename HeadT,
typename... TailTs>
185 static std::string BuildItemTypes()
188 if constexpr (
sizeof...(TailTs) > 0)
189 result +=
"," + BuildItemTypes<TailTs...>();
193 template <
typename HeadT,
typename... TailTs>
194 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
197 if constexpr (
sizeof...(TailTs) > 0)
198 _BuildItemFields<TailTs...>(itemFields,
index + 1);
200 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
202 std::vector<std::unique_ptr<RFieldBase>>
result;
203 _BuildItemFields<ItemTs...>(
result);
207 template <
unsigned Index,
typename HeadT,
typename... TailTs>
208 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
211 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
212 offsets.emplace_back(
offset);
213 if constexpr (
sizeof...(TailTs) > 0)
214 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
216 static std::vector<std::size_t> BuildItemOffsets()
218 std::vector<std::size_t>
result;
219 _BuildItemOffsets<0, ItemTs...>(
result, ContainerT());
224 static std::string
TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
225 explicit RField(std::string_view
name) : RTupleField(
name, BuildItemFields(), BuildItemOffsets())
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
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 offset
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 result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Abstract base class for classes implementing the visitor design pattern.
std::size_t fMaxAlignment
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
A functor to release the memory acquired by CreateValue (memory and constructor).
Points to an object with RNTuple I/O support and keeps a pointer to the corresponding field.
A field translates read and write calls from/to underlying columns to/from tree values.
void Attach(std::unique_ptr< RFieldBase > child)
Add a new subfield to the list of nested fields.
int fTraits
Properties of the type that allow for optimizations of collections of that type.
static constexpr int kTraitTrivialType
Shorthand for types that are both trivially constructible and destructible.
Classes with dictionaries that can be inspected by TClass.
RField & operator=(RField &&other)=default
static std::string TypeName()
Template specializations for C++ std::pair.
~RPairField() override=default
static std::string GetTypeList(const std::array< std::unique_ptr< RFieldBase >, 2 > &itemFields)
RPairField(RPairField &&other)=default
RPairField & operator=(RPairField &&other)=default
std::vector< std::size_t > fOffsets
void operator()(void *objPtr, bool dtorOnly) final
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
RRecordDeleter(std::vector< std::unique_ptr< RDeleter > > itemDeleters, const std::vector< std::size_t > &offsets)
The field for an untyped record.
std::size_t fMaxAlignment
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< std::size_t > fOffsets
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
RRecordField(RRecordField &&other)=default
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment) const
std::unique_ptr< RDeleter > GetDeleter() const final
~RRecordField() override=default
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
const std::vector< std::size_t > & GetOffsets() const
RRecordField & operator=(RRecordField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void AttachItemFields(std::vector< std::unique_ptr< RFieldBase > > itemFields)
Template specializations for C++ std::tuple.
RTupleField & operator=(RTupleField &&other)=default
static std::string GetTypeList(const std::vector< std::unique_ptr< RFieldBase > > &itemFields)
~RTupleField() override=default
RTupleField(RTupleField &&other)=default
RooCmdArg Index(RooCategory &icat)
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...