boost-ext / sml

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

Dispatching to parent: process() vs. processEvent() in action #623

Open pmf opened 3 months ago

pmf commented 3 months ago

I have a composite machine, and I want to dispatch an event to the parent.

It works when using process(ev_success{}) in the transition table of the sub machine, but it does not work when I send this event from an action in the sub machine (I can work around this by dispatching ev_success_internal from one action of the sub machine to trigger a dummy state, from which I can process(ev_success{}) to the parent).

What does not work (fails to compile): see example_not_working.cpp (the first file) in this gist: https://gist.github.com/pmf/520607f3952d56c9482e2550296b1ab4

What works: : see example_working.cpp (the first file) in the same gist (this is the workaround I use; ideally, I'd to just dispatch ev_success from this action, and have it behave like if it had been done by process() in the transition table).

(In addition, when I define an unreachable dummy state that accepts ev_success in the child machine, it compiles, but does not work at runtime: https://gist.github.com/pmf/5512263bc9e32b17b3571ca417c3094b).

This happens with either my old version (from 2020) or the current version in master as of today.