#pragma once #include "resources/Identifier.h" #include namespace Feather { // Registry that maps Identifiers to objects // TODO: optimize ownership (move, forward, copying, etc). perhaps use pointers template class RegistryMap { std::map map; public: inline void Register(const Identifier& id, T&& value) { map.insert({ id, std::move(value) }); } inline const T& Get(const Identifier& id) const { return map.at(id); } //inline Identifier& GetKey(T& value) const {} inline size_t Size() const { return map.size(); } }; template class DefaultedRegistry : public RegistryMap { using string = std::string; const Identifier defaultKey; T& defaultValue; public: DefaultedRegistry(const string&& defaultKey) : defaultKey(Identifier(defaultKey)) {} }; }