ROOT 6.10/09 Reference Guide |
Key/value store of objects.
Given a name, a TDirectory
can store and retrieve an object. It will manage shared ownership through a shared_ptr
.
Example: TDirectory dirMC; TDirectory dirHiggs;
dirMC.Add("higgs", histHiggsMC); dirHiggs.Add("mc", histHiggsMC);
Definition at line 68 of file TDirectory.hxx.
Classes | |
struct | ToContentType |
Public Types | |
enum | EFindStatus { EFindStatus::kValidValue, EFindStatus::kValidValueBase, EFindStatus::kKeyNameNotFound, EFindStatus::kTypeMismatch } |
Status of the call to Find<T>(name). More... | |
Public Member Functions | |
template<class T > | |
void | Add (const std::string &name, const std::shared_ptr< T > &ptr) |
Add an existing object (rather a shared_ptr to it) to the TDirectory. More... | |
template<class T , class... ARGS> | |
std::shared_ptr< ToContentType_t< T > > | Create (const std::string &name, ARGS &&... args) |
Create an object of type T (passing some arguments to its constructor). More... | |
Internal::TDirectoryEntry | Find (const std::string &name) const |
Find the TDirectoryEntry associated to the name. More... | |
template<class T > | |
std::pair< Internal::TDirectoryEntry, EFindStatus > | Find (const std::string &name) const |
Find the TDirectoryEntry associated with the name. More... | |
template<class T > | |
std::shared_ptr< ToContentType_t< T > > | Get (const std::string &name) |
Get the object for a key. More... | |
Static Public Member Functions | |
static TDirectory & | Heap () |
Dedicated, process-wide TDirectory. More... | |
Private Types | |
using | ContentMap_t = std::unordered_map< std::string, Internal::TDirectoryEntry > |
The directory content is a hashed map of name => Internal::TDirectoryEntry . More... | |
template<class T > | |
using | ToContentType_t = typename ToContentType< T >::type |
Private Attributes | |
ContentMap_t | fContent |
The TDirectory 's content. More... | |
#include <ROOT/TDirectory.hxx>
|
private |
The directory content is a hashed map of name => Internal::TDirectoryEntry
.
Definition at line 71 of file TDirectory.hxx.
|
private |
Definition at line 86 of file TDirectory.hxx.
|
strong |
Status of the call to Find<T>(name).
Definition at line 113 of file TDirectory.hxx.
|
inline |
Add an existing object (rather a shared_ptr
to it) to the TDirectory.
The TDirectory will have shared ownership.
Definition at line 170 of file TDirectory.hxx.
|
inline |
Create an object of type T
(passing some arguments to its constructor).
The TDirectory
will have shared ownership of the object.
name | - Key of the object. |
args | - arguments to be passed to the constructor of T |
Definition at line 95 of file TDirectory.hxx.
|
inline |
Find the TDirectoryEntry associated to the name.
Returns empty TDirectoryEntry if nothing is found.
Definition at line 103 of file TDirectory.hxx.
|
inline |
Find the TDirectoryEntry associated with the name.
first
if nothing is found, or if the type does not match the expected type. second
contains the reason. second
is kValidValue, then static_pointer_cast<T
>(first
.GetPointer()) is shared_ptr<T
> to initially stored object second
is kValidValueBase, then first
.CastPointer<T
>() is a valid cast to base class T
of the stored object Definition at line 129 of file TDirectory.hxx.
|
inline |
Get the object for a key.
T
can be the object's type or a base class. The TDirectory
will return the same object for subsequent calls to Get().
shared_ptr
to the object or its base. TDirectoryUnknownKey | if no object is stored under this name. |
TDirectoryTypeMismatch | if the object stored under this name is of a type that is not a derived type of T . |
Definition at line 149 of file TDirectory.hxx.
|
static |
Dedicated, process-wide TDirectory.
|
private |
The TDirectory
's content.
Definition at line 74 of file TDirectory.hxx.