Skip to content

Addition of Unique Ptr type Open interface with implementation #14017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions io/io/inc/TFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ class TFile : public TDirectoryFile {
static TFile *Open(const char *name, Option_t *option = "",
const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
Int_t netopt = 0);

static std::unique_ptr<TFile> OpenU(const char *name, Option_t *option = "",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static std::unique_ptr<TFile> OpenU(const char *name, Option_t *option = "",
static std::unique_ptr<TFile> OpenUniquePtr(const char *name, Option_t *option = "",

Copy link
Member

Choose a reason for hiding this comment

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

We shall have a naming discussion in Mattermost's I/O channel. I promise that nobody will want to spell OpenUniquePtr :-) And I don't want to see Bronch-style Opan either :-)

Copy link
Author

Choose a reason for hiding this comment

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

@Axel-Naumann @pcanal Is it fine if we keep it as OpenU for the time being?

const char *ftitle = "", Int_t compress = ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault,
Int_t netopt = 0);

static TFile *Open(TFileOpenHandle *handle);

static EFileType GetType(const char *name, Option_t *option = "", TString *prefix = nullptr);
Expand Down
6 changes: 6 additions & 0 deletions io/io/src/TFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4068,6 +4068,12 @@ TFile *TFile::OpenFromCache(const char *name, Option_t *, const char *ftitle,
/// In RECREATE mode, a nullptr is returned if the file can not be created.
/// In UPDATE mode, a nullptr is returned if the file cannot be created or opened.

std::unique_ptr<TFile> OpenU(const char *url, Option_t *options, const char *ftitle,
Int_t compress, Int_t netopt)
{
return std::unique_ptr<TFile>{TFile::Open(url, options, ftitle, compress, netopt)};
}

TFile *TFile::Open(const char *url, Option_t *options, const char *ftitle,
Int_t compress, Int_t netopt)
{
Expand Down