/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2020-09-05 * Changed: 2020-11-06 * * */ #ifndef LS_STD_STATE_MACHINE_HPP #define LS_STD_STATE_MACHINE_HPP #include #include #include #include #include "../../../include/base/Class.hpp" #include "State.hpp" #include "StateMachineTypes.hpp" namespace ls_std { class StateMachine : public Class { public: explicit StateMachine(std::string _name); ~StateMachine() = default; bool addState(const std::shared_ptr& _state); std::shared_ptr getCurrentState(); std::vector getMemory(); std::string getName(); std::unordered_map> getStates(); bool hasState(const StateId& _id); bool proceed(); void setMemory(std::vector _memory); void setName(std::string _name); bool setStartState(const StateId& _id); private: std::shared_ptr currentState {}; std::vector memory {}; std::string name {}; std::unordered_map> states {}; std::vector _getNextValidStates(); void _remember(const StateId& _id); bool _hasState(const StateId& _id); }; } #endif