diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-11 13:21:19 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-11 13:21:19 +0100 |
commit | 357ebfc3eac1d39b02875e1bd78ae6f58b10f824 (patch) | |
tree | 7d79435fa764c0fedcc912ddaf876ff03ef8be5e /src/crepe/manager/ResourceManager.cpp | |
parent | 6eef90e9ffb1d8fc25161e912bc5d8aa8e4024da (diff) | |
parent | c45b60941b82dec2097d958b396a117b1634eada (diff) |
Merge remote-tracking branch 'origin/master' into max/AI
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); +} |