Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches
IOUtils.hpp
Go to the documentation of this file.
1#ifndef IOUTILS_H
2#define IOUTILS_H
3
4#include <TFile.h>
5#include <TString.h>
6#include <TSystem.h>
7
18namespace IO {
19
30void SetRootFilesBaseDir(const TString &dir);
31
34TString GetRootFilesBaseDir();
35
50void SetThreadSafe(Bool_t enabled = kTRUE);
51
54Bool_t IsThreadSafe();
55
71TFile *OpenForReading(const TString &subpath);
72
98TFile *OpenForWriting(const TString &subpath, const TString mode = "RECREATE");
99
114public:
119
120private:
121 Bool_t engaged_;
123 ScopedRootLock &operator=(const ScopedRootLock &);
124};
125} // namespace IO
126
127#endif
ScopedRootLock()
Acquire the shared file-open lock if thread-safe mode is on.
Definition IOUtils.cpp:48
~ScopedRootLock()
Release the lock if this guard acquired one.
Definition IOUtils.cpp:53
Path-aware ROOT file helpers with optional thread-safe opening.
Definition IOUtils.hpp:18
TString GetRootFilesBaseDir()
Current base directory for relative subpaths, without trailing slash.
Definition IOUtils.cpp:37
void SetRootFilesBaseDir(const TString &dir)
Set the base directory that relative subpaths resolve against.
Definition IOUtils.cpp:30
Bool_t IsThreadSafe()
Whether thread-safe file opening is currently engaged.
Definition IOUtils.cpp:46
void SetThreadSafe(Bool_t enabled=kTRUE)
Enable ROOT thread safety and serialise file opening.
Definition IOUtils.cpp:39
TFile * OpenForWriting(const TString &subpath, const TString mode="RECREATE")
Open a ROOT file for writing, creating parent directories first.
Definition IOUtils.cpp:68
TFile * OpenForReading(const TString &subpath)
Open a ROOT file for reading, resolved against the base directory.
Definition IOUtils.cpp:58