boost-ext / sml

C++14 State Machine library
https://boost-ext.github.io/sml
Boost Software License 1.0
1.1k stars 173 forks source link

Added "any state" feature #602

Closed rvdvvdw closed 8 months ago

rvdvvdw commented 8 months ago

Allowing a default reaction on events without having to add them to every state. I believe a similar feature exists in sml2

Problem: -Many (of my) state machines have events that are handled in (almost) all states. For example, transitions to an error state or a stop/abort event. Currently there is no way to express a default reaction to an event.

Solution: -Added an "any" state. The any state is written as "state<_>". Whenever an event is processed in a state that does NOT handle that event, the "any" state is checked. If the "any" state handles the event it is processed as if the current state is the "any" state. This change could break code that already uses "state<_>" as a normal state.

Issue: #328

Reviewers: @krzysztof-jusiak