ROOT  6.06/09
Reference Guide
Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
ROOT::TDirectory Class Reference

Key/value store of objects.

Given a name, a TDirectory can store and retrieve an object. It will manage ownership through a TCoopPtr: if you delete the object, the object will be gone from the TDirectory. Once the TDirectoryis destructed, the objects it contains are destructed (unless other TCoopPtrs reference the same object).

Example: TDirectory dirBackgrounds; TDirectory dirQCD; TDirectory dirHiggs;

Definition at line 42 of file TDirectory.h.

Public Member Functions

template<class T , class... ARGS>
TCoopPtr< T > Create (const std::string &name, ARGS...args)
 Create an object of type T (passing some arguments to its constructor). More...
 
const TKeyFindKey (const std::string &name) const
 
template<class T >
const TKeyAdd (const std::string &name, TCoopPtr< T > ptr)
 Add an existing object (rather a TCoopPtr to it) to the TDirectory. More...
 

Static Public Member Functions

static TDirectoryHeap ()
 Dedicated, process-wide TDirectory. More...
 

Private Types

using Value_t = std::shared_ptr< Internal::TCoopPtrTypeErasedBase >
 The values referenced by a TDirectory are type erased TCoopPtrs: they can be of any type; the actual type is determined through the virtual interface of Internal::TCoopPtrTypeErasedBase. More...
 
using ContentMap_t = std::unordered_map< TKey, Value_t >
 The directory content is a hashed map of TKey => Value_t. More...
 

Private Attributes

ContentMap_t fContent
 The TDirectory's content. More...
 

#include <ROOT/TDirectory.h>

+ Inheritance diagram for ROOT::TDirectory:
+ Collaboration diagram for ROOT::TDirectory:

Member Typedef Documentation

using ROOT::TDirectory::ContentMap_t = std::unordered_map<TKey, Value_t>
private

The directory content is a hashed map of TKey => Value_t.

TODO: really? Or just std::string => Value_t - that should be enough! Rather add some info (time stamp etc) to the Value_t.

Definition at line 52 of file TDirectory.h.

The values referenced by a TDirectory are type erased TCoopPtrs: they can be of any type; the actual type is determined through the virtual interface of Internal::TCoopPtrTypeErasedBase.

Definition at line 47 of file TDirectory.h.

Member Function Documentation

template<class T >
const TKey& ROOT::TDirectory::Add ( const std::string &  name,
TCoopPtr< T >  ptr 
)
inline

Add an existing object (rather a TCoopPtr to it) to the TDirectory.

The TDirectory will not delete the object but it will need to be notified once the object is deleted.

Definition at line 85 of file TDirectory.h.

template<class T , class... ARGS>
TCoopPtr<T> ROOT::TDirectory::Create ( const std::string &  name,
ARGS...  args 
)
inline

Create an object of type T (passing some arguments to its constructor).

The TDirectory will register the object.

Parameters
name- Key of the object.
args- arguments to be passed to the constructor of T

Definition at line 65 of file TDirectory.h.

const TKey* ROOT::TDirectory::FindKey ( const std::string &  name) const
inline

Definition at line 74 of file TDirectory.h.

ROOT::TDirectory & TDirectory::Heap ( )
static

Dedicated, process-wide TDirectory.

Note
This is not thread-safe. You will need to syncronize yourself. In general it's a bad idea to use a global collection in a multi-threaded environment; ROOT itself does not make use of it. It is merely offered for historical, process-wide object registration by name. Instead, pass a pointer to the object where you need to access it - this is also much faster than a lookup by name.

Definition at line 20 of file TFile.cxx.

Member Data Documentation

ContentMap_t ROOT::TDirectory::fContent
private

The TDirectory's content.

Definition at line 55 of file TDirectory.h.


The documentation for this class was generated from the following files: