I would like to be able to communicate the data from an event to a state that gets constructed as a result of a transition.
From this post in 2009 and this one in 2010 the use of triggering_event() is suggested. However, I can't find an example anywhere that demonstrates how to use it.
Can anyone help?
The following example is a Boost statechart implementation based on the motor state machine described here. Instead of using a custom_reaction to pull the speed out of the EvSetSpeed event (as in other states here), I've modified it to call triggering_event() in the constructor of the Start state.
Things to note:
Finally, it's worth mentioning that trying to call triggering_event in the constructor of the initial state of a state machine will result in a null return value. This is because the initial state is constructed during the call to initiate, where there is no triggering event.