30namespace Experimental {
 
   60static void AddFilesToClose(std::weak_ptr<ROOT::Experimental::RFile> pFile)
 
   63      std::vector<std::weak_ptr<ROOT::Experimental::RFile>> fFiles;
 
   67         for (
auto &wFile: fFiles) {
 
   68            if (
auto sFile = wFile.lock()) {
 
   74   static CloseFiles_t closer;
 
   76   std::lock_guard<std::mutex> lock(closer.fMutex);
 
   77   closer.fFiles.emplace_back(pFile);
 
   87   TV6Storage(
const std::string &
name, 
const std::string &
mode): fOldFile(::
TFile::Open(
name.c_str(), 
mode.c_str())) {}
 
   91   void Close() final { fOldFile->
Close(); }
 
   93   ~TV6Storage() { 
delete fOldFile; }
 
   95   void WriteMemoryWithType(std::string_view 
name, 
const void *address, 
TClass *cl) 
final 
  104   AddFilesToClose(
fFile);
 
  110   std::string ret(
mode);
 
  112      ret += 
" CACHEREAD ";
 
  114      ret += 
" TIMEOUT=" + std::to_string(opts.
fAsyncTimeout) + 
" ";
 
  118static std::mutex &GetCacheDirMutex()
 
  120   static std::mutex sMutex;
 
  124static std::unique_ptr<ROOT::Experimental::Internal::RFileStorageInterface>
 
  129   struct SetCacheDirRAII_t {
 
  130      std::string fOldCacheDir;
 
  131      std::lock_guard<std::mutex> fLock;
 
  133      SetCacheDirRAII_t(
bool need): fLock(GetCacheDirMutex())
 
  141         if (!fOldCacheDir.empty())
 
  146   auto v6storage = std::make_unique<TV6Storage>(std::string(
name), GetV6RFileOpts(
mode, opts));
 
  149   return std::unique_ptr<RFileStorageInterface>{std::move(v6storage)};
 
  157   using namespace Internal;
 
  158   auto file = std::make_shared<RFileSharedPtrCtor>(OpenV6RFile(
name, 
"READ", opts));
 
  166   using namespace Internal;
 
  167   auto file = std::make_shared<RFileSharedPtrCtor>(OpenV6RFile(
name, 
"CREATE", opts));
 
  175   using namespace Internal;
 
  176   auto file = std::make_shared<RFileSharedPtrCtor>(OpenV6RFile(
name, 
"RECREATE", opts));
 
  184   using namespace Internal;
 
  185   auto file = std::make_shared<RFileSharedPtrCtor>(OpenV6RFile(
name, 
"UPDATE", opts));
 
  191   std::lock_guard<std::mutex> lock(GetCacheDirMutex());
 
  200   std::lock_guard<std::mutex> lock(GetCacheDirMutex());
 
  201   return ::TFile::GetCacheFileDir();
 
  207   : fStorage(std::move(storage))
 
  224   fStorage->WriteMemoryWithType(
name, address, cl);
 
Option_t Option_t TPoint TPoint const char mode
RFileSharedPtrCtor(std::unique_ptr< RFileStorageInterface > &&storage)
Base class for RFile storage backends.
virtual void WriteMemoryWithType(std::string_view name, const void *address, TClass *cl)=0
virtual ~RFileStorageInterface()=default
Key/value store of objects.
static RDirectory & Heap()
Dedicated, process-wide RDirectory.
Points to an object that stores or reads objects in ROOT's binary format.
std::shared_ptr< RFile > fFile
RFilePtr(std::shared_ptr< RFile > &&)
Constructed by Open etc.
static RFilePtr Recreate(std::string_view name, const Options_t &opts=Options_t())
Open a file with name for reading and writing.
RFile(std::unique_ptr< Internal::RFileStorageInterface > &&storage)
void Flush()
Save all objects associated with this directory (including file header) to the storage medium.
static std::string SetCacheDir(std::string_view path)
Set the new directory used for cached reads, returns the old directory.
static std::string GetCacheDir()
Get the directory used for cached reads.
~RFile()
Must not call Write() of all attached objects: some might not be needed to be written or writing migh...
static RFilePtr Open(std::string_view name, const Options_t &opts=Options_t())
Open a file with name for reading.
static RFilePtr OpenForUpdate(std::string_view name, const Options_t &opts=Options_t())
Open an existing 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.
static RFilePtr Create(std::string_view name, const Options_t &opts=Options_t())
Open a file with name for reading and writing.
void Close()
Flush() and make the file non-writable: close it.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Int_t WriteObjectAny(const void *obj, const char *classname, const char *name, Option_t *option="", Int_t bufsize=0) override
Write object from pointer of class classname in this directory.
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
static const char * GetCacheFileDir()
Get the directory where to locally stage/cache remote files.
static Bool_t SetCacheFileDir(ROOT::Internal::TStringView cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
void Close(Option_t *option="") override
Close a file.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Options for RFile 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.