|
Boost Users : |
Subject: [Boost-users] [msm] EUML submachine without macro
From: rayg (ray_at_[hidden])
Date: 2011-06-15 01:24:03
Hi,
I'm trying to define a submachine without the
BOOST_MSM_EUML_DECLARE_STATE_MACHINE macro (the "old" way - like in
http://www.boost.org/doc/libs/1_46_0/libs/msm/doc/HTML/examples/SimpleTutorialWithEumlTable.cpp).
The "main" machine works as expected. However, the submachine doesn't kick
in at all (the system asserts in default no-transition handler). Any ideas?
Ray
------------
#include <boost/msm/front/state_machine_def.hpp>
#include <boost/msm/front/euml/euml.hpp>
#include <boost/msm/back/state_machine.hpp>
using namespace std;
using namespace boost::msm::front::euml;
namespace msm = boost::msm;
//#define WITH_MACROS
//************
//* Events
//************
BOOST_MSM_EUML_EVENT(play)
BOOST_MSM_EUML_EVENT(toggle)
//*************
//* Submachine
//*************
#ifdef WITH_MACROS
//************************
//* This works fine
//************************
BOOST_MSM_EUML_ACTION(Song1_Entry)
{
template <class Event,class FSM,class STATE>
void operator()(Event const&,FSM&,STATE& )
{
// Called as expected
std::cout << "entering: Song1" << std::endl;
}
};
BOOST_MSM_EUML_STATE((Song1_Entry), Song1)
BOOST_MSM_EUML_STATE((), Song2)
BOOST_MSM_EUML_TRANSITION_TABLE((
Song2 == Song1 + toggle,
Song1 == Song2 + toggle
), sub_transition_table)
BOOST_MSM_EUML_DECLARE_STATE_MACHINE((sub_transition_table,
init_ << Song1),
_Playing)
#else
//************************
//* Doesn't work
//************************
struct Song1_impl : public msm::front::state<> , public
msm::front::euml::euml_state<Song1_impl>
{
template <typename EVENT, typename FSM>
void on_entry(EVENT const&, FSM& fsm)
{
// Not called
std::cout << "entering: Song1" << std::endl;
}
};
struct Song2_impl : public msm::front::state<> , public
msm::front::euml::euml_state<Song2_impl> { };
Song1_impl const Song1;
Song2_impl const Song2;
struct _Playing : public msm::front::state_machine_def< _Playing >
{
// Initial state
typedef Song1_impl initial_state;
BOOST_MSM_EUML_DECLARE_TRANSITION_TABLE((
Song2 == Song1 + toggle,
Song1 == Song2 + toggle
), sub_transition_table)
};
#endif
// Pick a back-end
typedef msm::back::state_machine<_Playing> Playing_impl;
Playing_impl const Playing;
//**********************************
//* Main machine
//**********************************
struct Empty_impl : public msm::front::state<> , public
msm::front::euml::euml_state<Empty_impl>
{
};
Empty_impl const Empty;
struct _Player : public msm::front::state_machine_def< _Player >
{
// Initial state
typedef Empty_impl initial_state;
BOOST_MSM_EUML_DECLARE_TRANSITION_TABLE((
Playing == Empty + play
), transition_table)
};
// Pick a back-end
typedef msm::back::state_machine<_Player> player;
int main(int argc, char* argv[])
{
player p;
p.start();
p.process_event( play );
return 0;
}
-- View this message in context: http://boost.2283326.n4.nabble.com/msm-EUML-submachine-without-macro-tp3598543p3598543.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net