From 5077c09d38e1e33a14765c23dab997856bf6b416 Mon Sep 17 00:00:00 2001 From: Erris Date: Sun, 20 Apr 2025 21:31:53 +0200 Subject: [PATCH] fixing small issues to save some resources --- include/state-machine_pool.hpp | 3 ++- include/state_machine.hpp | 2 -- include/state_system.hpp | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/state-machine_pool.hpp b/include/state-machine_pool.hpp index 973b1a0..7082208 100644 --- a/include/state-machine_pool.hpp +++ b/include/state-machine_pool.hpp @@ -7,7 +7,8 @@ template class StateMachinePool { public: void RegisterEntity(const std::string &id, StateOwnerType &entity) { - machines[id] = std::make_unique>(entity, factory); + auto machine = std::make_unique>(entity, factory); + machines[id] = std::move(machine); } void UnregisterEntity(const std::string &id) { diff --git a/include/state_machine.hpp b/include/state_machine.hpp index 66381ce..85901a7 100644 --- a/include/state_machine.hpp +++ b/include/state_machine.hpp @@ -13,8 +13,6 @@ using json = nlohmann::json; template class StateMachine { - using SharedState = std::shared_ptr>; - public: StateMachine(T &owner, const StateFactory &factory) : owner(owner), factory(factory) {}; diff --git a/include/state_system.hpp b/include/state_system.hpp index 3f8b892..d9f7b41 100644 --- a/include/state_system.hpp +++ b/include/state_system.hpp @@ -48,18 +48,18 @@ class StateSystem { GetPool().Deserialize(j, getEntity); } - template + template void SetStrictTransitions(bool enabled) { GetPool().SetStrictTransitions(enabled); } - template + template void SetAutoTransitions(bool enabled) { GetPool().SetAutoTransitions(enabled); } private: - template + template StateMachinePool &GetPool() const { static StateMachinePool pool; return pool;