Builder is now using the FSM I wrote. Still not as clean as I like but big improvement.

This commit is contained in:
Zed A. Shaw 2024-09-10 01:56:22 -04:00
parent dcf1a4020d
commit a7c5de6ac3
4 changed files with 176 additions and 129 deletions

11
fsm.hpp
View file

@ -1,5 +1,10 @@
#pragma once
#include <fmt/core.h>
#define FSM_EV(S, F) case S: F(); break
#define FSM_STATE(S, F, E) case S: fmt::println(">>> " #S ":" #F ":{}", int(E)); F(E); break
template<typename S, typename E>
class DeadSimpleFSM {
protected:
@ -11,6 +16,8 @@ public:
void state(S next_state) {
_state = next_state;
}
};
#define FSM_T(S, F) case S: F(); break
bool in_state(S state) {
return _state == state;
}
};