13#ifndef ROOT_RField_STLMisc
14#define ROOT_RField_STLMisc
17#error "Please include RField.hxx!"
41 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final;
53 RAtomicField(std::string_view fieldName, std::unique_ptr<RFieldBase> itemField);
66template <
typename ItemT>
67class RField<std::atomic<ItemT>> final :
public RAtomicField {
70 explicit RField(std::string_view
name) : RAtomicField(
name, std::make_unique<
RField<ItemT>>(
"_0")) {}
90 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
92 return std::make_unique<RBitsetField>(newName, fN);
98 std::size_t
AppendImpl(
const void *from)
final;
105 const size_t wordSize = (fN <=
sizeof(
unsigned long) * 8) ?
sizeof(
unsigned long) :
sizeof(
unsigned long long);
107 const size_t wordSize =
sizeof(
unsigned long);
112 template <
typename FUlong,
typename FUlonglong,
typename... Args>
113 void SelectWordSize(FUlong &&fUlong, FUlonglong &&fUlonglong, Args &&...args);
123 const size_t bitsPerWord = WordSize() * 8;
124 return WordSize() * ((fN + bitsPerWord - 1) / bitsPerWord);
130 return WordSize() ==
sizeof(
unsigned long) ?
alignof(
unsigned long) :
alignof(
unsigned long long);
132 return alignof(
unsigned long);
139 std::size_t
GetN()
const {
return fN; }
142template <std::
size_t N>
143class RField<std::bitset<N>> final :
public RBitsetField {
145 static std::string
TypeName() {
return "std::bitset<" + std::to_string(
N) +
">"; }
156extern template class RSimpleField<std::
byte>;
159class
RField<std::
byte> final : public RSimpleField<std::
byte> {
161 std::unique_ptr<RFieldBase>
CloneImpl(std::string_view newName)
const final
163 return std::make_unique<RField>(newName);
169 static std::
string TypeName() {
return "std::byte"; }
192 bool fIsEvolvedFromInnerType =
false;
198 std::
size_t AppendNull();
199 std::
size_t AppendValue(const
void *from);
211 RNullableField(std::string_view fieldName,
const std::string &typePrefix, std::unique_ptr<RFieldBase> itemField);
225 std::size_t fEngagementPtrOffset = 0;
229 :
RDeleter(
alignment), fItemDeleter(std::move(itemDeleter)), fEngagementPtrOffset(engagementPtrOffset)
232 void operator()(
void *objPtr,
bool dtorOnly)
final;
239 const bool *GetEngagementPtr(
const void *optionalPtr)
const;
240 bool *GetEngagementPtr(
void *optionalPtr)
const;
242 void PrepareRead(
void *to,
bool hasOnDiskValue);
245 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
247 void ConstructValue(
void *where)
const final;
248 std::unique_ptr<RDeleter> GetDeleter() const final;
250 std::
size_t AppendImpl(const
void *from) final;
261 std::
size_t GetValueSize() const final;
262 std::
size_t GetAlignment() const final;
265template <typename ItemT>
282 :
RDeleter(alignof(std::unique_ptr<char>)), fItemDeleter(std::move(itemDeleter))
285 void operator()(
void *objPtr,
bool dtorOnly)
final;
291 const std::type_info *fPolymorphicTypeInfo =
nullptr;
294 void *PrepareRead(
void *to,
bool hasOnDiskValue);
297 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
299 void ConstructValue(
void *where)
const final {
new (where) std::unique_ptr<char>(); }
300 std::unique_ptr<RDeleter> GetDeleter() const final;
302 std::
size_t AppendImpl(const
void *from) final;
313 std::
size_t GetValueSize() const final {
return sizeof(std::unique_ptr<char>); }
314 std::size_t
GetAlignment() const final {
return alignof(std::unique_ptr<char>); }
317template <
typename ItemT>
318class RField<std::unique_ptr<ItemT>> final :
public RUniquePtrField {
320 static std::string TypeName() {
return "std::unique_ptr<" + RField<ItemT>::TypeName() +
">"; }
321 explicit RField(std::string_view
name) : RUniquePtrField(
name, std::make_unique<RField<ItemT>>(
"_0")) {}
322 RField(RField &&other) =
default;
323 RField &operator=(RField &&other) =
default;
324 ~RField() final = default;
332class RField<std::
string> final : public RFieldBase {
336 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final
338 return std::make_unique<RField>(newName);
341 const RColumnRepresentations &GetColumnRepresentations() const final;
342 void GenerateColumns() final;
343 void GenerateColumns(const
ROOT::RNTupleDescriptor &desc) final;
345 void ConstructValue(
void *where) const final {
new (where) std::string(); }
346 std::unique_ptr<RDeleter> GetDeleter() const final {
return std::make_unique<RTypedDeleter<std::string>>(); }
348 std::size_t AppendImpl(
const void *from)
final;
351 void CommitClusterImpl() final { fIndex = 0; }
354 static std::string TypeName() {
return "std::string"; }
355 explicit RField(std::string_view
name)
356 : RFieldBase(
name, TypeName(),
ROOT::ENTupleStructure::
kPlain, false ), fIndex(0)
359 RField(RField &&other) =
default;
360 RField &operator=(RField &&other) =
default;
361 ~RField() final = default;
363 std::
size_t GetValueSize() const final {
return sizeof(std::string); }
364 std::size_t GetAlignment() const final {
return alignof(std::string); }
379 static constexpr std::size_t kMaxVariants = 125;
389 std::vector<std::unique_ptr<RDeleter>> itemDeleters)
391 fTagOffset(tagOffset),
392 fVariantOffset(variantOffset),
393 fItemDeleters(std::move(itemDeleters))
396 void operator()(
void *objPtr,
bool dtorOnly)
final;
399 size_t fMaxItemSize = 0;
400 size_t fMaxAlignment = 1;
402 size_t fTagOffset = 0;
404 size_t fVariantOffset = 0;
405 std::vector<ROOT::Internal::RColumnIndex::ValueType>
fNWritten;
411 static std::uint8_t GetTag(
const void *variantPtr, std::size_t tagOffset);
412 static void SetTag(
void *variantPtr, std::size_t tagOffset, std::uint8_t tag);
417 std::unique_ptr<RFieldBase> CloneImpl(std::string_view newName)
const final;
420 void GenerateColumns() final;
423 void ConstructValue(
void *where) const final;
424 std::unique_ptr<
RDeleter> GetDeleter() const final;
426 std::
size_t AppendImpl(const
void *from) final;
429 void CommitClusterImpl() final;
439 std::
size_t GetValueSize() const final;
440 std::
size_t GetAlignment() const final;
443template <typename... ItemTs>
446 template <
typename HeadT,
typename... TailTs>
447 static std::string BuildItemTypes()
450 if constexpr (
sizeof...(TailTs) > 0)
451 result +=
"," + BuildItemTypes<TailTs...>();
455 template <
typename HeadT,
typename... TailTs>
456 static void _BuildItemFields(std::vector<std::unique_ptr<RFieldBase>> &itemFields,
unsigned int index = 0)
459 if constexpr (
sizeof...(TailTs) > 0)
460 _BuildItemFields<TailTs...>(itemFields,
index + 1);
462 static std::vector<std::unique_ptr<RFieldBase>> BuildItemFields()
464 std::vector<std::unique_ptr<RFieldBase>>
result;
465 _BuildItemFields<ItemTs...>(
result);
470 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
Abstract base class for classes implementing the visitor design pattern.
The in-memory representation of a 32bit or 64bit on-disk index column.
Template specializations for C++ std::atomic.
RAtomicField(RAtomicField &&other)=default
size_t GetValueSize() const final
What sizeof(T) for this type returns.
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
What alignof(T) for this type returns.
void AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final
RAtomicField(std::string_view fieldName, std::unique_ptr< RFieldBase > itemField)
std::unique_ptr< RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
std::size_t AppendImpl(const void *from) final
Operations on values of complex types, e.g.
std::unique_ptr< RDeleter > GetDeleter() const final
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
~RAtomicField() override=default
std::vector< RValue > SplitValue(const RValue &value) const final
Creates the list of direct child values given an existing value for this field.
RAtomicField & operator=(RAtomicField &&other)=default
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>
size_t GetAlignment() const final
What alignof(T) for this type returns.
~RBitsetField() override=default
RBitsetField & operator=(RBitsetField &&other)=default
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
What sizeof(T) for this type returns.
RBitsetField(RBitsetField &&other)=default
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 ReconcileOnDiskField(const RNTupleDescriptor &desc) final
For non-artificial fields, check compatibility of the in-memory field and the on-disk field.
std::size_t GetValueSize() const final
What sizeof(T) for this type returns.
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) 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 AcceptVisitor(ROOT::Detail::RFieldVisitor &visitor) const final
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final
The list of column representations a field can have.
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.
std::vector< std::unique_ptr< RFieldBase > > fSubfields
Collections and classes own subfields.
virtual const RColumnRepresentations & GetColumnRepresentations() const
Implementations in derived classes should return a static RColumnRepresentations object.
virtual void GenerateColumns()
Implementations in derived classes should create the backing columns corresponding to the field type ...
static std::unique_ptr< RDeleter > GetDeleterOf(const RFieldBase &other)
static std::size_t CallAppendOn(RFieldBase &other, const void *from)
Allow derived classes to call Append() and Read() on other (sub)fields.
virtual void CommitClusterImpl()
static void CallReadOn(RFieldBase &other, RNTupleLocalIndex localIndex, void *to)
static void CallConstructValueOn(const RFieldBase &other, void *where)
Allow derived classes to call ConstructValue(void *) and GetDeleter() on other (sub)fields.
Classes with dictionaries that can be inspected by TClass.
RField & operator=(RField &&other)=default
static std::string TypeName()
RField(std::string_view name)
The on-storage metadata of an RNTuple.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Template specializations for C++ std::optional and std::unique_ptr.
~RNullableField() override=default
RNullableField & operator=(RNullableField &&other)=default
RNullableField(RNullableField &&other)=default
ROptionalDeleter(std::unique_ptr< RDeleter > itemDeleter, std::size_t engagementPtrOffset, std::size_t alignment)
std::unique_ptr< RDeleter > fItemDeleter
std::size_t GetEngagementPtrOffset() const
std::unique_ptr< RDeleter > fItemDeleter
std::unique_ptr< RDeleter > fItemDeleter
RUniquePtrDeleter(std::unique_ptr< RDeleter > itemDeleter)
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
std::size_t GetAlignment() const final
What alignof(T) for this type returns.
std::vector< std::unique_ptr< RDeleter > > fItemDeleters
std::size_t fVariantOffset
RVariantDeleter(std::size_t tagOffset, std::size_t variantOffset, std::size_t alignment, std::vector< std::unique_ptr< RDeleter > > itemDeleters)
Template specializations for C++ std::variant.
std::vector< ROOT::Internal::RColumnIndex::ValueType > fNWritten
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.