28namespace Experimental {
33class TFileStorageInterface;
34class TFileSharedPtrCtor;
47 std::unique_ptr<Internal::TFileStorageInterface>
fStorage;
49 TFile(std::unique_ptr<Internal::TFileStorageInterface> &&storage);
55 friend Internal::TFileSharedPtrCtor;
141 return std::make_unique<T>(*Get<T>(
name));
191 TFilePtr(std::shared_ptr<TFile> &&);
204 operator bool()
const {
return fFile.get(); }
Key/value store of objects.
void Add(std::string_view name, const std::shared_ptr< T > &ptr)
Add an existing object (rather a shared_ptr to it) to the TDirectory.
Internal::TDirectoryEntry Find(std::string_view name) const
Find the TDirectoryEntry associated to the name.
Points to an object that stores or reads objects in ROOT's binary format.
const TFile * operator->() const
Dereference the file pointer, giving access to the TFileImplBase object.
TFilePtr(std::shared_ptr< TFile > &&)
Constructed by Open etc.
std::shared_ptr< TFile > fFile
TFile * operator->()
Dereference the file pointer, giving access to the TFileImplBase object.
void Write(std::string_view name)
Write an object that is already lifetime managed by this TFileImplBase.
void Write(std::string_view name, const T *obj)
Write an object that is not lifetime managed by this TFileImplBase.
static TFilePtr Recreate(std::string_view name, const Options_t &opts=Options_t())
Open a file with name for reading and writing.
TFile(std::unique_ptr< Internal::TFileStorageInterface > &&storage)
static TFilePtr Create(std::string_view name, const Options_t &opts=Options_t())
Open a file with name for reading and writing.
void WriteMemoryWithType(std::string_view name, const void *address, TClass *cl)
Serialize the object at address, using the object's TClass.
void Close()
Flush() and make the file non-writable: close it.
static std::string GetCacheDir()
Get the directory used for cached reads.
static TFilePtr Open(std::string_view name, const Options_t &opts=Options_t())
Open a file with name for reading.
void Write(std::string_view name, const T &obj)
Write an object that is not lifetime managed by this TFileImplBase.
~TFile()
Must not call Write() of all attached objects: some might not be needed to be written or writing migh...
void Flush()
Save all objects associated with this directory (including file header) to the storage medium.
std::unique_ptr< T > Read(std::string_view name)
Read the object for a key.
static std::string SetCacheDir(std::string_view path)
Set the new directory used for cached reads, returns the old directory.
static TFilePtr OpenForUpdate(std::string_view name, const Options_t &opts=Options_t())
Open an existing file with name for reading and writing.
std::unique_ptr< Internal::TFileStorageInterface > fStorage
Storage backend.
void Write(std::string_view name, std::shared_ptr< T > &&obj)
Hand over lifetime management of an object to this TFileImplBase, and write it.
The ROOT global object gROOT contains a list of all defined classes.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Namespace for new ROOT classes and functions.
basic_string_view< char > string_view
Options for TFile construction.
bool fCachedRead
Whether the file should be cached before reading.
int fAsyncTimeout
Timeout for asynchronous opening.
bool fAsynchronousOpen
Whether the file should be opened asynchronously, if available.
std::string fCacheDir
Where to cache the file. If empty, defaults to TFilePtr::GetCacheDir().
Options_t()
Default constructor needed for member inits.