12#ifndef ROOT_TDirectory
13#define ROOT_TDirectory
29#ifdef R__LESS_INCLUDES
42 struct TDirectoryAtomicAdapter;
114 (*fDirectory).RegisterContext(
this);
193 virtual Bool_t cd(
const char *path);
195 void Delete(
const char *namecycle=
"")
override;
205 template <
class T>
inline T*
Get(
const char* namecycle)
212 template <
class T>
inline void GetObject(
const char* namecycle, T*& ptr)
216 virtual void *
GetObjectChecked(
const char *namecycle,
const char* classname);
232 virtual const char *
GetPath()
const;
241 const char * =
"",
Int_t = 1,
242 Int_t = 0) {
return nullptr;}
246 virtual void pwd()
const;
259 void SetName(
const char* newname)
override;
280 template <
typename T>
281 inline std::enable_if_t<!std::is_base_of<TObject, T>::value,
Int_t>
294 template <
typename T>
295 inline std::enable_if_t<std::is_base_of<TObject, T>::value,
Int_t>
345 template <
typename T>
346 explicit operator T*()
const {
347 return (T *)
fValue->load();
357 return fValue->load() == other;
361 return fValue->load() != other;
365 return fValue->load() == other;
369 return fValue->load() != other;
376 fValue->exchange(newvalue);
384#define gDirectory (::ROOT::Internal::TDirectoryAtomicAdapter{})
#define ClassDefOverride(name, id)
Using a TBrowser one can browse all ROOT objects.
TClass instances represent classes, structs and namespaces in the ROOT type system.
TDirectory::TContext keeps track and restore the current directory.
TContext & operator=(TContext &)=delete
TContext(TDirectory *previous, TDirectory *newCurrent)
std::atomic< bool > fDirectoryWait
Set to true during the destructor execution.
void RegisterCurrentDirectory()
void CdNull()
Set the current directory to null.
TContext(TDirectory *newCurrent)
TContext * fPrevious
Set to true if a TDirectory might still access this object.
std::atomic< bool > fActiveDestructor
Pointer to the previous current directory.
TContext(TContext &)=delete
Pointer to the next TContext in the implied list of context pointing to fPrevious.
TContext * fNext
Pointer to the next TContext in the implied list of context pointing to fPrevious.
std::atomic< TDirectory * > fDirectory
Describe directory structure in memory.
std::shared_ptr< std::atomic< TDirectory * > > SharedGDirectory_t
Pointer to a list of TContext object pointing to this TDirectory.
virtual Long64_t GetSeekDir() const
Bool_t cd1(const char *path)
flag to add histograms, graphs,etc to the directory
void Delete(const char *namecycle="") override
Delete Objects or/and keys in a directory.
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
virtual TList * GetList() const
virtual void SetSeekDir(Long64_t)
TDirectory(const TDirectory &directory)=delete
virtual Int_t Write(const char *=nullptr, Int_t=0, Int_t=0) override
Write this object to the current directory.
virtual Int_t AppendKey(TKey *)
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
virtual Int_t GetNkeys() const
virtual Int_t GetNbytesKeys() const
virtual const char * GetPath() const
Returns the full path of the directory.
std::atomic_flag fSpinLock
Counter delaying the TDirectory destructor from finishing.
virtual void ReadAll(Option_t *="")
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void * GetObjectUnchecked(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void DeleteAll(Option_t *option="")
Delete all objects from memory.
std::atomic< size_t > fContextPeg
thread local gDirectory pointing to this object.
virtual void SetModified()
std::vector< SharedGDirectory_t > fGDirectories
virtual void rmdir(const char *name)
Removes subdirectory from the directory When directory is deleted, all keys in all subdirectories wil...
void Copy(TObject &) const override
Copy this to obj.
static Bool_t AddDirectoryStatus()
Static function: see TDirectory::AddDirectory for more comments.
void FillFullPath(TString &buf) const
Recursive method to fill full path for directory.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add objects like histograms, TGraph2D, etc in memory.
void CleanTargets()
Clean the pointers to this object (gDirectory, TContext, etc.).
void ls(Option_t *option="") const override
List Directory contents.
virtual Int_t WriteObjectAny(const void *, const TClass *, const char *, Option_t *="", Int_t=0)
TContext * fContext
Buffer for GetPath() function.
virtual TFile * OpenFile(const char *, Option_t *="", const char *="", Int_t=1, Int_t=0)
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
void RegisterGDirectory(SharedGDirectory_t &ptr)
Register a std::atomic<TDirectory*> that will soon be pointing to this TDirectory object.
virtual void WriteDirHeader()
std::enable_if_t<!std::is_base_of< TObject, T >::value, Int_t > WriteObject(const T *obj, const char *name, Option_t *option="", Int_t bufsize=0)
Write an object with proper type checking.
Int_t Sizeof() const override
Return size of the TNamed part of the TObject.
TDirectory()
Directory default constructor.
static void DecodeNameCycle(const char *namecycle, char *name, Short_t &cycle, const size_t namesize=0)
Decode a namecycle "aap;2" into name "aap" and cycle "2".
static Bool_t Cd(const char *path)
Change current directory to "path".
void Clear(Option_t *option="") override
Delete all objects from a Directory list.
virtual Int_t WriteTObject(const TObject *obj, const char *name=nullptr, Option_t *="", Int_t=0)
Write an object with proper type checking.
virtual void Add(TObject *obj, Bool_t replace=kFALSE)
virtual Int_t WriteObjectAny(const void *, const char *, const char *, Option_t *="", Int_t=0)
virtual TFile * GetFile() const
TObject * FindObject(const char *name) const override
Find object by name in the list of memory objects.
virtual void Build(TFile *motherFile=nullptr, TDirectory *motherDir=nullptr)
void Print(Option_t *option="") const override
Print all objects in the directory.
virtual Bool_t cd()
Change current directory to "this" directory.
virtual ~TDirectory()
Destructor.
virtual Int_t ReadKeys(Bool_t=kTRUE)
static Bool_t Cd1(const char *path)
Change current directory to "path".
virtual Bool_t IsWritable() const
virtual TKey * GetKey(const char *, Short_t=9999) const
virtual void Purge(Short_t=1)
void UnregisterContext(TContext *ctxt)
UnRegister a TContext pointing to this TDirectory object.
virtual Int_t ReadTObject(TObject *, const char *)
virtual void SetWritable(Bool_t)
virtual Bool_t IsModified() const
virtual void SetTRefAction(TObject *, TObject *)
virtual void SaveSelf(Bool_t=kFALSE)
void RecursiveRemove(TObject *obj) override
Recursively remove object from a Directory.
virtual Int_t SaveObjectAs(const TObject *, const char *="", Option_t *="") const
Save object in filename, if filename is nullptr or "", a file with "<objectname>.root" is created.
virtual TKey * FindKey(const char *) const
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
void SetName(const char *newname) override
Set the name for directory If the directory name is changed after the directory was written once,...
void BuildDirectory(TFile *motherFile, TDirectory *motherDir)
Initialise directory to defaults.
virtual Int_t GetBufferSize() const
virtual Long64_t GetSeekParent() const
virtual void SetMother(TObject *mother)
virtual Long64_t GetSeekKeys() const
virtual TList * GetListOfKeys() const
static SharedGDirectory_t & GetSharedLocalCurrentDirectory()
Return the (address of) a shared pointer to the struct holding the actual thread local gDirectory poi...
std::enable_if_t< std::is_base_of< TObject, T >::value, Int_t > WriteObject(const T *obj, const char *name, Option_t *option="", Int_t bufsize=0)
Write an object with proper type checking.
virtual TObject * FindObjectAnyFile(const char *) const
static Bool_t fgAddDirectory
MSVC doesn't support = ATOMIC_FLAG_INIT;.
TDirectory * GetMotherDir() const
virtual const char * GetPathStatic() const
Returns the full path of the directory.
static std::atomic< TDirectory * > & CurrentDirectory()
Return the current directory for the current thread.
TObject * GetMother() const
void Browse(TBrowser *b) override
Browse the content of the directory.
void GetObject(const char *namecycle, T *&ptr)
Get an object with proper type checking.
virtual void pwd() const
Print the path of the directory.
virtual void * GetObjectChecked(const char *namecycle, const char *classname)
See documentation of TDirectory::GetObjectCheck(const char *namecycle, const TClass *cl)
virtual TObject * CloneObject(const TObject *obj, Bool_t autoadd=kTRUE)
Clone an object.
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
void RegisterContext(TContext *ctxt)
Register a TContext pointing to this TDirectory object.
virtual TKey * FindKeyAny(const char *) const
T * Get(const char *namecycle)
See documentation of TDirectoryFile::Get(const char *namecycle)
virtual Int_t Write(const char *=nullptr, Int_t=0, Int_t=0) const override
Write this object to the current directory.
virtual void SetBufferSize(Int_t)
void Paint(Option_t *option="") override
Paint all objects in the directory.
virtual TObject * FindObjectAny(const char *name) const
Find object by name in the list of memory objects of the current directory or its sub-directories.
void operator=(const TDirectory &)=delete
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Book space in a file, create I/O buffers, to fill them, (un)compress them.
The TNamed class is the base class for all named ROOT classes.
Mother of all ROOT objects.
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Internal class used in the implementation of gDirectory The objects of type TDirectoryAtomicAdapter s...
TDirectory * operator->() const
TDirectory * operator=(TDirectory *newvalue)
TDirectoryAtomicAdapter()
bool operator!=(TDirectory *other) const
bool operator==(TDirectory *other) const
bool operator!=(const TDirectory *other) const
TDirectory::SharedGDirectory_t & fValue
bool operator==(const TDirectory *other) const