feat: main loop now listens to state

This commit is contained in:
Leonetienne
2025-12-15 20:13:05 +01:00
parent 0405df14fe
commit ace1b9ef66
3 changed files with 56 additions and 45 deletions
+7 -7
View File
@@ -4,28 +4,28 @@
// Singleton-instance
class StateMachine
{
enum class State {
public:
enum class STATE {
INITIALIZING,
IDLING,
MOVING,
ERROR
};
public:
StateMachine(const StateMachine&) = delete;
StateMachine(StateMachine&&) = delete;
static StateMachine& getInstance() noexcept;
State getState() const noexcept { return state; };
STATE getState() const noexcept { return state; };
String getLastError() const noexcept { return lastError; };
// May fail if a state transition from state a to b is not valid
bool setState(const State newState) noexcept;
bool setState(const STATE newState) noexcept;
bool raiseError(const String& reason) noexcept;
bool canSwitchToState(const State newState) const noexcept;
bool canSwitchToState(const STATE newState) const noexcept;
private:
StateMachine() noexcept;
State state = State::INITIALIZING;
STATE state = STATE::INITIALIZING;
String lastError = "";
};