#if!defined STATEMACHINE_HPP #define STATEMACHINE_HPP #include #include #include #include #include class StateMachine { public: using State = std::function; using Notification = std::function; static unsigned int const NoOp; static void noOp(StateMachine&); StateMachine(); void addState(unsigned int index, State&& state); void addStateBegin(unsigned index, Notification&& state); void addStateEnd(unsigned index, Notification&& state); void change(unsigned int index); void step(); unsigned int currentIndex()const { return m_currentIndex; } private: std::map m_states; std::map m_begins; std::map m_ends; State m_currentState; unsigned int m_currentIndex; }; #endif