FSM: working compile-time deducing states from initial one (i hope ...)

This commit is contained in:
2025-05-30 17:31:39 +03:00
parent fbe82fc56c
commit 10dd92baab
2 changed files with 56 additions and 24 deletions

View File

@@ -23,15 +23,26 @@ struct EV2 {
static constexpr std::string_view ID = "EV2";
};
struct EV3 {
static constexpr std::string_view ID = "EV3";
};
struct ST1;
struct ST2;
struct STN : fsm::MccFsmAbstractState {
static constexpr std::string_view ID = "STN";
using transition_t = trans_table_t<std::pair<EV1, STN>, std::pair<EV2, STN>>;
using transition_t = trans_table_t<std::pair<EV1, STN>, std::pair<EV2, ST2>>;
};
struct ST3 : fsm::MccFsmAbstractState {
static constexpr std::string_view ID = "ST3";
using transition_t = trans_table_t<std::pair<EV1, ST1>, std::pair<EV2, ST2>>;
};
struct ST2 : fsm::MccFsmAbstractState {
static constexpr std::string_view ID = "ST2";
using transition_t = trans_table_t<std::pair<EV2, STN>>;
using transition_t = trans_table_t<std::pair<EV2, STN>, std::pair<EV3, ST3>>;
};
struct ST1 : fsm::MccFsmAbstractState {
@@ -43,7 +54,7 @@ struct ST1 : fsm::MccFsmAbstractState {
// static_assert(fsm::traits::fsm_trans_table_c<tr_t>, "!!!!!!!!!!!!!");
// fsm::MccFiniteStateMachine<ST1> fsm;
fsm::MccFiniteStateMachine<ST1> fsm;
int main()
{
@@ -87,5 +98,8 @@ int main()
free(aa);
free(uu);
aa = abi::__cxa_demangle(typeid(fsm::MccFiniteStateMachine<ST1>::states_t).name(), NULL, NULL, &status);
std::cout << "states = " << aa << "\n";
return 0;
}