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