Skip to content

Transition Actions

Sergei Fedorov edited this page Nov 20, 2016 · 1 revision

A transition action is a functor that will be called after the transition's source state exited and before the target state entered. It is passed the event, immediately enclosing state machine and source and target states. The operator can be const-qualified, it doesn't make any difference as the transition action objects are temporaries instantiated at the point of call.

Generic transition action (catch all)

struct transition_action {
    template < typename Event, typename FSM, typename SourceState, typename TargetState >
    void
    operator()(Event&&, FSM&, SourceState&, TargetState&)
    {
        using ::psst::util::demangle;
        ::std::cerr << "State machine " << demangle<FSM>() 
            << " transits from " << demangle<SourceState>()
            << " to " << demangle<TargetState>()
            << " on event " << demangle<Event>() << "\n";
    }
};

The event will be passed by rvalue reference if process_event was called with rvalue reference or the event was previously queued or deferred. The FSM parameter will be the immediately enclosing state machine (definition wrapped in ::afsm::state_machine or ::afsm::inner_state_machine. The states parameters are state or state machine definitions wrapped in ::afsm::state or ::afsm::inner_state_machine respectively.

Source and target state parameters are planned to be optional

Clone this wiki locally