1 #ifndef cetlib_registry_via_id_h 2 #define cetlib_registry_via_id_h 11 #include "cetlib_except/exception.h" 16 #include <type_traits> 20 template <
class K,
class V>
24 template <
class K,
class V, K (V::*)() const = &V::
id>
33 template <
class K,
class V>
42 typedef typename collection_type::key_type
key_type;
52 return the_registry_().empty();
57 return the_registry_().size();
64 return the_registry_().begin();
69 return the_registry_().end();
74 return the_registry_().cbegin();
79 return the_registry_().cend();
86 template <
class FwdIt>
87 static std::enable_if_t<
88 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
91 put(FwdIt begin, FwdIt
end);
94 template <
class FwdIt>
95 static std::enable_if_t<
96 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
99 put(FwdIt begin, FwdIt end);
102 static void put(collection_type
const&
c);
105 static collection_type
const&
108 return the_registry_();
110 static V
const&
get(
K const&
key);
111 static bool get(
K const&
key, V&
value) noexcept;
115 static collection_type&
118 static collection_type the_registry;
127 template <
class K,
class V>
132 the_registry_().emplace(
id, value);
136 template <
class K,
class V>
137 template <
class FwdIt>
140 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
148 template <
class K,
class V>
149 template <
class FwdIt>
152 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
156 the_registry_().insert(
b,
e);
159 template <
class K,
class V>
163 put(c.cbegin(), c.cend());
169 template <
class K,
class V>
174 if (it == the_registry_().
end())
176 <<
"Key \"" << key <<
"\" not found in registry";
180 template <
class K,
class V>
186 if (it == the_registry_().
end()) {
::xsd::cxx::tree::id< char, ncname > id
collection_type::const_iterator const_iterator
static const_iterator begin()
::xsd::cxx::tree::exception< char > exception
static const_iterator end()
collection_type::mapped_type mapped_type
static collection_type & the_registry_()
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
static const_iterator cend()
const XML_Char int const XML_Char * value
collection_type::size_type size_type
collection_type::key_type key_type
static collection_type const & get() noexcept
static detail::must_have_id< K, V >::type put(V const &value)
static const_iterator cbegin()
collection_type::value_type value_type
std::map< K const, V > collection_type