#pragma once class LFR_StateMachine; class LFR_State { public: virtual void enter(LFR_StateMachine* stateMachine) = 0; virtual void exit(LFR_StateMachine* stateMachine) = 0; virtual ~LFR_State() {} }; namespace State { class Idle: public LFR_State { Idle() {} Idle(const Idle& other) {}; Idle& operator= (const Idle& other); public: void enter(LFR_StateMachine*); void exit(LFR_StateMachine*); static LFR_State& getInstance(); }; class Autonomous: public LFR_State { Autonomous() {} Autonomous(const Autonomous& other) {}; Autonomous& operator= (const Autonomous& other); public: void enter(LFR_StateMachine*); void exit(LFR_StateMachine*); static LFR_State& getInstance(); }; class Manual: public LFR_State { Manual() {} Manual(const Manual& other) {}; Manual& operator= (const Manual& other); public: void enter(LFR_StateMachine*); void exit(LFR_StateMachine*); static LFR_State& getInstance(); }; } class LFR_StateMachine { LFR_State* currentState; public: LFR_StateMachine(){ setState(State::Idle::getInstance()); } inline LFR_State* getCurrentState() const {return currentState;} void setState(LFR_State& newState) { currentState->exit(this); currentState = &newState; currentState->enter(this); } };