aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ResourceManager.cpp
blob: 8b1fbf52f2a75301ac426bac436fb56d0db0ecfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "util/Log.h"

#include "ResourceManager.h"

using namespace crepe;
using namespace std;

ResourceManager::~ResourceManager() { 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);
}