16 #ifndef ROOT7_TDirectory 17 #define ROOT7_TDirectory 24 #include <type_traits> 25 #include <unordered_map> 30 namespace 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::TDirectoryEntry>;
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)...);
109 auto idx = fContent.find(std::string(name));
110 if (idx == fContent.end())
135 auto idx = fContent.find(std::string(name));
136 if (idx == fContent.end())
137 return {
nullptr, EFindStatus::kKeyNameNotFound};
139 return {idx->second, EFindStatus::kValidValue};
141 return {idx->second, EFindStatus::kValidValueBase};
142 return {
nullptr, EFindStatus::kTypeMismatch};
155 const auto &pair = Find<T>(
name);
159 case EFindStatus::kValidValue:
return std::static_pointer_cast<
ToContentType_t<T>>(entry.GetPointer());
161 case EFindStatus::kTypeMismatch:
176 std::string sName(name);
177 auto idx = fContent.find(sName);
178 if (idx != fContent.end()) {
180 idx->second.swap(entry);
182 fContent[sName].swap(entry);
basic_string_view< char > string_view
Namespace for new ROOT classes and functions.
Internal::TDirectoryEntry Find(std::string_view name) const
Find the TDirectoryEntry associated to the name.
TDirectoryTypeMismatch(std::string_view keyName)
void Add(std::string_view name, const std::shared_ptr< T > &ptr)
Add an existing object (rather a shared_ptr to it) to the TDirectory.
TDirectoryUnknownKey(std::string_view keyName)
typename std::enable_if<!std::is_pointer< decaytype >::value &&!std::is_member_pointer< decaytype >::value &&!std::is_void< decaytype >::value, decaytype >::type type
typename ToContentType< T >::type ToContentType_t
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.
ContentMap_t fContent
The TDirectory's content.
std::pair< Internal::TDirectoryEntry, EFindStatus > Find(std::string_view name) const
Find the TDirectoryEntry 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).
Objects of this class are thrown to signal that the value known under the given name ...
typename std::decay< T >::type decaytype
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
std::shared_ptr< U > CastPointer() const
const char * what() const noexcept final
const char * what() const noexcept final
#define R__LOG_HERE(LEVEL, GROUP)
Key/value store of objects.
Objects of this class are thrown to signal that no key with that name exists.
std::shared_ptr< ToContentType_t< T > > Get(std::string_view name)
Get the object for a key.