aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 14:06:18 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 14:06:18 +0100
commit431b0bd7c6c502b42bb5be5488371d8c475e7024 (patch)
treee077fe2365f3d441c2201f7cb3ab38920bf2b3ae
parent07adbf48e0781cd8c95983c1871a84b6160ee5bf (diff)
move some shit around
-rw-r--r--src/crepe/CMakeLists.txt2
-rw-r--r--src/crepe/api/Asset.cpp (renamed from src/crepe/Asset.cpp)0
-rw-r--r--src/crepe/api/Asset.h (renamed from src/crepe/Asset.h)0
-rw-r--r--src/crepe/api/AssetManager.cpp17
-rw-r--r--src/crepe/api/AudioSource.h5
-rw-r--r--src/crepe/api/CMakeLists.txt8
-rw-r--r--src/crepe/api/ResourceManager.cpp17
-rw-r--r--src/crepe/api/ResourceManager.h (renamed from src/crepe/api/AssetManager.h)28
-rw-r--r--src/crepe/api/ResourceManager.hpp (renamed from src/crepe/api/AssetManager.hpp)4
-rw-r--r--src/crepe/facade/Sound.cpp2
-rw-r--r--src/test/AssetTest.cpp2
11 files changed, 42 insertions, 43 deletions
diff --git a/src/crepe/CMakeLists.txt b/src/crepe/CMakeLists.txt
index 52a781e..05f86d7 100644
--- a/src/crepe/CMakeLists.txt
+++ b/src/crepe/CMakeLists.txt
@@ -1,5 +1,4 @@
target_sources(crepe PUBLIC
- Asset.cpp
Particle.cpp
ComponentManager.cpp
Component.cpp
@@ -8,7 +7,6 @@ target_sources(crepe PUBLIC
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
- Asset.h
ComponentManager.h
ComponentManager.hpp
Component.h
diff --git a/src/crepe/Asset.cpp b/src/crepe/api/Asset.cpp
index 8692c6c..8692c6c 100644
--- a/src/crepe/Asset.cpp
+++ b/src/crepe/api/Asset.cpp
diff --git a/src/crepe/Asset.h b/src/crepe/api/Asset.h
index f6e6782..f6e6782 100644
--- a/src/crepe/Asset.h
+++ b/src/crepe/api/Asset.h
diff --git a/src/crepe/api/AssetManager.cpp b/src/crepe/api/AssetManager.cpp
deleted file mode 100644
index 3925758..0000000
--- a/src/crepe/api/AssetManager.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "util/Log.h"
-
-#include "AssetManager.h"
-
-using namespace crepe;
-
-AssetManager & AssetManager::get_instance() {
- static AssetManager instance;
- return instance;
-}
-
-AssetManager::~AssetManager() {
- dbg_trace();
- this->asset_cache.clear();
-}
-
-AssetManager::AssetManager() { dbg_trace(); }
diff --git a/src/crepe/api/AudioSource.h b/src/crepe/api/AudioSource.h
index 0748267..8a78927 100644
--- a/src/crepe/api/AudioSource.h
+++ b/src/crepe/api/AudioSource.h
@@ -1,11 +1,10 @@
#pragma once
-#include <memory>
-
-#include "../Asset.h"
#include "../Component.h"
#include "../types.h"
+#include "Asset.h"
+
namespace crepe {
//! Audio source component
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index 93a1fac..70f1527 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -8,7 +8,7 @@ target_sources(crepe PUBLIC
Transform.cpp
Color.cpp
Texture.cpp
- AssetManager.cpp
+ ResourceManager.cpp
Sprite.cpp
SaveManager.cpp
Config.cpp
@@ -20,6 +20,7 @@ target_sources(crepe PUBLIC
Animator.cpp
LoopManager.cpp
LoopTimer.cpp
+ Asset.cpp
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -35,8 +36,8 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Vector2.h
Color.h
Texture.h
- AssetManager.h
- AssetManager.hpp
+ ResourceManager.h
+ ResourceManager.hpp
SaveManager.h
Scene.h
Metadata.h
@@ -46,4 +47,5 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
Animator.h
LoopManager.h
LoopTimer.h
+ Asset.h
)
diff --git a/src/crepe/api/ResourceManager.cpp b/src/crepe/api/ResourceManager.cpp
new file mode 100644
index 0000000..470e511
--- /dev/null
+++ b/src/crepe/api/ResourceManager.cpp
@@ -0,0 +1,17 @@
+#include "util/Log.h"
+
+#include "ResourceManager.h"
+
+using namespace crepe;
+
+ResourceManager & ResourceManager::get_instance() {
+ static ResourceManager instance;
+ return instance;
+}
+
+ResourceManager::~ResourceManager() {
+ dbg_trace();
+ this->asset_cache.clear();
+}
+
+ResourceManager::ResourceManager() { dbg_trace(); }
diff --git a/src/crepe/api/AssetManager.h b/src/crepe/api/ResourceManager.h
index 86a9902..7a45493 100644
--- a/src/crepe/api/AssetManager.h
+++ b/src/crepe/api/ResourceManager.h
@@ -8,36 +8,36 @@
namespace crepe {
/**
- * \brief The AssetManager is responsible for storing and managing assets over
+ * \brief The ResourceManager is responsible for storing and managing assets over
* multiple scenes.
*
- * The AssetManager ensures that assets are loaded once and can be accessed
+ * The ResourceManager ensures that assets are loaded once and can be accessed
* across different scenes. It caches assets to avoid reloading them every time
- * a scene is loaded. Assets are retained in memory until the AssetManager is
+ * a scene is loaded. Assets are retained in memory until the ResourceManager is
* destroyed, at which point the cached assets are cleared.
*/
-class AssetManager {
+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;
private:
- AssetManager();
- virtual ~AssetManager();
+ ResourceManager();
+ virtual ~ResourceManager();
public:
- AssetManager(const AssetManager &) = delete;
- AssetManager(AssetManager &&) = delete;
- AssetManager & operator=(const AssetManager &) = delete;
- AssetManager & operator=(AssetManager &&) = delete;
+ ResourceManager(const ResourceManager &) = delete;
+ ResourceManager(ResourceManager &&) = delete;
+ ResourceManager & operator=(const ResourceManager &) = delete;
+ ResourceManager & operator=(ResourceManager &&) = delete;
/**
- * \brief Retrieves the singleton instance of the AssetManager.
+ * \brief Retrieves the singleton instance of the ResourceManager.
*
- * \return A reference to the single instance of the AssetManager.
+ * \return A reference to the single instance of the ResourceManager.
*/
- static AssetManager & get_instance();
+ static ResourceManager & get_instance();
public:
/**
@@ -62,4 +62,4 @@ public:
} // namespace crepe
-#include "AssetManager.hpp"
+#include "ResourceManager.hpp"
diff --git a/src/crepe/api/AssetManager.hpp b/src/crepe/api/ResourceManager.hpp
index 977b4e1..9cd4bcb 100644
--- a/src/crepe/api/AssetManager.hpp
+++ b/src/crepe/api/ResourceManager.hpp
@@ -1,11 +1,11 @@
#pragma once
-#include "AssetManager.h"
+#include "ResourceManager.h"
namespace crepe {
template <typename asset>
-std::shared_ptr<asset> AssetManager::cache(const std::string & file_path,
+std::shared_ptr<asset> ResourceManager::cache(const std::string & file_path,
bool reload) {
auto it = asset_cache.find(file_path);
diff --git a/src/crepe/facade/Sound.cpp b/src/crepe/facade/Sound.cpp
index b7bfeab..726f11f 100644
--- a/src/crepe/facade/Sound.cpp
+++ b/src/crepe/facade/Sound.cpp
@@ -1,6 +1,6 @@
#include <memory>
-#include "../Asset.h"
+#include "../api/Asset.h"
#include "../util/Log.h"
#include "Sound.h"
diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp
index c3ff158..324a3f1 100644
--- a/src/test/AssetTest.cpp
+++ b/src/test/AssetTest.cpp
@@ -1,7 +1,7 @@
#include "api/Config.h"
#include <gtest/gtest.h>
-#include <crepe/Asset.h>
+#include <crepe/api/Asset.h>
using namespace std;
using namespace crepe;