aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 18:04:03 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 18:04:03 +0100
commitab0b4923c4f49e7a28f6d17e994d3e013ca344bb (patch)
treeb385693017be292b8f4862e88b912dba7c6be619 /src/crepe/api
parent213f947d0907858cace470736c15f87caa934591 (diff)
more WIP audio system + utilities
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/ResourceManager.cpp13
-rw-r--r--src/crepe/api/ResourceManager.h13
2 files changed, 20 insertions, 6 deletions
diff --git a/src/crepe/api/ResourceManager.cpp b/src/crepe/api/ResourceManager.cpp
index 17fbd9b..6eb4afd 100644
--- a/src/crepe/api/ResourceManager.cpp
+++ b/src/crepe/api/ResourceManager.cpp
@@ -2,6 +2,9 @@
#include "ResourceManager.h"
+// default resource cache functions
+#include "../facade/Sound.h"
+
using namespace crepe;
ResourceManager & ResourceManager::get_instance() {
@@ -11,3 +14,13 @@ ResourceManager & ResourceManager::get_instance() {
ResourceManager::~ResourceManager() { dbg_trace(); }
ResourceManager::ResourceManager() { dbg_trace(); }
+
+void ResourceManager::clear() {
+ this->resources.clear();
+}
+
+template <>
+Sound & ResourceManager::cache<Sound>(const Asset & asset) {
+ return this->cache<Sound>(asset);
+}
+
diff --git a/src/crepe/api/ResourceManager.h b/src/crepe/api/ResourceManager.h
index a69a9fa..468af16 100644
--- a/src/crepe/api/ResourceManager.h
+++ b/src/crepe/api/ResourceManager.h
@@ -51,22 +51,23 @@ public:
* it is already cached.
* \tparam T The type of asset to cache (e.g., texture, sound, etc.).
*
- * \return A shared pointer to the cached asset.
+ * \return A reference to the resource
*
* This template function caches the asset at the given file path. If the
- * asset is already cached and `reload` is false, the existing cached version
- * will be returned. Otherwise, the asset will be reloaded and added to the
+ * asset is already cached, the existing instance will be returned.
+ * Otherwise, the concrete resource will be instantiated and added to the
* cache.
*/
template <typename T>
T & cache(const Asset & asset);
- /**
- * \brief Clear the resource cache
- */
+ //! Clear the resource cache
void clear();
};
+template <>
+Sound & ResourceManager::cache<Sound>(const Asset & asset);
+
} // namespace crepe
#include "ResourceManager.hpp"