diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-26 20:03:41 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-26 20:03:41 +0100 |
commit | a685e5f743786cc6499e7ce8973bb78a83d101f7 (patch) | |
tree | 21d7aeb768912bef8f98436d13acb4423cffd8f0 /src/crepe/api/ResourceManager.cpp | |
parent | 92e3fbda73128e65a31b3760b3fa4bd0147debe3 (diff) |
big WIP
Diffstat (limited to 'src/crepe/api/ResourceManager.cpp')
-rw-r--r-- | src/crepe/api/ResourceManager.cpp | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/crepe/api/ResourceManager.cpp b/src/crepe/api/ResourceManager.cpp deleted file mode 100644 index 7877ed9..0000000 --- a/src/crepe/api/ResourceManager.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include <stdexcept> - -#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 <typename T> -T & ResourceManager::cache(const Asset & asset) { - dbg_trace(); - static_assert(is_base_of<Resource, T>::value, "cache must recieve a derivative class of Resource"); - - if (!this->resources.contains(asset)) - this->resources[asset] = make_unique<T>(asset); - - Resource * resource = this->resources.at(asset).get(); - T * concrete_resource = dynamic_cast<T *>(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 &); - |