aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/ResourceManager.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 17:01:10 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 17:01:10 +0100
commit213f947d0907858cace470736c15f87caa934591 (patch)
tree2d15878761eefb84e5ccdfa75a91646d9fab4aa2 /src/crepe/api/ResourceManager.h
parent431b0bd7c6c502b42bb5be5488371d8c475e7024 (diff)
fix resource manager
Diffstat (limited to 'src/crepe/api/ResourceManager.h')
-rw-r--r--src/crepe/api/ResourceManager.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/crepe/api/ResourceManager.h b/src/crepe/api/ResourceManager.h
index 7a45493..a69a9fa 100644
--- a/src/crepe/api/ResourceManager.h
+++ b/src/crepe/api/ResourceManager.h
@@ -1,12 +1,15 @@
#pragma once
-#include <any>
#include <memory>
-#include <string>
#include <unordered_map>
+#include "Asset.h"
+#include "Resource.h"
+
namespace crepe {
+class Sound;
+
/**
* \brief The ResourceManager is responsible for storing and managing assets over
* multiple scenes.
@@ -20,18 +23,18 @@ class ResourceManager {
private:
//! A cache that holds all the assets, accessible by their file path, over multiple scenes.
- std::unordered_map<std::string, std::any> asset_cache;
+ std::unordered_map<const Asset, std::unique_ptr<Resource>> resources;
private:
- ResourceManager();
- virtual ~ResourceManager();
+ ResourceManager(); // dbg_trace
+ virtual ~ResourceManager(); // dbg_trace
-public:
ResourceManager(const ResourceManager &) = delete;
ResourceManager(ResourceManager &&) = delete;
ResourceManager & operator=(const ResourceManager &) = delete;
ResourceManager & operator=(ResourceManager &&) = delete;
+public:
/**
* \brief Retrieves the singleton instance of the ResourceManager.
*
@@ -56,8 +59,12 @@ public:
* cache.
*/
template <typename T>
- std::shared_ptr<T> cache(const std::string & file_path,
- bool reload = false);
+ T & cache(const Asset & asset);
+
+ /**
+ * \brief Clear the resource cache
+ */
+ void clear();
};
} // namespace crepe