ROOT 6.18/05 Reference Guide |
Key/value store of objects.
Given a name, a RDirectory
can store and retrieve an object. It will manage shared ownership through a shared_ptr
.
Example: RDirectory dirMC; RDirectory dirHiggs;
dirMC.Add("higgs", histHiggsMC); dirHiggs.Add("mc", histHiggsMC);
Definition at line 70 of file RDirectory.hxx.
Classes | |
struct | ToContentType |
Public Types | |
enum class | EFindStatus { kValidValue , kValidValueBase , kKeyNameNotFound , kTypeMismatch } |
Status of the call to Find<T>(name). More... | |
Public Member Functions | |
template<class T > | |
void | Add (std::string_view name, const std::shared_ptr< T > &ptr) |
Add an existing object (rather a shared_ptr to it) to the RDirectory. More... | |
template<class T , class... ARGS> | |
std::shared_ptr< ToContentType_t< T > > | Create (std::string_view name, ARGS &&... args) |
Create an object of type T (passing some arguments to its constructor). More... | |
Internal::RDirectoryEntry | Find (std::string_view name) const |
Find the RDirectoryEntry associated to the name. More... | |
template<class T > | |
std::pair< Internal::RDirectoryEntry, EFindStatus > | Find (std::string_view name) const |
Find the RDirectoryEntry associated with the name. More... | |
template<class T > | |
std::shared_ptr< ToContentType_t< T > > | Get (std::string_view name) |
Get the object for a key. More... | |
Static Public Member Functions | |
static RDirectory & | Heap () |
Dedicated, process-wide RDirectory. More... | |
Private Types | |
using | ContentMap_t = std::unordered_map< std::string, Internal::RDirectoryEntry > |
The directory content is a hashed map of name => Internal::RDirectoryEntry . More... | |
template<class T > | |
using | ToContentType_t = typename ToContentType< T >::type |
Private Attributes | |
ContentMap_t | fContent |
The RDirectory 's content. More... | |
#include <ROOT/RDirectory.hxx>
|
private |
The directory content is a hashed map of name => Internal::RDirectoryEntry
.
Definition at line 75 of file RDirectory.hxx.
|
private |
Definition at line 89 of file RDirectory.hxx.
|
strong |
Status of the call to Find<T>(name).
Definition at line 118 of file RDirectory.hxx.
|
inline |
Add an existing object (rather a shared_ptr
to it) to the RDirectory.
The RDirectory will have shared ownership.
Definition at line 172 of file RDirectory.hxx.
|
inline |
Create an object of type T
(passing some arguments to its constructor).
The RDirectory
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 98 of file RDirectory.hxx.
|
inline |
Find the RDirectoryEntry associated to the name.
Returns empty RDirectoryEntry if nothing is found.
Definition at line 107 of file RDirectory.hxx.
|
inline |
Find the RDirectoryEntry 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 133 of file RDirectory.hxx.
|
inline |
Get the object for a key.
T
can be the object's type or a base class. The RDirectory
will return the same object for subsequent calls to Get().
shared_ptr
to the object or its base. RDirectoryUnknownKey | if no object is stored under this name. |
RDirectoryTypeMismatch | if the object stored under this name is of a type that is not a derived type of T . |
Definition at line 153 of file RDirectory.hxx.
|
static |
Dedicated, process-wide RDirectory.
|
private |
The RDirectory
's content.
Definition at line 78 of file RDirectory.hxx.