aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-17 17:15:53 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-17 17:15:53 +0200
commita2c719948ff8af9abe267c4d1c9b16cd1e2fb317 (patch)
treeb2509bc9d435e7efc0afdf99f82a8b483f65758f
parent9fd3bdca9de2d37b63e1646b22d32b0b182f01ee (diff)
`make format`
-rw-r--r--src/crepe/Component.cpp1
-rw-r--r--src/crepe/Component.h1
-rw-r--r--src/crepe/ComponentManager.cpp11
-rw-r--r--src/crepe/ComponentManager.hpp9
-rw-r--r--src/crepe/ScriptSystem.cpp17
-rw-r--r--src/crepe/ScriptSystem.h4
-rw-r--r--src/crepe/System.h7
-rw-r--r--src/crepe/api/BehaviorScript.cpp7
-rw-r--r--src/crepe/api/BehaviorScript.h8
-rw-r--r--src/crepe/api/BehaviorScript.hpp4
-rw-r--r--src/crepe/api/Script.cpp2
-rw-r--r--src/crepe/api/Script.h4
-rw-r--r--src/crepe/util/fmt.cpp5
-rw-r--r--src/crepe/util/fmt.h2
-rw-r--r--src/crepe/util/log.cpp3
-rw-r--r--src/example/script.cpp11
16 files changed, 38 insertions, 58 deletions
diff --git a/src/crepe/Component.cpp b/src/crepe/Component.cpp
index 737f30a..bce90f1 100644
--- a/src/crepe/Component.cpp
+++ b/src/crepe/Component.cpp
@@ -1,4 +1,3 @@
#include "Component.h"
using namespace crepe;
-
diff --git a/src/crepe/Component.h b/src/crepe/Component.h
index 00b2164..d9a01ac 100644
--- a/src/crepe/Component.h
+++ b/src/crepe/Component.h
@@ -5,6 +5,7 @@ namespace crepe {
class Component {
protected:
Component() = default;
+
public:
virtual ~Component() = default;
// TODO: shouldn't this constructor be deleted because this class will never
diff --git a/src/crepe/ComponentManager.cpp b/src/crepe/ComponentManager.cpp
index 8aa9d4e..8bde33a 100644
--- a/src/crepe/ComponentManager.cpp
+++ b/src/crepe/ComponentManager.cpp
@@ -1,5 +1,5 @@
-#include "util/log.h"
#include "ComponentManager.h"
+#include "util/log.h"
using namespace crepe;
@@ -24,11 +24,6 @@ void ComponentManager::delete_all_components() {
this->components.clear();
}
-ComponentManager::ComponentManager() {
- dbg_trace();
-}
-
-ComponentManager::~ComponentManager() {
- dbg_trace();
-}
+ComponentManager::ComponentManager() { dbg_trace(); }
+ComponentManager::~ComponentManager() { dbg_trace(); }
diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp
index e0242a2..2377a94 100644
--- a/src/crepe/ComponentManager.hpp
+++ b/src/crepe/ComponentManager.hpp
@@ -10,7 +10,8 @@ template <class T, typename... Args>
T & ComponentManager::add_component(uint32_t id, Args &&... args) {
using namespace std;
- static_assert(is_base_of<Component, T>::value, "add_component must recieve a derivative class of Component");
+ static_assert(is_base_of<Component, T>::value,
+ "add_component must recieve a derivative class of Component");
// Determine the type of T (this is used as the key of the unordered_map<>)
type_index type = typeid(T);
@@ -81,7 +82,8 @@ ComponentManager::get_components_by_id(uint32_t id) const {
if (components.find(type) == components.end()) return component_vector;
// Get the correct vector<>
- const vector<vector<unique_ptr<Component>>> & component_array = components.at(type);
+ const vector<vector<unique_ptr<Component>>> & component_array
+ = components.at(type);
// Make sure that the id (that we are looking for) is within the boundaries of the vector<>
if (id >= component_array.size()) return component_vector;
@@ -117,7 +119,8 @@ ComponentManager::get_components_by_type() const {
if (components.find(type) == components.end()) return component_vector;
// Get the correct vector<>
- const vector<vector<unique_ptr<Component>>> & component_array = components.at(type);
+ const vector<vector<unique_ptr<Component>>> & component_array
+ = components.at(type);
// Loop through the whole vector<>
for (const vector<unique_ptr<Component>> & component : component_array) {
diff --git a/src/crepe/ScriptSystem.cpp b/src/crepe/ScriptSystem.cpp
index 1a7bff4..5d882be 100644
--- a/src/crepe/ScriptSystem.cpp
+++ b/src/crepe/ScriptSystem.cpp
@@ -2,8 +2,8 @@
#include <functional>
#include <vector>
-#include "ScriptSystem.h"
#include "ComponentManager.h"
+#include "ScriptSystem.h"
#include "api/BehaviorScript.h"
#include "api/Script.h"
#include "util/log.h"
@@ -12,12 +12,8 @@ using namespace std;
using namespace crepe;
using namespace crepe::api;
-ScriptSystem::ScriptSystem() {
- dbg_trace();
-}
-ScriptSystem::~ScriptSystem() {
- dbg_trace();
-}
+ScriptSystem::ScriptSystem() { dbg_trace(); }
+ScriptSystem::~ScriptSystem() { dbg_trace(); }
ScriptSystem & ScriptSystem::get_instance() {
static ScriptSystem instance;
@@ -29,14 +25,14 @@ void ScriptSystem::update() {
dbg_trace();
forward_list<Script *> scripts = this->get_scripts();
- for (Script * script : scripts)
- script->update();
+ for (Script * script : scripts) script->update();
}
forward_list<Script *> ScriptSystem::get_scripts() {
forward_list<Script *> scripts = {};
ComponentManager & mgr = ComponentManager::get_instance();
- vector<reference_wrapper<BehaviorScript>> behavior_scripts = mgr.get_components_by_type<BehaviorScript>();
+ vector<reference_wrapper<BehaviorScript>> behavior_scripts
+ = mgr.get_components_by_type<BehaviorScript>();
for (auto behavior_script_ref : behavior_scripts) {
BehaviorScript & behavior_script = behavior_script_ref.get();
@@ -47,4 +43,3 @@ forward_list<Script *> ScriptSystem::get_scripts() {
return scripts;
}
-
diff --git a/src/crepe/ScriptSystem.h b/src/crepe/ScriptSystem.h
index e0b2a65..1f472a0 100644
--- a/src/crepe/ScriptSystem.h
+++ b/src/crepe/ScriptSystem.h
@@ -21,8 +21,6 @@ private:
private:
std::forward_list<api::Script *> get_scripts();
-
};
-}
-
+} // namespace crepe
diff --git a/src/crepe/System.h b/src/crepe/System.h
index 3fe3d66..ecbb7f5 100644
--- a/src/crepe/System.h
+++ b/src/crepe/System.h
@@ -8,8 +8,8 @@ public:
virtual void update() = 0;
protected:
- System() { };
- virtual ~System() { };
+ System() {};
+ virtual ~System() {};
private:
// singleton
@@ -19,5 +19,4 @@ private:
System & operator=(System &&) = delete;
};
-}
-
+} // namespace crepe
diff --git a/src/crepe/api/BehaviorScript.cpp b/src/crepe/api/BehaviorScript.cpp
index 7a93f10..1f236b4 100644
--- a/src/crepe/api/BehaviorScript.cpp
+++ b/src/crepe/api/BehaviorScript.cpp
@@ -1,11 +1,8 @@
#include "../util/log.h"
-#include "Script.h"
#include "BehaviorScript.h"
+#include "Script.h"
using namespace crepe::api;
-BehaviorScript::BehaviorScript() {
- dbg_trace();
-}
-
+BehaviorScript::BehaviorScript() { dbg_trace(); }
diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h
index 756c2ca..b8263ca 100644
--- a/src/crepe/api/BehaviorScript.h
+++ b/src/crepe/api/BehaviorScript.h
@@ -7,7 +7,7 @@
namespace crepe {
class ScriptSystem;
class ComponentManager;
-}
+} // namespace crepe
namespace crepe::api {
@@ -17,11 +17,12 @@ class BehaviorScript : public Component {
protected:
friend class crepe::ComponentManager;
BehaviorScript();
+
public:
virtual ~BehaviorScript() = default;
public:
- template<class T>
+ template <class T>
BehaviorScript & set_script();
protected:
@@ -29,7 +30,6 @@ protected:
std::unique_ptr<Script> script = nullptr;
};
-}
+} // namespace crepe::api
#include "BehaviorScript.hpp"
-
diff --git a/src/crepe/api/BehaviorScript.hpp b/src/crepe/api/BehaviorScript.hpp
index 9a1f427..a6bd81c 100644
--- a/src/crepe/api/BehaviorScript.hpp
+++ b/src/crepe/api/BehaviorScript.hpp
@@ -7,7 +7,7 @@
namespace crepe::api {
-template<class T>
+template <class T>
BehaviorScript & BehaviorScript::set_script() {
static_assert(std::is_base_of<Script, T>::value);
dbg_trace();
@@ -16,4 +16,4 @@ BehaviorScript & BehaviorScript::set_script() {
return *this;
}
-}
+} // namespace crepe::api
diff --git a/src/crepe/api/Script.cpp b/src/crepe/api/Script.cpp
index 6259574..5016ed0 100644
--- a/src/crepe/api/Script.cpp
+++ b/src/crepe/api/Script.cpp
@@ -1,5 +1,3 @@
#include "Script.h"
using namespace crepe::api;
-
-
diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h
index b1e6a95..0036d1f 100644
--- a/src/crepe/api/Script.h
+++ b/src/crepe/api/Script.h
@@ -8,6 +8,7 @@ namespace crepe::api {
class Script {
friend class crepe::ScriptSystem;
+
protected:
virtual void init() {}
virtual void update() {}
@@ -17,5 +18,4 @@ protected:
// added event.
};
-}
-
+} // namespace crepe::api
diff --git a/src/crepe/util/fmt.cpp b/src/crepe/util/fmt.cpp
index 3a43a6f..8ef1164 100644
--- a/src/crepe/util/fmt.cpp
+++ b/src/crepe/util/fmt.cpp
@@ -1,6 +1,6 @@
-#include <string>
-#include <cstdio>
#include <cstdarg>
+#include <cstdio>
+#include <string>
#include "fmt.h"
@@ -31,4 +31,3 @@ string crepe::util::stringf(const char * fmt, ...) {
va_end(args);
return out;
}
-
diff --git a/src/crepe/util/fmt.h b/src/crepe/util/fmt.h
index 5c45703..44c426f 100644
--- a/src/crepe/util/fmt.h
+++ b/src/crepe/util/fmt.h
@@ -7,4 +7,4 @@ namespace crepe::util {
std::string va_stringf(va_list args, const char * fmt);
std::string stringf(const char * fmt, ...);
-}
+} // namespace crepe::util
diff --git a/src/crepe/util/log.cpp b/src/crepe/util/log.cpp
index b46620d..f012c67 100644
--- a/src/crepe/util/log.cpp
+++ b/src/crepe/util/log.cpp
@@ -3,8 +3,8 @@
#include <cstdlib>
#include <string>
-#include "log.h"
#include "fmt.h"
+#include "log.h"
using namespace crepe::util;
@@ -38,4 +38,3 @@ void crepe::util::logf(log_level level, const char * fmt, ...) {
log(level, va_stringf(args, fmt));
va_end(args);
}
-
diff --git a/src/example/script.cpp b/src/example/script.cpp
index 95c4950..cc585db 100644
--- a/src/example/script.cpp
+++ b/src/example/script.cpp
@@ -3,22 +3,20 @@
* Standalone example for usage of the script component and system
*/
-#include <crepe/util/log.h>
-#include <crepe/ScriptSystem.h>
#include <crepe/ComponentManager.h>
#include <crepe/GameObject.h>
+#include <crepe/ScriptSystem.h>
+#include <crepe/util/log.h>
-#include <crepe/api/Script.h>
#include <crepe/api/BehaviorScript.h>
+#include <crepe/api/Script.h>
using namespace crepe;
using namespace crepe::api;
using namespace std;
class MyScript : public Script {
- void update() {
- dbg_log("MY SCRIPT UPDATE");
- }
+ void update() { dbg_log("MY SCRIPT UPDATE"); }
};
int main() {
@@ -32,4 +30,3 @@ int main() {
return 0;
}
-