28 #include <unordered_set>
32 template<
typename K,
typename V>
34 std::unordered_set<std::pair<K, std::shared_ptr<V>>> elems;
45 virtual std::shared_ptr<V>
load(
const K& key) {}
49 virtual const T&
get(
const K& key) {
50 auto it = elems.find(name);
51 if(it != elems.end())
return it->second;
52 std::shared_ptr<V> new_elem;
53 new_elem = elems[key] =
load(key);
virtual const T & get(const K &key)
Obtain an element or construct a new one from a provided construct which accepts key.
static Manager< K, V > & get_instance()
Return the singleton.
static Manager< K, V > * singleton
Global manager object.
virtual std::shared_ptr< V > load(const K &key)
Load an element, this is the function that must be defined by the inheritor.