16#ifndef ROOT7_RField_STLMisc
17#define ROOT7_RField_STLMisc
20#error "Please include RField.hxx!"
36namespace Experimental {
48 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
58 RAtomicField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
71template <
typename ItemT>
72class RField<std::atomic<ItemT>> final :
public RAtomicField {
90 static constexpr std::size_t kWordSize =
sizeof(
Word_t);
91 static constexpr std::size_t kBitsPerWord = kWordSize * 8;
97 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
99 return std::make_unique<RBitsetField>(newName, fN);
105 std::size_t
AppendImpl(
const void *from)
final;
115 size_t GetValueSize() const final {
return kWordSize * ((fN + kBitsPerWord - 1) / kBitsPerWord); }
120 std::size_t
GetN()
const {
return fN; }
123template <std::
size_t N>
124class RField<std::bitset<N>> final :
public RBitsetField {
126 static std::string
TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
137extern template class RSimpleField<std::
byte>;
140class
RField<std::
byte> final : public RSimpleField<std::
byte> {
142 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
144 return std::make_unique<RField>(newName);
150 static std::
string TypeName() {
return "std::byte"; }
156 void AcceptVisitor(Detail::RFieldVisitor &visitor) const final;
176 std::
size_t AppendNull();
177 std::
size_t AppendValue(const
void *from);
184 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
198 std::size_t fEngagementPtrOffset = 0;
202 : fItemDeleter(std::move(itemDeleter)), fEngagementPtrOffset(engagementPtrOffset) {}
203 void operator()(
void *objPtr,
bool dtorOnly)
final;
210 const bool *GetEngagementPtr(
const void *optionalPtr)
const;
211 bool *GetEngagementPtr(
void *optionalPtr)
const;
215 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
217 void ConstructValue(
void *where)
const final;
218 std::unique_ptr<RDeleter> GetDeleter() const final;
220 std::
size_t AppendImpl(const
void *from) final;
221 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
230 size_t GetValueSize() const final;
231 size_t GetAlignment() const final;
234template <typename ItemT>
250 explicit RUniquePtrDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
251 void operator()(
void *objPtr,
bool dtorOnly)
final;
257 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
259 void ConstructValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
260 std::unique_ptr<RDeleter> GetDeleter() const final;
262 std::
size_t AppendImpl(const
void *from) final;
263 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
272 size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
273 size_t GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
276template <
typename ItemT>
277class RField<std::unique_ptr<ItemT>> final :
public RUniquePtrField {
291class
RField<std::
string> final : public RFieldBase {
295 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
297 return std::make_unique<RField>(newName);
304 void ConstructValue(
void *where) const final {
new (where) std::string(); }
305 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::string>>(); }
307 std::size_t
AppendImpl(
const void *from)
final;
313 static std::string
TypeName() {
return "std::string"; }
322 size_t GetValueSize() const final {
return sizeof(std::string); }
323 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
324 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
338 static constexpr std::size_t kMaxVariants = 125;
348 std::vector<std::unique_ptr<RDeleter>> itemDeleters)
349 : fTagOffset(tagOffset), fVariantOffset(variantOffset), fItemDeleters(std::move(itemDeleters))
352 void operator()(
void *objPtr,
bool dtorOnly)
final;
355 size_t fMaxItemSize = 0;
356 size_t fMaxAlignment = 1;
358 size_t fTagOffset = 0;
360 size_t fVariantOffset = 0;
363 static std::string GetTypeList(
const std::vector<std::unique_ptr<RFieldBase>> &itemFields);
368 static std::uint8_t GetTag(
const void *variantPtr, std::size_t tagOffset);
369 static void SetTag(
void *variantPtr, std::size_t tagOffset, std::uint8_t tag);
374 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
377 void GenerateColumns() final;
380 void ConstructValue(
void *where) const final;
381 std::unique_ptr<
RDeleter> GetDeleter() const final;
383 std::
size_t AppendImpl(const
void *from) final;
384 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
386 void CommitClusterImpl() final;
394 size_t GetValueSize() const final;
395 size_t GetAlignment() const final;
398template <typename... ItemTs>
401 template <
typename HeadT,
typename... TailTs>
402 static std::string BuildItemTypes()
405 if constexpr (
sizeof...(TailTs) > 0)
406 result +=
"," + BuildItemTypes<TailTs...>();
410 template <
typename HeadT,
typename... TailTs>
411 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
414 if constexpr (
sizeof...(TailTs) > 0)
415 _BuildItemFields<TailTs...>(itemFields,
index + 1);
417 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
419 std::vector<std::unique_ptr<RFieldBase>>
result;
420 _BuildItemFields<ItemTs...>(
result);
425 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
ROOT::Experimental::RField< T > RField
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
TRObject operator()(const T1 &t1) const
Binding & operator=(OUT(*fun)(void))
Abstract base class for classes implementing the visitor design pattern.
Template specializations for C++ std::atomic.
~RAtomicField() override=default
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::unique_ptr< RDeleter > GetDeleter() 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 ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given a value for this field.
RAtomicField & operator=(RAtomicField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RAtomicField(RAtomicField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
Template specializations for C++ std::bitset.
std::size_t GetN() const
Get the number of bits in the bitset, i.e. the N in std::bitset<N>
RBitsetField(RBitsetField &&other)=default
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
~RBitsetField() override=default
RBitsetField & operator=(RBitsetField &&other)=default
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void ReadInClusterImpl(RClusterIndex clusterIndex, void *to) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
std::unique_ptr< RDeleter > GetDeleter() const final
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Some fields have multiple possible column representations, e.g.
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.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponsing to the field type ...
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append and Read on other (sub) fields.
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
static void CallReadOn(RFieldBase &other, RClusterIndex clusterIndex, void *to)
static void CallConstructValueOn(const RFieldBase &other, void *where)
Allow derived classes to call ConstructValue(void *) and GetDeleter on other (sub) fields.
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
virtual void CommitClusterImpl()
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
Classes with dictionaries that can be inspected by TClass.
RField & operator=(RField &&other)=default
static std::string TypeName()
The on-storage meta-data of an ntuple.
Template specializations for C++ std::optional and std::unique_ptr.
RNullableField & operator=(RNullableField &&other)=default
~RNullableField() override=default
RNullableField(RNullableField &&other)=default
ROptionalDeleter(std::unique_ptr< RDeleter > itemDeleter, std::size_t engagementPtrOffset)
std::unique_ptr< RDeleter > fItemDeleter
std::size_t GetEngagementPtrOffset() const
std::unique_ptr< RDeleter > fItemDeleter
RUniquePtrDeleter(std::unique_ptr< RDeleter > itemDeleter)
std::unique_ptr< RDeleter > fItemDeleter
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
std::unique_ptr< RDeleter > fItemDeleter
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
RVariantDeleter(std::size_t tagOffset, std::size_t variantOffset, std::vector< std::unique_ptr< RDeleter > > itemDeleters)
std::size_t fVariantOffset
Template specializations for C++ std::variant.
std::vector< ClusterSize_t::ValueType > fNWritten
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
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...
Wrap the integer in a struct in order to avoid template specialization clash with std::uint64_t.