15 #ifndef ROOT7_TDirectory
16 #define ROOT7_TDirectory
23 #include <type_traits>
24 #include <unordered_map>
28 namespace Experimental {
37 const char*
what() const noexcept final {
return fKeyName.c_str(); }
50 const char*
what() const noexcept final {
return fKeyName.c_str(); }
71 using ContentMap_t = std::unordered_map<std::string, Internal::TDirectoryEntry>;
79 using type =
typename std::enable_if<
80 !std::is_pointer<decaytype>::value
81 && !std::is_member_pointer<decaytype>::value
82 && !std::is_void<decaytype>::value,
94 template <
class T,
class...
ARGS>
95 std::shared_ptr<ToContentType_t<T>>
Create(
const std::string&
name,
ARGS&&... args) {
96 auto ptr = std::make_shared<ToContentType_t<T>>(std::forward<ARGS>(args)...);
128 std::pair<Internal::TDirectoryEntry, EFindStatus>
149 std::shared_ptr<ToContentType_t<T>>
Get(
const std::string&
name) {
150 const auto& pair = Find<T>(
name);
170 void Add(
const std::string&
name,
const std::shared_ptr<T>& ptr) {
176 <<
"Replacing object with name \"" << name <<
"\"" << std::endl;
177 idx->second.swap(entry);
Value known for this key name and type.
TDirectoryUnknownKey(const std::string &keyName)
typename ToContentType< T >::type ToContentType_t
std::shared_ptr< ToContentType_t< T > > Get(const std::string &name)
Get the object for a key.
static TDirectory & Heap()
Dedicated, process-wide TDirectory.
EFindStatus
Status of the call to Find<T>(name).
std::unordered_map< std::string, Internal::TDirectoryEntry > ContentMap_t
The directory content is a hashed map of name => Internal::TDirectoryEntry.
Warnings about likely unexpected behavior.
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).
Internal::TDirectoryEntry Find(const std::string &name) const
Find the TDirectoryEntry associated to the name.
const char * what() const noexceptfinal
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.
ContentMap_t fContent
The TDirectory's content.
Objects of this class are thrown to signal that the value known under the given name ...
typename std::decay< T >::type decaytype
std::pair< Internal::TDirectoryEntry, EFindStatus > Find(const std::string &name) const
Find the TDirectoryEntry associated with the name.
typename std::enable_if< !std::is_pointer< decaytype >::value &&!std::is_member_pointer< decaytype >::value &&!std::is_void< decaytype >::value, decaytype >::type type
The provided type does not match the value's type.
No key is known for this name.
#define R__LOG_HERE(LEVEL, GROUP)
Key/value store of objects.
TDirectoryTypeMismatch(const std::string &keyName)
Value known for this key name and base type.
Objects of this class are thrown to signal that no key with that name exists.
const char * what() const noexceptfinal