aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/ResourceManager.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-11 15:00:21 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-11 15:00:21 +0100
commite980f88c08e05d3c3d0ae7ff7422ec9e686ecfa4 (patch)
treedbf603db33c75e13cfeb255d8fcf789f4b2b82bc /src/crepe/manager/ResourceManager.cpp
parenta597b0059f30e9d56331c6ece34fdcabb4028616 (diff)
parent78c4a8772526f40c531b5402b56932b0a41e22e8 (diff)
Merge branch 'master' into niels/UI
Diffstat (limited to 'src/crepe/manager/ResourceManager.cpp')
-rw-r--r--src/crepe/manager/ResourceManager.cpp30
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);
+}