Boost logo

Boost :

Subject: [boost] [MSM] Surprising Entry Point behaviour
From: Michael Caisse (mcaisse-lists_at_[hidden])
Date: 2016-03-04 00:44:53


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


msm_bug.png

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk