26 #include <unordered_map>
61 template <
class RegisteredType,
class KeyType = std::
string,
class =
void>
84 static const RegisteredType&
get(
const KeyType& key)
86 std::lock_guard<std::recursive_mutex> guard {registeredElementsMutex()};
89 throw std::invalid_argument {
"No factory for this key! "};
91 return registeredElements().at(key);
94 static bool has(
const KeyType& key)
96 std::lock_guard<std::recursive_mutex> guard {registeredElementsMutex()};
97 return registeredElements().end() != registeredElements().find(key);
107 std::lock_guard<std::recursive_mutex> guard {registeredElementsMutex()};
108 registeredElements()[key] = std::move(element);
117 std::lock_guard<std::recursive_mutex> guard {registeredElementsMutex()};
118 std::vector<KeyType> result;
119 result.reserve(registeredElements().size());
120 for (
const auto& elem : registeredElements())
122 result.emplace_back(elem.first);
134 return elementContainer;
136 static std::recursive_mutex& registeredElementsMutex()
138 static std::recursive_mutex elementContainerMutex;
139 return elementContainerMutex;