Skip to content

Commit cf951ec

Browse files
committed
[ntuple] defriend RClassField from RFieldBase
The privileged access of RClassField to RFieldBase is used to modify some properties of its subfields. Make this more targeted through protected methods. One of the methods, CallSetArtificialOn(), will be reused by the record field.
1 parent 2c021b8 commit cf951ec

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

tree/ntuple/inc/ROOT/RFieldBase.hxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ This is and can only be partially enforced through C++.
8585
*/
8686
// clang-format on
8787
class RFieldBase {
88-
friend class ROOT::RClassField; // to mark members as artificial
8988
friend class ROOT::Experimental::Detail::RRawPtrWriteEntry; // to call Append()
9089
friend struct ROOT::Internal::RFieldCallbackInjector; // used for unit tests
9190
friend struct ROOT::Internal::RFieldRepresentationModifier; // used for unit tests
@@ -421,6 +420,11 @@ protected:
421420
static void CallConstructValueOn(const RFieldBase &other, void *where) { other.ConstructValue(where); }
422421
static std::unique_ptr<RDeleter> GetDeleterOf(const RFieldBase &other) { return other.GetDeleter(); }
423422

423+
/// Allow parents to mark their childs as artificial fields (used in class and record fields)
424+
void CallSetArtificialOn(RFieldBase &other) { other.SetArtificial(); }
425+
/// Allow class fields to adjust the type alias of their members
426+
void SetTypeAliasOf(RFieldBase &other, const std::string &alias) { other.fTypeAlias = alias; }
427+
424428
/// Operations on values of complex types, e.g. ones that involve multiple columns or for which no direct
425429
/// column type exists.
426430
virtual std::size_t AppendImpl(const void *from);

tree/ntuple/src/RFieldMeta.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ ROOT::RClassField::RClassField(std::string_view fieldName, TClass *classp)
174174

175175
const auto normTypeName = ROOT::Internal::GetNormalizedUnresolvedTypeName(origTypeName);
176176
if (normTypeName == subField->GetTypeName()) {
177-
subField->fTypeAlias = "";
177+
SetTypeAliasOf(*subField, "");
178178
} else {
179-
subField->fTypeAlias = normTypeName;
179+
SetTypeAliasOf(*subField, normTypeName);
180180
}
181181

182182
fTraits &= subField->GetTraits();
@@ -190,7 +190,7 @@ ROOT::RClassField::~RClassField()
190190
if (fStagingArea) {
191191
for (const auto &[_, si] : fStagingItems) {
192192
if (!(si.fField->GetTraits() & kTraitTriviallyDestructible)) {
193-
auto deleter = si.fField->GetDeleter();
193+
auto deleter = GetDeleterOf(*si.fField);
194194
deleter->operator()(fStagingArea.get() + si.fOffset, true /* dtorOnly */);
195195
}
196196
}
@@ -467,7 +467,7 @@ void ROOT::RClassField::BeforeConnectPageSource(ROOT::Internal::RPageSource &pag
467467
// Iterate over all sub fields in memory and mark those as missing that are not in the descriptor.
468468
for (auto &field : fSubfields) {
469469
if (regularSubfields.count(field->GetFieldName()) == 0) {
470-
field->SetArtificial();
470+
CallSetArtificialOn(*field);
471471
}
472472
}
473473
}

0 commit comments

Comments
 (0)