15 #include <type_traits>
17 #include <unordered_map>
43 void add(
const std::string&
name,
T&&
object);
51 const T&
get(
const std::string&
name)
const;
57 virtual const std::type_info&
type()
const = 0;
66 const std::type_info&
type()
const {
return typeid(
T); }
70 std::unordered_map<std::string, std::unique_ptr<IHolder>>
m_store;
78 : m_logger(std::move(logger)) {}
83 throw std::invalid_argument(
"Object can not have an empty name");
85 if (0 < m_store.count(name)) {
86 throw std::invalid_argument(
"Object '" + name +
"' already exists");
94 auto it = m_store.find(name);
95 if (
it == m_store.end()) {
96 throw std::out_of_range(
"Object '" + name +
"' does not exists");
99 if (
typeid(
T) != holder->
type()) {
100 throw std::out_of_range(
"Type missmatch for object '" + name +
"'");