diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-14 19:57:45 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-14 19:57:45 +0100 |
commit | add8724446fdeae1aaec9b07544cf7a5475a9bfe (patch) | |
tree | 7c51cf0d65f8f0d906a0abe2b29bad916dcf83e8 /src/crepe/api/ResourceManager.hpp | |
parent | ab0b4923c4f49e7a28f6d17e994d3e013ca344bb (diff) |
ResourceManager working + tested
Diffstat (limited to 'src/crepe/api/ResourceManager.hpp')
-rw-r--r-- | src/crepe/api/ResourceManager.hpp | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/crepe/api/ResourceManager.hpp b/src/crepe/api/ResourceManager.hpp deleted file mode 100644 index 62cac20..0000000 --- a/src/crepe/api/ResourceManager.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include <stdexcept> -#include <format> - -#include "ResourceManager.h" - -namespace crepe { - -template <typename T> -T & ResourceManager::cache(const Asset & asset) { - using namespace std; - 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; -} - -} // namespace crepe |