16#ifndef ROOT7_RDirectory
17#define ROOT7_RDirectory
25#include <unordered_map>
30namespace Experimental {
40 const char *
what() const noexcept final {
return fKeyName.c_str(); }
52 const char *
what() const noexcept final {
return fKeyName.c_str(); }
75 using ContentMap_t = std::unordered_map<std::string, Internal::RDirectoryEntry>;
84 typename std::enable_if<!std::is_pointer<decaytype>::value && !std::is_member_pointer<decaytype>::value &&
85 !std::is_void<decaytype>::value,
97 template <
class T,
class...
ARGS>
100 auto ptr = std::make_shared<ToContentType_t<T>>(std::forward<ARGS>(args)...);
155 const auto &pair = Find<T>(
name);
176 std::string sName(
name);
180 idx->second.swap(entry);
189 std::string sName(
name);
#define R__LOG_HERE(LEVEL, GROUP)
std::shared_ptr< U > CastPointer() const
std::shared_ptr< void > & GetPointer()
Retrieve the shared_ptr of the referenced object.
Objects of this class are thrown to signal that the value known under the given name .
const char * what() const noexcept final
RDirectoryTypeMismatch(std::string_view keyName)
Objects of this class are thrown to signal that no key with that name exists.
const char * what() const noexcept final
RDirectoryUnknownKey(std::string_view keyName)
Key/value store of objects.
typename ToContentType< T >::type ToContentType_t
bool Remove(std::string_view name)
Remove entry from RDirectory (if exists)
static RDirectory & Heap()
Dedicated, process-wide RDirectory.
Internal::RDirectoryEntry Find(std::string_view name) const
Find the RDirectoryEntry associated to the name.
std::shared_ptr< ToContentType_t< T > > Get(std::string_view name)
Get the object for a key.
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.
std::unordered_map< std::string, Internal::RDirectoryEntry > ContentMap_t
The directory content is a hashed map of name => Internal::RDirectoryEntry.
EFindStatus
Status of the call to Find<T>(name).
@ kValidValue
Value known for this key name and type.
@ kValidValueBase
Value known for this key name and base type.
@ kTypeMismatch
The provided type does not match the value's type.
@ kKeyNameNotFound
No key is known for this name.
ContentMap_t fContent
The RDirectory's content.
std::pair< Internal::RDirectoryEntry, EFindStatus > Find(std::string_view name) const
Find the RDirectoryEntry associated with the name.
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).
basic_string_view< char > string_view
@ kWarning
Warnings about likely unexpected behavior.
typename std::decay< T >::type decaytype
typename std::enable_if<!std::is_pointer< decaytype >::value &&!std::is_member_pointer< decaytype >::value &&!std::is_void< decaytype >::value, decaytype >::type type