This header-only library is inspired by boost MSM and copies how it defines its transition tables. Only a subset of Boost.MSM features are implemented.
- requires a c++23 compiler
- many compile-time checks using concepts
- removes 5 arguments limitation on state-machine constructor
- removes transition table limitations due to boost MPL vector/map size
- states don't require any decoration
- accepts non-copyable events
- auto-detects if deferred events are used
- c++23 compiler such as clang++ or g++
- boost (required for unit-tests)
- python (required for conan build)
user@mach:~$ git clone https://github.com/SBAM/mfsm.git
user@mach:~$ cd mfsm
user@mach:~$ ./test.sh
user@mach:~$ conan upload -r <my_remote> mfsm/1.3struct sm
{
using transition_table_t = mfsm::transition_table<
// Start Event Next Action Guard
// +-------+-----+-----------+------------+--------+
mfsm::row<state1, evt2, state2, action, mfsm::none>,
mfsm::row<state1, evt1, mfsm::none, mfsm::defer, mfsm::none>,
mfsm::row<state2, evt1, state1, action, mfsm::none>,
mfsm::row<state2, evt2, mfsm::none, mfsm::defer, mfsm::none>,
mfsm::row<state2, evt3, state1, action, guard>,
mfsm::row<state2, evt3, state2, action, not_guard>>;
using initial_state = state1;
template <typename EVT>
void no_transition(EVT&&, std::size_t);
};
auto actual_sm = mfsm::state_machine<sm>{};
actual_sm.process_event(evt3{true});Refer to unit-tests for more examples.
- minimizes state-machine size, declares deferred queue only if needed
- low runtime complexity, candidate rows (match event) are deduced at compile time