16#ifndef ROOT7_RNTupleModel
17#define ROOT7_RNTupleModel
30#include <unordered_map>
31#include <unordered_set>
35namespace Experimental {
37class RCollectionNTupleWriter;
61 using FieldMap_t = std::unordered_map<const Detail::RFieldBase *, const Detail::RFieldBase *>;
129 std::unique_ptr<RNTupleModel>
Clone()
const;
130 static std::unique_ptr<RNTupleModel>
Create();
132 static std::unique_ptr<RNTupleModel>
CreateBare();
167 template <
typename T,
typename... ArgsT>
169 return MakeField<T>({fieldName,
""}, std::forward<ArgsT>(args)...);
185 template <
typename T,
typename... ArgsT>
186 std::shared_ptr<T>
MakeField(std::pair<std::string_view, std::string_view> fieldNameDesc,
191 auto field = std::make_unique<RField<T>>(fieldNameDesc.first);
192 field->SetDescription(fieldNameDesc.second);
193 std::shared_ptr<T> ptr;
195 ptr =
fDefaultEntry->AddValue<
T>(field.get(), std::forward<ArgsT>(args)...);
203 void AddField(std::unique_ptr<Detail::RFieldBase> field);
206 template <
typename T>
208 AddField<T>({fieldName,
""}, fromWhere);
212 template <
typename T>
213 void AddField(std::pair<std::string_view, std::string_view> fieldNameDesc,
T* fromWhere) {
220 auto field = std::make_unique<RField<T>>(fieldNameDesc.first);
221 field->SetDescription(fieldNameDesc.second);
232 template <
typename T>
250 std::unique_ptr<RNTupleModel> collectionModel);
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
The REntry is a collection of values in an ntuple corresponding to a complete row in the data set.
Base class for all ROOT issued exceptions.
The container field for an ntuple model, which itself has no physical representation.
Projected fields are fields whose columns are reused from existing fields.
FieldMap_t fFieldMap
Maps the source fields from fModel to the target projected fields attached to fFieldZero.
RFieldZero * GetFieldZero() const
std::unordered_map< const Detail::RFieldBase *, const Detail::RFieldBase * > FieldMap_t
The map keys are the projected target fields, the map values are the backing source fields Note that ...
RProjectedFields & operator=(RProjectedFields &&)=default
RProjectedFields(std::unique_ptr< RFieldZero > fieldZero)
const RNTupleModel * fModel
The model this set of projected fields belongs to.
RProjectedFields(RProjectedFields &&)=default
RResult< void > Add(std::unique_ptr< Detail::RFieldBase > field, const FieldMap_t &fieldMap)
Adds a new projected field.
std::unique_ptr< RFieldZero > fFieldZero
The projected fields are attached to this zero field.
RProjectedFields(const RProjectedFields &)=delete
RProjectedFields & operator=(const RProjectedFields &)=delete
RResult< void > EnsureValidMapping(const Detail::RFieldBase *target, const FieldMap_t &fieldMap)
Asserts that the passed field is a valid target of the source field provided in the field map.
std::unique_ptr< RProjectedFields > Clone(const RNTupleModel *newModel) const
The new model needs to be a clone of fModel.
const Detail::RFieldBase * GetSourceField(const Detail::RFieldBase *target) const
~RProjectedFields()=default
RProjectedFields(const RNTupleModel *model)
The RNTupleModel encapulates the schema of an ntuple.
std::unordered_set< std::string > fFieldNames
Keeps track of which field names are taken, including projected field names.
std::string fDescription
Free text set by the user.
void EnsureValidFieldName(std::string_view fieldName)
Checks that user-provided field names are valid in the context of this NTuple model.
std::uint64_t fModelId
Upon freezing, every model has a unique ID to distingusish it from other models.
std::uint64_t GetModelId() const
RNTupleModel(const RNTupleModel &)=delete
std::string GetDescription() const
void EnsureNotBare() const
Throws an RException if fDefaultEntry is nullptr.
std::unique_ptr< RNTupleModel > Clone() const
void EnsureNotFrozen() const
Throws an RException if fFrozen is true.
REntry * GetDefaultEntry() const
std::unique_ptr< REntry > CreateBareEntry() const
In a bare entry, all values point to nullptr.
std::unique_ptr< REntry > CreateEntry() const
static std::unique_ptr< RNTupleModel > Create()
void AddField(std::string_view fieldName, T *fromWhere)
Throws an exception if fromWhere is null.
std::unique_ptr< RProjectedFields > fProjectedFields
The set of projected top-level fields.
void SetDescription(std::string_view description)
std::unique_ptr< REntry > fDefaultEntry
Contains field values corresponding to the created top-level fields.
std::shared_ptr< T > MakeField(std::string_view fieldName, ArgsT &&... args)
Creates a new field and a corresponding tree value that is managed by a shared pointer.
std::shared_ptr< T > MakeField(std::pair< std::string_view, std::string_view > fieldNameDesc, ArgsT &&... args)
Creates a new field given a {name, description} pair and a corresponding tree value that is managed b...
std::shared_ptr< RCollectionNTupleWriter > MakeCollection(std::string_view fieldName, std::unique_ptr< RNTupleModel > collectionModel)
Ingests a model for a sub collection and attaches it to the current model.
RResult< void > AddProjectedField(std::unique_ptr< Detail::RFieldBase > field, std::function< std::string(const std::string &)> mapping)
Adds a top-level field based on existing fields.
const Detail::RFieldBase * GetField(std::string_view fieldName) const
RFieldZero * GetFieldZero() const
static std::unique_ptr< RNTupleModel > CreateBare()
A bare model has no default entry.
T * Get(std::string_view fieldName) const
const RProjectedFields & GetProjectedFields() const
void AddField(std::pair< std::string_view, std::string_view > fieldNameDesc, T *fromWhere)
Throws an exception if fromWhere is null.
RNTupleModel & operator=(const RNTupleModel &)=delete
void AddField(std::unique_ptr< Detail::RFieldBase > field)
Adds a field whose type is not known at compile time.
std::unique_ptr< RFieldZero > fFieldZero
Hierarchy of fields consisting of simple types and collections (sub trees)
RResult<void> has no data member and no Inspect() method but instead a Success() factory method.
basic_string_view< char > string_view
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.