From f51ddfac7b8948a43a40894185238c8a1ceeb5c4 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 15 Nov 2024 17:25:12 +0100 Subject: wrap lines at column 95 instead of 80 --- mwe/ecs-homemade/inc/ComponentManager.h | 6 ++---- mwe/ecs-homemade/inc/ComponentManager.hpp | 21 +++++++-------------- mwe/ecs-homemade/inc/GameObjectMax.hpp | 3 +-- 3 files changed, 10 insertions(+), 20 deletions(-) (limited to 'mwe/ecs-homemade/inc') diff --git a/mwe/ecs-homemade/inc/ComponentManager.h b/mwe/ecs-homemade/inc/ComponentManager.h index 0ba358e..99c108f 100644 --- a/mwe/ecs-homemade/inc/ComponentManager.h +++ b/mwe/ecs-homemade/inc/ComponentManager.h @@ -33,8 +33,7 @@ public: //Get a vector<> of all components at specific type and id template - std::vector> - GetComponentsByID(std::uint32_t id) const; + std::vector> GetComponentsByID(std::uint32_t id) const; //Get a vector<> of all components of a specific type template std::vector> GetComponentsByType() const; @@ -50,8 +49,7 @@ private: * The first std::vector<> stores another vector<>. This first vector<> is to bind the entity's id to a component. * The second std::vector<> stores unique_ptrs. Each component can be gathered via an unique_ptr. This second vector<> allows multiple components of the same std::type_index for one entity (id). */ - std::unordered_map>>> + std::unordered_map>>> mComponents; }; diff --git a/mwe/ecs-homemade/inc/ComponentManager.hpp b/mwe/ecs-homemade/inc/ComponentManager.hpp index 92db1d4..af9c3a1 100644 --- a/mwe/ecs-homemade/inc/ComponentManager.hpp +++ b/mwe/ecs-homemade/inc/ComponentManager.hpp @@ -7,8 +7,7 @@ T & ComponentManager::AddComponent(std::uint32_t id, Args &&... args) { //Check if this component type is already in the unordered_map<> if (mComponents.find(type) == mComponents.end()) { //If not, create a new (empty) vector<> of vector> - mComponents[type] - = std::vector>>(); + mComponents[type] = std::vector>>(); } //Resize the vector<> if the id is greater than the current size @@ -18,8 +17,7 @@ T & ComponentManager::AddComponent(std::uint32_t id, Args &&... args) { } //Create a new component of type T using perfect forwarding and store its unique_ptr in the vector<> - mComponents[type][id].push_back( - std::make_unique(std::forward(args)...)); + mComponents[type][id].push_back(std::make_unique(std::forward(args)...)); return static_cast(*mComponents[type][id].back().get()); } @@ -68,15 +66,13 @@ ComponentManager::GetComponentsByID(std::uint32_t id) const { if (mComponents.find(type) != mComponents.end()) { //Get the correct vector<> - const std::vector>> & - componentArray + const std::vector>> & componentArray = mComponents.at(type); //Make sure that the id (that we are looking for) is within the boundaries of the vector<> if (id < componentArray.size()) { //Loop trough the whole vector<> - for (const std::unique_ptr & componentPtr : - componentArray[id]) { + for (const std::unique_ptr & componentPtr : componentArray[id]) { //Cast the unique_ptr to a raw pointer T * castedComponent = static_cast(componentPtr.get()); @@ -94,8 +90,7 @@ ComponentManager::GetComponentsByID(std::uint32_t id) const { } template -std::vector> -ComponentManager::GetComponentsByType() const { +std::vector> ComponentManager::GetComponentsByType() const { //Determine the type of T (this is used as the key of the unordered_map<>) std::type_index type = typeid(T); @@ -107,13 +102,11 @@ ComponentManager::GetComponentsByType() const { if (mComponents.find(type) != mComponents.end()) { //Get the correct vector<> - const std::vector>> & - componentArray + const std::vector>> & componentArray = mComponents.at(type); //Loop through the whole vector<> - for (const std::vector> & component : - componentArray) { + for (const std::vector> & component : componentArray) { //Loop trough the whole vector<> for (const std::unique_ptr & componentPtr : component) { //Cast the unique_ptr to a raw pointer diff --git a/mwe/ecs-homemade/inc/GameObjectMax.hpp b/mwe/ecs-homemade/inc/GameObjectMax.hpp index 2f433bb..92375bb 100644 --- a/mwe/ecs-homemade/inc/GameObjectMax.hpp +++ b/mwe/ecs-homemade/inc/GameObjectMax.hpp @@ -2,6 +2,5 @@ template T & GameObject::AddComponent(Args &&... args) { - return ComponentManager::GetInstance().AddComponent( - mId, std::forward(args)...); + return ComponentManager::GetInstance().AddComponent(mId, std::forward(args)...); } -- cgit v1.2.3