[MSM] Surprising Entry Point behaviour

Hi Christophe - I'm seeing some surprising behaviour when I have a sub-machine that can only be entered via an entry point. I have attached a diagram for quick reference. Code is below to demonstrate the "issue". Moving into the Sub state should only generate transitions into A with a 'none' event. The only way to get to B is via a transition from A with the 'event' event. MSM is trying to generate code into B for a transition with a 'none' event. This could be valid if the transition from Top::X wasn't via the entry point and just directly to Sub. I don't think there is a path to B with a 'none' event. Thoughts? Take care - michael ---------------- #include <boost/msm/front/state_machine_def.hpp> #include <boost/msm/front/functor_row.hpp> #include <boost/msm/back/state_machine.hpp> using boost::msm::front::none; using boost::msm::front::Row; namespace msm = boost::msm; struct event { int foo; }; struct Sub_ : public msm::front::state_machine_def<Sub_> { struct Enter : public msm::front::entry_pseudo_state<0> {}; struct A : msm::front::state<> {}; struct B : msm::front::state<> { template<class FSM> void on_entry(event const & evt, FSM &) {} }; using initial_state = A; struct transition_table : boost::mpl::vector< // Start Event Next Action Guard // +----------+---------+--------+-----------+-------- Row < Enter , none , A , none , none >, Row < A , event , B , none , none >, Row < B , none , A , none , none > // +----------+---------+--------+-----------+-------- >{}; }; using Sub = msm::back::state_machine<Sub_>; struct Top_ : public msm::front::state_machine_def<Top_> { struct X : msm::front::state<> {}; using initial_state = X; struct transition_table : boost::mpl::vector< // S Event Next Action Guard // +----+-------+-----------------------------+-------+------- Row < X , none , Sub::entry_pt<Sub_::Enter> , none , none > // +----+-------+-----------------------------+-------+------- >{}; }; using Top = boost::msm::back::state_machine<Top_>; int main() { Top top; top.start(); } ------------------------- -- Michael Caisse Ciere Consulting ciere.com

Hi Michael,
MSM is trying to generate code into B for a transition with a 'none' event. This could be valid if the transition from Top::X wasn't via the entry point and just directly to Sub. I don't think there is a path to B with a 'none' event.
Your guess is correct. The problem is that I'm forced to use a mpl::for_each when using an anonymous event within a submachine. You will find the call to mpl::for_each in the compiler stack trace. Though not all events have a transition with none, MSM is forced to generate a possibility for it. Normally it is not a problem, unless you add your own on_entry replacing the default one. Having both versions will make the compiler happy and the template version will not be called. I think I'll want to revisit this implementation in a future C++14 rewrite. Regards, Christophe
participants (2)
-
christophe.j.henry@gmail.com
-
Michael Caisse