32 auto fieldNameStr = std::string(fieldName);
33 if (
fFieldNames.insert(fieldNameStr).second ==
false) {
34 throw RException(
R__FAIL(
"field name '" + fieldNameStr +
"' already exists in NTuple model"));
40 , fDefaultEntry(std::make_unique<
REntry>())
45 auto cloneModel = std::make_unique<RNTupleModel>();
46 auto cloneFieldZero = fFieldZero->Clone(
"");
47 cloneModel->fFieldZero = std::unique_ptr<RFieldZero>(
static_cast<RFieldZero *
>(cloneFieldZero.release()));
48 cloneModel->fDefaultEntry = cloneModel->fFieldZero->GenerateEntry();
55 EnsureValidFieldName(field->GetName());
56 fDefaultEntry->AddValue(field->GenerateValue());
57 fFieldZero->Attach(std::move(field));
62 std::string_view fieldName, std::unique_ptr<RNTupleModel> collectionModel)
64 EnsureValidFieldName(fieldName);
65 auto collectionNTuple = std::make_shared<RCollectionNTuple>(std::move(collectionModel->fDefaultEntry));
66 auto field = std::make_unique<RCollectionField>(fieldName, collectionNTuple, std::move(collectionModel));
67 fDefaultEntry->CaptureValue(field->CaptureValue(collectionNTuple->GetOffsetPtr()));
68 fFieldZero->Attach(std::move(field));
69 return collectionNTuple;
74 auto entry = std::make_unique<REntry>();
75 for (
auto&
f : *fFieldZero) {
76 if (
f.GetParent() != GetFieldZero())
78 entry->AddValue(
f.GenerateValue());
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
static RResult< void > EnsureValidFieldName(std::string_view fieldName)
Check whether a given string is a valid field name.
void Throw()
Throws an RException with fError.
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.
std::unordered_set< std::string > fFieldNames
Keeps track of which field names are taken.
void EnsureValidFieldName(std::string_view fieldName)
Checks that user-provided field names are valid in the context of this NTuple model.
std::shared_ptr< RCollectionNTuple > MakeCollection(std::string_view fieldName, std::unique_ptr< RNTupleModel > collectionModel)
Ingests a model for a sub collection and attaches it to the current model.
std::unique_ptr< RNTupleModel > Clone() const
std::unique_ptr< REntry > CreateEntry()
void AddField(std::unique_ptr< Detail::RFieldBase > field)
Adds a field whose type is not known at compile time. Thus there is no shared pointer returned.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...