
Hello,
I want to pass data from outside into the state machine and pass the
data from one state to the next state during state transition.
But it seams that statechart doesn't support this.
Could this feature be added? What is the preferred way which statechart
suggests?
With best regards,
Oliver
#include <iostream>
#include <stdexcept>
#include
{}; struct active : public sc::simple_state< active, sm
{ active( int i) { std::cout << "active(): " << i << std::endl; } }; struct inactive : public sc::simple_state< inactive, sm
{ typedef sc::custom_reaction< ev_activate > reactions; sc::result react( ev_activate const& ev) { return transit< active >( ev.data); // passing data to new state during transition } }; int main() { try { sm fsm; fsm.initiate(); fsm.process_event( ev_activate( 1) ); // passing data from outside return 0; } catch ( std::runtime_error const& e) { std::cerr << e.what() << std::endl; } catch (...) { std::cerr << "unhandled exception" << std::endl; } return -1; }