From e0db2fa06232e9f081df6dac2e360195becae17c Mon Sep 17 00:00:00 2001 From: max-001 Date: Thu, 7 Nov 2024 09:43:17 +0100 Subject: Added this-> --- src/crepe/ComponentManager.cpp | 2 +- src/crepe/ComponentManager.hpp | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/crepe/ComponentManager.cpp b/src/crepe/ComponentManager.cpp index 55bd82f..01bc8d7 100644 --- a/src/crepe/ComponentManager.cpp +++ b/src/crepe/ComponentManager.cpp @@ -11,7 +11,7 @@ ComponentManager & ComponentManager::get_instance() { void ComponentManager::delete_all_components_of_id(uint32_t id) { // Loop through all the types (in the unordered_map<>) - for (auto & [type, componentArray] : components) { + for (auto & [type, componentArray] : this->components) { // Make sure that the id (that we are looking for) is within the boundaries of the vector<> if (id < componentArray.size()) { // Clear the components at this specific id diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp index 11c4d15..eac38fc 100644 --- a/src/crepe/ComponentManager.hpp +++ b/src/crepe/ComponentManager.hpp @@ -17,15 +17,15 @@ T & ComponentManager::add_component(uint32_t id, Args &&... args) { type_index type = typeid(T); // Check if this component type is already in the unordered_map<> - if (components.find(type) == components.end()) { + if (this->components.find(type) == this->components.end()) { //If not, create a new (empty) vector<> of vector> - components[type] = vector>>(); + this->components[type] = vector>>(); } // Resize the vector<> if the id is greater than the current size - if (id >= components[type].size()) { + if (id >= this->components[type].size()) { // Initialize new slots to nullptr (resize does automatically init to nullptr) - components[type].resize(id + 1); + this->components[type].resize(id + 1); } // Create a new component of type T (arguments directly forwarded). The @@ -35,14 +35,14 @@ T & ComponentManager::add_component(uint32_t id, Args &&... args) { // Check if the vector size is not greater than get_instances_max if (instance->get_instances_max() != -1 - && components[type][id].size() >= instance->get_instances_max()) { + && this->components[type][id].size() >= instance->get_instances_max()) { // TODO: Exception throw std::runtime_error( "Exceeded maximum number of instances for this component type"); } // store its unique_ptr in the vector<> - components[type][id].push_back(std::move(instance)); + this->components[type][id].push_back(std::move(instance)); return *instance; } @@ -55,10 +55,10 @@ void ComponentManager::delete_components_by_id(uint32_t id) { type_index type = typeid(T); // Find the type (in the unordered_map<>) - if (components.find(type) != components.end()) { + if (this->components.find(type) != this->components.end()) { // Get the correct vector<> vector>> & component_array - = components[type]; + = this->components[type]; // Make sure that the id (that we are looking for) is within the boundaries of the vector<> if (id < component_array.size()) { @@ -73,9 +73,9 @@ void ComponentManager::delete_components() { // Determine the type of T (this is used as the key of the unordered_map<>) std::type_index type = typeid(T); - if (components.find(type) == components.end()) return; + if (this->components.find(type) == this->components.end()) return; - components[type].clear(); + this->components[type].clear(); } template @@ -89,11 +89,11 @@ ComponentManager::get_components_by_id(uint32_t id) const { // Create an empty vector<> vector> component_vector; - if (components.find(type) == components.end()) return component_vector; + if (this->components.find(type) == this->components.end()) return component_vector; // Get the correct vector<> const vector>> & component_array - = components.at(type); + = this->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; @@ -124,11 +124,11 @@ ComponentManager::get_components_by_type() const { vector> component_vector; // Find the type (in the unordered_map<>) - if (components.find(type) == components.end()) return component_vector; + if (this->components.find(type) == this->components.end()) return component_vector; // Get the correct vector<> const vector>> & component_array - = components.at(type); + = this->components.at(type); // Loop through the whole vector<> for (const vector> & component : component_array) { -- cgit v1.2.3