MccFiniteStateMachine: compiled and works (again ... :) )

This commit is contained in:
2025-06-02 17:48:08 +03:00
parent 9bee1ca0ea
commit 52a29e0f91
2 changed files with 186 additions and 24 deletions

View File

@@ -15,9 +15,11 @@ struct S {
struct EV1 {
static constexpr std::string_view ID = "EV1";
// EV1() = default;
// EV1(EV1&&) = default;
// EV1& operator=(EV1&&) = default;
void onTransit()
{
//
std::cout << "EV1::onTransit()\n";
}
};
struct EV2 {
@@ -44,12 +46,22 @@ struct ST3 {
struct ST2 {
static constexpr std::string_view ID = "ST2";
using transition_t = fsm::fsm_transition_table_t<std::pair<EV2, STN>, std::pair<EV3, ST3>>;
void enter(EV1& ev)
{
std::cout << "transit to " << ID << "-state\n";
}
};
struct ST1 {
static constexpr std::string_view ID = "ST1";
using transition_t =
fsm::fsm_transition_table_t<std::pair<EV1, ST2>, std::pair<EV2, STN>, std::pair<EV3, STN>, std::pair<EV3, STN>>;
void exit()
{
std::cout << "transit from " << ID << "-state\n";
}
};
// struct STN : fsm::MccFsmAbstractState {
@@ -124,7 +136,21 @@ int main()
*/
fsm::MccFiniteStateMachine(ST1{});
fsm::MccFiniteStateMachine fsmach(ST1{});
fsmach.dispatchEvent<EV1>();
// fsmach.dispatchEvent<EV1>();
// using tab_t = fsm::fsm_transition_table_t<std::pair<EV1, ST2>, std::pair<EV3, ST1>>;
// using st_t = tab_t::find_state_by_event_t<EV2>;
// int status;
// char* aa = abi::__cxa_demangle(typeid(st_t).name(), NULL, NULL, &status);
// std::cout << "aa = " << aa << "\n";
// free(aa);
return 0;
}