#ifndef RESOURCE_MANAGER_H #define RESOURCE_MANAGER_H #include #include #include #include #include template class ResourceManager{ private: std::map> resourceMap; public: void load(Identifier id, const std::string& path); Resource& get(Identifier id); const Resource& get(Identifier id) const; }; template void ResourceManager::load(Identifier id, const std::string& path){ auto resource = std::make_unique(); if( !resource->loadFromFile(path) ){ throw("ResoureManager::load - Failed to load filename: " + path); } auto inserted = resourceMap.insert( std::make_pair(id, std::move(resource)) ); assert(inserted.second); } template Resource& ResourceManager::get(Identifier id) { auto found = resourceMap.find(id); assert(found != resourceMap.end()); return *found->second; } template const Resource& ResourceManager::get(Identifier id) const { auto found = resourceMap.find(id); assert(found != resourceMap.end()); return *found->second; } #endif // RESOURCE_MANAGER_H