aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/ResourceManager.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 12:21:26 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 12:21:26 +0100
commitc2ef6a36532c8c078fd7836325d6be277b946cbf (patch)
treebcac24106220ad626aca5dfcd3576e7d60ac3af2 /src/crepe/manager/ResourceManager.cpp
parent74bffd3e466c342ca80811146a536716fb6437cb (diff)
parent7a07c56d572a6f30d0aa611bd566197bc04c3b33 (diff)
merge `loek/scripts`
Diffstat (limited to 'src/crepe/manager/ResourceManager.cpp')
-rw-r--r--src/crepe/manager/ResourceManager.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/crepe/manager/ResourceManager.cpp b/src/crepe/manager/ResourceManager.cpp
new file mode 100644
index 0000000..87585ad
--- /dev/null
+++ b/src/crepe/manager/ResourceManager.cpp
@@ -0,0 +1,34 @@
+#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);
+}
+