diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-10 19:13:48 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-10 19:13:48 +0100 |
commit | 0cb7f2f82ca167656b3c5cb9f0cc3b44c59cb0eb (patch) | |
tree | 8fa80428c08140d964eb122b5a1f8130bf10464a /src/crepe/manager/ResourceManager.cpp | |
parent | 9ff08f61023a910e3d4df1f1f52d8af0fc72c153 (diff) | |
parent | 7cbc577e94ed048f2a8146fab6972ae6ff290be7 (diff) |
Merge branch 'master' into loek/scripts
Diffstat (limited to 'src/crepe/manager/ResourceManager.cpp')
-rw-r--r-- | src/crepe/manager/ResourceManager.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/crepe/manager/ResourceManager.cpp b/src/crepe/manager/ResourceManager.cpp new file mode 100644 index 0000000..7c01808 --- /dev/null +++ b/src/crepe/manager/ResourceManager.cpp @@ -0,0 +1,30 @@ +#include "util/Log.h" + +#include "ResourceManager.h" + +using namespace crepe; +using namespace std; + +ResourceManager::ResourceManager(Mediator & mediator) : Manager(mediator) { + mediator.resource_manager = *this; + dbg_trace(); +} +ResourceManager::~ResourceManager() { dbg_trace(); } + +void ResourceManager::clear() { + std::erase_if(this->resources, [](const pair<const Asset, CacheEntry> & pair) { + const CacheEntry & entry = pair.second; + return entry.persistent == false; + }); +} + +void ResourceManager::clear_all() { this->resources.clear(); } + +void ResourceManager::set_persistent(const Asset & asset, bool persistent) { + this->get_entry(asset).persistent = persistent; +} + +ResourceManager::CacheEntry & ResourceManager::get_entry(const Asset & asset) { + if (!this->resources.contains(asset)) this->resources[asset] = {}; + return this->resources.at(asset); +} |