#include #include "util/Log.h" #include "ResourceManager.h" using namespace crepe; using namespace std; ResourceManager & ResourceManager::get_instance() { static ResourceManager instance; return instance; } ResourceManager::~ResourceManager() { dbg_trace(); } ResourceManager::ResourceManager() { dbg_trace(); } void ResourceManager::clear() { this->resources.clear(); } template T & ResourceManager::cache(const Asset & asset) { dbg_trace(); static_assert(is_base_of::value, "cache must recieve a derivative class of Resource"); if (!this->resources.contains(asset)) this->resources[asset] = make_unique(asset); Resource * resource = this->resources.at(asset).get(); T * concrete_resource = dynamic_cast(resource); if (concrete_resource == nullptr) throw runtime_error(format("ResourceManager: mismatch between requested type and actual type of resource ({})", asset.get_path())); return *concrete_resource; } #include "../facade/Sound.h" template Sound & ResourceManager::cache(const Asset &);