#ifndef STATE_SYSTEM_HPP #define STATE_SYSTEM_HPP #include "state.hpp" #include "state_machine.hpp" #include "state-machine_pool.hpp" class StateSystem { public: template void RegisterEntity(const std::string &id, T &object) { GetPool().RegisterEntity(id, object); } template void UnregisterEntity(const std::string &id) { GetPool().UnregisterEntity(id); } template void ChangeState(const std::string &id, const std::string &stateId) { GetPool().ChangeState(id, stateId); } template void RevertState(const std::string &id) { GetPool().RevertState(id); } template void RegisterState(const std::string &id, std::shared_ptr> state) { if (state) GetPool().RegisterState(id, std::move(state)); } template void AddTransition(Transition &transition) { GetPool().AddTransition(transition); } template void UpdateAll() { GetPool().UpdateAll(); } template void Update(const std::string &id) { GetPool().Update(id); } template json Serialize() const { StateMachinePool &pool = GetPool(); return pool.Serialize(); } template void Deserialize(const json& j, std::function getEntity) { GetPool().Deserialize(j, getEntity); } template void SetStrictTransitions(bool enabled) { GetPool().SetStrictTransitions(enabled); } template void SetAutoTransitions(bool enabled) { GetPool().SetAutoTransitions(enabled); } private: template StateMachinePool &GetPool() const { static StateMachinePool pool; return pool; } }; #endif // STATE_SYSTEM_HPP