Skip to content

[rfile] Introduce special Put overload for TNamed - #23812

Open
silverweed wants to merge 3 commits into
root-project:masterfrom
silverweed:rfile_tnamed
Open

silverweed wants to merge 3 commits into
root-project:masterfrom
silverweed:rfile_tnamed

Conversation

@silverweed

@silverweed silverweed commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

This Pull request:

depends on #23811.
Adds an overload of Put that allows calling Put(tnamedObj) instead of Put(obj.GetName(), obj, obj.GetTitle()). To be seen if we want the same for Overwrite.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 9h 35m 21s ⏱️
 3 883 tests  3 680 ✅  29 💤   174 ❌
72 704 runs  68 622 ✅ 648 💤 3 434 ❌

For more details on these failures, see this check.

Results for commit 71d9768.

♻️ This comment has been updated with latest results.

Comment thread io/io/src/RFile.cxx
@jblomer jblomer added this to the 6.42.00 milestone Oct 26, 2026
Comment thread io/io/inc/ROOT/RFile.hxx Outdated
enum EPutFlags {
/// When encountering an object at the specified path, overwrite it with the new one instead of erroring out.
kPutAllowOverwrite = 0x1,
kPutFlag_AllowOverwrite = 0x1,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to use a enum class ....

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes it more cumbersome though to use the constants in a bit mask.

Comment thread io/io/inc/TDirectoryFile.h Outdated
Int_t WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *option="", Int_t bufsize=0) override;
Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Int_t bufsize=0) override;
Int_t WriteObjectAny(const void *obj, const TClass *cl, const char *name, Option_t *option="", Int_t bufsize=0) override;
Int_t WriteObjectAny(const void *obj, const char *title, const TClass *cl, const char *name, Option_t *option="", Int_t bufsize=0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to use the std::pair argument, as this is not a method that's usually called by user code so the odd syntax shouldn't hurt.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the latest commit

Comment thread io/io/src/RFile.cxx
}

void RFile::PutUntyped(std::string_view pathSV, const std::type_info &type, const void *obj, std::uint32_t flags)
void RFile::Put(const TNamed &namedObj, std::string_view dirPath)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a plan to allow the user to over-tide the name and title? For example

void RFile::Put(const TNamed &namedObj, std::string_view path, std::string_view title)

(with the unresolved question of being able or not of over-riding just the name and not the title).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, my idea behind this overload is to have the key information exactly match the TNamed's; if one wants to customize name and/or title they can always use the "regular" overload.
Plus, I want to keep this as simple as possible and avoid extra optional parameters (I'm already a bit on the fence about this whole overload as-is)

silverweed and others added 3 commits October 29, 2026 08:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants