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 {
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;
122template <std::
size_t N>
123class RField<std::bitset<N>> final :
public RBitsetField {
125 static std::string
TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
136extern template class RSimpleField<std::byte>;
141 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
143 return std::make_unique<RField>(newName);
146 const RColumnRepresentations &GetColumnRepresentations() const final;
149 static std::
string TypeName() {
return "std::byte"; }
150 explicit RField(std::string_view
name) : RSimpleField(
name, TypeName()) {}
155 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
178 void GenerateColumns() final;
181 std::
size_t AppendNull();
182 std::
size_t AppendValue(const
void *from);
183 void CommitClusterImpl() final { fNWritten = 0; }
187 void ReadInClusterImpl(
RClusterIndex clusterIndex,
void *to)
final;
193 RNullableField(std::string_view fieldName, std::string_view typeName, std::unique_ptr<RFieldBase> itemField);
212 explicit ROptionalDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
213 void operator()(
void *objPtr,
bool dtorOnly)
final;
221 std::pair<const void *, const bool *> GetValueAndEngagementPtrs(
const void *optionalPtr)
const;
222 std::pair<void *, bool *> GetValueAndEngagementPtrs(
void *optionalPtr)
const;
225 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
227 void ConstructValue(
void *where)
const final;
228 std::unique_ptr<RDeleter> GetDeleter() const final;
230 std::
size_t AppendImpl(const
void *from) final;
231 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
240 size_t GetValueSize() const final;
241 size_t GetAlignment() const final;
244template <typename ItemT>
260 explicit RUniquePtrDeleter(std::unique_ptr<RDeleter> itemDeleter) : fItemDeleter(std::move(itemDeleter)) {}
261 void operator()(
void *objPtr,
bool dtorOnly)
final;
267 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
269 void ConstructValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
270 std::unique_ptr<RDeleter> GetDeleter() const final;
272 std::
size_t AppendImpl(const
void *from) final;
273 void ReadGlobalImpl(
NTupleSize_t globalIndex,
void *to) final;
282 size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
283 size_t GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
286template <
typename ItemT>
290 explicit RField(std::string_view
name) : RUniquePtrField(
name, TypeName(), std::make_unique<
RField<ItemT>>(
"_0")) {}
301class RField<std::string> final :
public RFieldBase {
305 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
307 return std::make_unique<RField>(newName);
314 void ConstructValue(
void *where) const final {
new (where) std::string(); }
315 std::unique_ptr<RDeleter>
GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::string>>(); }
317 std::size_t
AppendImpl(
const void *from)
final;
323 static std::string
TypeName() {
return "std::string"; }
332 size_t GetValueSize() const final {
return sizeof(std::string); }
333 size_t GetAlignment() const final {
return std::alignment_of<std::string>(); }
334 void AcceptVisitor(Detail::RFieldVisitor &visitor)
const final;
358 std::vector<std::unique_ptr<RDeleter>> &itemDeleters)
362 void operator()(
void *objPtr,
bool dtorOnly)
final;
373 static std::string
GetTypeList(
const std::vector<RFieldBase *> &itemFields);
378 static std::uint8_t
GetTag(
const void *variantPtr, std::size_t tagOffset);
379 static void SetTag(
void *variantPtr, std::size_t tagOffset, std::uint8_t tag);
382 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
391 std::
size_t AppendImpl(const
void *from) final;
407template <typename... ItemTs>
409 using ContainerT =
typename std::variant<ItemTs...>;
412 template <
typename HeadT,
typename... TailTs>
413 static std::string BuildItemTypes()
416 if constexpr (
sizeof...(TailTs) > 0)
417 result +=
"," + BuildItemTypes<TailTs...>();
421 template <
typename HeadT,
typename... TailTs>
422 static std::vector<RFieldBase *> BuildItemFields(
unsigned int index = 0)
424 std::vector<RFieldBase *>
result;
426 if constexpr (
sizeof...(TailTs) > 0) {
427 auto tailFields = BuildItemFields<TailTs...>(
index + 1);
428 result.insert(
result.end(), tailFields.begin(), tailFields.end());
434 void ConstructValue(
void *where)
const final {
new (where) ContainerT(); }
437 static std::string TypeName() {
return "std::variant<" + BuildItemTypes<ItemTs...>() +
">"; }
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.
static constexpr std::size_t kWordSize
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
static constexpr std::size_t kBitsPerWord
void ConstructValue(void *where) const final
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
~RBitsetField() override=default
RBitsetField & operator=(RBitsetField &&other)=default
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
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 AcceptVisitor(Detail::RFieldVisitor &visitor) const override
size_t GetAlignment() const final
As a rule of thumb, the alignment is equal to the size of the type.
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()
RFieldBase(std::string_view name, std::string_view type, ENTupleStructure structure, bool isSimple, std::size_t nRepetitions=0)
The constructor creates the underlying column objects and connects them to either a sink or a source.
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
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
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
std::unique_ptr< RValue > fDefaultItemValue
For a dense nullable field, used to write a default-constructed item for missing ones.
std::unique_ptr< RDeleter > fItemDeleter
ROptionalDeleter(std::unique_ptr< RDeleter > itemDeleter)
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.
void operator()(void *objPtr, bool dtorOnly) final
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
std::size_t fVariantOffset
RVariantDeleter(std::size_t tagOffset, std::size_t variantOffset, std::vector< std::unique_ptr< RDeleter > > &itemDeleters)
Template specializations for C++ std::variant.
void ReadGlobalImpl(NTupleSize_t globalIndex, void *to) final
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
RVariantField & operator=(RVariantField &&other)=default
const RColumnRepresentations & GetColumnRepresentations() const final
Implementations in derived classes should return a static RColumnRepresentations object.
static void SetTag(void *variantPtr, std::size_t tagOffset, std::uint8_t tag)
void ConstructValue(void *where) const override
Constructs value in a given location of size at least GetValueSize(). Called by the base class' Creat...
static std::string GetTypeList(const std::vector< RFieldBase * > &itemFields)
std::vector< ClusterSize_t::ValueType > fNWritten
size_t fTagOffset
In the std::variant memory layout, at which byte number is the index stored.
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void CommitClusterImpl() final
static constexpr std::size_t kMaxVariants
static std::uint8_t GetTag(const void *variantPtr, std::size_t tagOffset)
Extracts the index from an std::variant and transforms it into the 1-based index used for the switch ...
size_t fVariantOffset
In the std::variant memory layout, the actual union of types may start at an offset > 0.
std::unique_ptr< RDeleter > GetDeleter() const 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.
void GenerateColumns() final
Implementations in derived classes should create the backing columns corresponsing to the field type ...
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.