From 02c4c796888397496452aaa46c52691eef8707eb Mon Sep 17 00:00:00 2001 From: max-001 Date: Tue, 5 Nov 2024 16:11:54 +0100 Subject: Added abstract Scene class --- src/crepe/api/Scene.cpp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/crepe/api/Scene.cpp (limited to 'src/crepe/api/Scene.cpp') diff --git a/src/crepe/api/Scene.cpp b/src/crepe/api/Scene.cpp new file mode 100644 index 0000000..189650f --- /dev/null +++ b/src/crepe/api/Scene.cpp @@ -0,0 +1,5 @@ +#include "Scene.h" + +using namespace crepe::api; + +Scene::Scene(std::string name) : name(name) {} -- cgit v1.2.3 From 9752e2d27b06db25f0e2bc170341901201b4e4c1 Mon Sep 17 00:00:00 2001 From: max-001 Date: Tue, 5 Nov 2024 16:42:08 +0100 Subject: Replaced crepe::api to crepe --- src/crepe/api/Scene.cpp | 2 +- src/crepe/api/Scene.h | 4 ++-- src/crepe/api/SceneManager.cpp | 2 +- src/crepe/api/SceneManager.h | 4 ++-- src/crepe/api/SceneManager.hpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/crepe/api/Scene.cpp') diff --git a/src/crepe/api/Scene.cpp b/src/crepe/api/Scene.cpp index 189650f..092dc62 100644 --- a/src/crepe/api/Scene.cpp +++ b/src/crepe/api/Scene.cpp @@ -1,5 +1,5 @@ #include "Scene.h" -using namespace crepe::api; +using namespace crepe; Scene::Scene(std::string name) : name(name) {} diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index 35fe9db..8bb487a 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -2,7 +2,7 @@ #include -namespace crepe::api { +namespace crepe { class Scene { public: @@ -14,4 +14,4 @@ public: std::string name; }; -} // namespace crepe::api +} // namespace crepe diff --git a/src/crepe/api/SceneManager.cpp b/src/crepe/api/SceneManager.cpp index 773303b..1680dd1 100644 --- a/src/crepe/api/SceneManager.cpp +++ b/src/crepe/api/SceneManager.cpp @@ -2,7 +2,7 @@ #include "SceneManager.h" -using namespace crepe::api; +using namespace crepe; SceneManager::SceneManager() {} diff --git a/src/crepe/api/SceneManager.h b/src/crepe/api/SceneManager.h index 97441a5..76fe92e 100644 --- a/src/crepe/api/SceneManager.h +++ b/src/crepe/api/SceneManager.h @@ -6,7 +6,7 @@ #include "Scene.h" -namespace crepe::api { +namespace crepe { class SceneManager { public: @@ -31,6 +31,6 @@ private: std::queue next_scene; }; -} // namespace crepe::api +} // namespace crepe #include "SceneManager.hpp" diff --git a/src/crepe/api/SceneManager.hpp b/src/crepe/api/SceneManager.hpp index 120640f..7789823 100644 --- a/src/crepe/api/SceneManager.hpp +++ b/src/crepe/api/SceneManager.hpp @@ -1,6 +1,6 @@ #include "SceneManager.h" -using namespace crepe::api; +using namespace crepe; using namespace std; // Add a new concrete scene to the scene manager -- cgit v1.2.3 From 2fce3e3985302544827f6bf4dcc3a46cae3f2fd1 Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 10:06:15 +0100 Subject: Used const references instead of pass by value --- src/crepe/api/Scene.cpp | 2 +- src/crepe/api/Scene.h | 2 +- src/crepe/api/SceneManager.cpp | 3 ++- src/crepe/api/SceneManager.h | 4 ++-- src/crepe/api/SceneManager.hpp | 9 +++++---- 5 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/crepe/api/Scene.cpp') diff --git a/src/crepe/api/Scene.cpp b/src/crepe/api/Scene.cpp index 092dc62..933edf4 100644 --- a/src/crepe/api/Scene.cpp +++ b/src/crepe/api/Scene.cpp @@ -2,4 +2,4 @@ using namespace crepe; -Scene::Scene(std::string name) : name(name) {} +Scene::Scene(const std::string & name) : name(name) {} diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h index 8bb487a..f8bcc3d 100644 --- a/src/crepe/api/Scene.h +++ b/src/crepe/api/Scene.h @@ -6,7 +6,7 @@ namespace crepe { class Scene { public: - Scene(std::string name); + Scene(const std::string & name); virtual ~Scene() = default; virtual void load_scene() = 0; diff --git a/src/crepe/api/SceneManager.cpp b/src/crepe/api/SceneManager.cpp index c8061c9..6fc8f9b 100644 --- a/src/crepe/api/SceneManager.cpp +++ b/src/crepe/api/SceneManager.cpp @@ -3,6 +3,7 @@ #include "SceneManager.h" using namespace crepe; +using namespace std; SceneManager::SceneManager() {} @@ -12,7 +13,7 @@ SceneManager & SceneManager::get_instance() { } // Push the next scene onto the queue -void SceneManager::load_scene(std::string name) { next_scene.push(name); } +void SceneManager::load_scene(const std::string & name) { next_scene.push(name); } // Load a new scene from the queue (if there is one) void SceneManager::empty_queue() { diff --git a/src/crepe/api/SceneManager.h b/src/crepe/api/SceneManager.h index 87db8d7..b7d5150 100644 --- a/src/crepe/api/SceneManager.h +++ b/src/crepe/api/SceneManager.h @@ -19,8 +19,8 @@ public: public: template - void add_scene(std::string name); - void load_scene(std::string name); + void add_scene(const std::string & name); + void load_scene(const std::string & name); void empty_queue(); private: diff --git a/src/crepe/api/SceneManager.hpp b/src/crepe/api/SceneManager.hpp index 7789823..82787ed 100644 --- a/src/crepe/api/SceneManager.hpp +++ b/src/crepe/api/SceneManager.hpp @@ -1,11 +1,12 @@ #include "SceneManager.h" -using namespace crepe; -using namespace std; +namespace crepe { // Add a new concrete scene to the scene manager template -void SceneManager::add_scene(string name) { - static_assert(is_base_of::value, "T must be derived from Scene"); +void SceneManager::add_scene(const std::string & name) { + static_assert(std::is_base_of::value, "T must be derived from Scene"); scenes.emplace_back(make_unique(name)); } + +} // namespace crepe -- cgit v1.2.3