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;
61 std::size_t
GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment)
const;
63 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
66 std::unique_ptr<RDeleter>
GetDeleter()
const override;
68 std::size_t
AppendImpl(
const void *from)
final;
72 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
73 const std::vector<std::size_t> &offsets, std::string_view typeName =
"");
75 template <std::
size_t N>
76 RRecordField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>,
N> &&itemFields,
77 const std::array<std::size_t, N> &offsets, std::string_view typeName =
"")
81 for (
unsigned i = 0; i <
N; ++i) {
85 fTraits &= itemFields[i]->GetTraits();
86 Attach(std::move(itemFields[i]));
93 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields);
94 RRecordField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
120 void operator()(
void *objPtr,
bool dtorOnly)
final;
124 static std::string
GetTypeList(
const std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
127 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
130 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RPairDeleter>(
fClass); }
132 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields,
133 const std::array<std::size_t, 2> &offsets);
136 RPairField(std::string_view fieldName, std::array<std::unique_ptr<RFieldBase>, 2> &itemFields);
142template <
typename T1,
typename T2>
144 using ContainerT =
typename std::pair<T1, T2>;
147 template <
typename Ty1,
typename Ty2>
148 static std::array<std::unique_ptr<RFieldBase>, 2> BuildItemFields()
150 return {std::make_unique<RField<Ty1>>(
"_0"), std::make_unique<
RField<Ty2>>(
"_1")};
153 static std::array<std::size_t, 2> BuildItemOffsets()
155 auto pair = ContainerT();
156 auto offsetFirst =
reinterpret_cast<std::uintptr_t
>(&(pair.first)) -
reinterpret_cast<std::uintptr_t
>(&pair);
157 auto offsetSecond =
reinterpret_cast<std::uintptr_t
>(&(pair.second)) -
reinterpret_cast<std::uintptr_t
>(&pair);
158 return {offsetFirst, offsetSecond};
162 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
166 return std::make_unique<RField<std::pair<T1, T2>>>(newName, std::move(items));
169 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
170 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
174 explicit RField(std::string_view
name, std::array<std::unique_ptr<RFieldBase>, 2> &&itemFields)
175 : RPairField(
name, std::move(itemFields), BuildItemOffsets())
178 fSize =
sizeof(ContainerT);
199 void operator()(
void *objPtr,
bool dtorOnly)
final;
203 static std::string
GetTypeList(
const std::vector<std::unique_ptr<RFieldBase>> &itemFields);
206 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const override;
209 std::unique_ptr<RDeleter>
GetDeleter()
const override {
return std::make_unique<RTupleDeleter>(
fClass); }
211 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &&itemFields,
212 const std::vector<std::size_t> &offsets);
215 RTupleField(std::string_view fieldName, std::vector<std::unique_ptr<RFieldBase>> &itemFields);
221template <
typename... ItemTs>
223 using ContainerT =
typename std::tuple<ItemTs...>;
226 template <
typename HeadT,
typename... TailTs>
227 static std::string BuildItemTypes()
230 if constexpr (
sizeof...(TailTs) > 0)
231 result +=
"," + BuildItemTypes<TailTs...>();
235 template <
typename HeadT,
typename... TailTs>
236 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
239 if constexpr (
sizeof...(TailTs) > 0)
240 _BuildItemFields<TailTs...>(itemFields,
index + 1);
242 template <
typename... Ts>
243 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
245 std::vector<std::unique_ptr<RFieldBase>>
result;
246 _BuildItemFields<Ts...>(
result);
250 template <
unsigned Index,
typename HeadT,
typename... TailTs>
251 static void _BuildItemOffsets(std::vector<std::size_t> &offsets,
const ContainerT &tuple)
254 reinterpret_cast<std::uintptr_t
>(&std::get<Index>(tuple)) -
reinterpret_cast<std::uintptr_t
>(&tuple);
255 offsets.emplace_back(
offset);
256 if constexpr (
sizeof...(TailTs) > 0)
257 _BuildItemOffsets<
Index + 1, TailTs...>(offsets, tuple);
259 template <
typename... Ts>
260 static std::vector<std::size_t> BuildItemOffsets()
262 std::vector<std::size_t>
result;
263 _BuildItemOffsets<0, Ts...>(
result, ContainerT());
268 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
270 std::vector<std::unique_ptr<RFieldBase>> items;
273 return std::make_unique<
RField<std::tuple<ItemTs...>>>(newName, std::move(items));
276 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
277 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<ContainerT>>(); }
280 static std::string
TypeName() {
return "std::tuple<" + BuildItemTypes<ItemTs...>() +
">"; }
281 explicit RField(std::string_view
name, std::vector<std::unique_ptr<RFieldBase>> &&itemFields)
282 : RTupleField(
name, std::move(itemFields), BuildItemOffsets<ItemTs...>())
285 fSize =
sizeof(ContainerT);
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::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::size_t fMaxAlignment
std::unique_ptr< RDeleter > GetDeleter() const final
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.
const std::string & GetFieldName() const
int fTraits
Properties of the type that allow for optimizations of collections of that type.
std::unique_ptr< RFieldBase > Clone(std::string_view newName) const
Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns.
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
static constexpr int kTraitTrivialType
Shorthand for types that are both trivially constructible and destructible.
Classes with dictionaries that can be inspected by TClass.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
RField & operator=(RField &&other)=default
static std::string TypeName()
~RField() override=default
void operator()(void *objPtr, bool dtorOnly) final
Template specializations for C++ std::pair.
~RPairField() override=default
void ConstructValue(void *where) const override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
static std::string GetTypeList(const std::array< std::unique_ptr< RFieldBase >, 2 > &itemFields)
RPairField(RPairField &&other)=default
std::unique_ptr< RDeleter > GetDeleter() const override
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
RRecordField(std::string_view fieldName, std::array< std::unique_ptr< RFieldBase >, N > &&itemFields, const std::array< std::size_t, N > &offsets, std::string_view typeName="")
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
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
RRecordField(RRecordField &&other)=default
std::unique_ptr< RDeleter > GetDeleter() const override
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
~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 override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
RTupleDeleter(TClass *cl)
void operator()(void *objPtr, bool dtorOnly) final
Template specializations for C++ std::tuple.
std::unique_ptr< RDeleter > GetDeleter() const override
RTupleField & operator=(RTupleField &&other)=default
static std::string GetTypeList(const std::vector< std::unique_ptr< RFieldBase > > &itemFields)
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
void ConstructValue(void *where) const override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
~RTupleField() override=default
RTupleField(RTupleField &&other)=default
TClass instances represent classes, structs and namespaces in the ROOT type system.
RooCmdArg Index(RooCategory &icat)
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...