
"Igor R" <boost.lists@gmail.com> schrieb im Newsbeitrag news:cfe0a3cf0910090328p5847488bq382c92e4e16c2756@mail.gmail.com... I have a state [A] with three orthogonal substates [X,Y,Z]. The states [A] and [X] provide custom reactions for an event [E]. If processing event [E] the state machine calls first the custom reaction in [A]. This method returns with forward_event() ; After this the custom reaction in [A] is called again. And then custom reaction in [X] is called.
From my experience, it doesn't behave like that.
It would be something easier to work vice versa. First the more "specialized" inner states could do there work and then the "generalized" outer states can do the everything else. That's what happens usually. Maybe there's some problem with your FSM definition? Hi, you're right. I've wrote a simplified example and all works like expected. But can't currently find any bug in my definitions. Here is the working simplified example: #include <boost/statechart/state_machine.hpp> #include <boost/statechart/state.hpp> #include <boost/statechart/transition.hpp> #include <boost/statechart/deferral.hpp> #include <boost/statechart/custom_reaction.hpp> #include <boost/statechart/event.hpp> #include <boost/mpl/list.hpp> namespace state { // forward declaration struct A; struct X; struct Y; struct Z; } // event struct E : boost::statechart::event< E > {}; // state machine class machine : public boost::statechart::state_machine< machine, state::A > { typedef boost::statechart::state_machine< machine, state::A > state_machine_t; public: machine(); static bool unit_test(); }; // states namespace state { struct A : boost::statechart::simple_state< A , machine , boost::mpl::list< X, Y, Z >
{ typedef boost::mpl::list < boost::statechart::custom_reaction< E >
reactions; boost::statechart::result react( const E& ); };
struct X : boost::statechart::simple_state< X , A::orthogonal< 0 >
{ typedef boost::mpl::list < boost::statechart::custom_reaction< E >
reactions; boost::statechart::result react( const E& ); }; struct Y : boost::statechart::simple_state< Y , A::orthogonal< 1 >
{}; struct Z : boost::statechart::simple_state< Z , A::orthogonal< 2 >
{}; } #include "statechart.h" machine::machine() { state_machine_t::initiate(); } bool machine::unit_test() { machine m; m.process_event(E()); return true; } namespace state { boost::statechart::result A::react( const E& evt ) { std::cout << "A" << std::endl; return discard_event(); } boost::statechart::result X::react( const E& evt ) { std::cout << "X" << std::endl; return forward_event(); } } // end namespace state Pirx!