Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.msm] BOOST_MSM_EUML_DECLARE_STATE_MACHINE with state base class
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2014-05-25 15:19:25


> Hi there,
>
> I use MSM from boost 1.49 with VC9 on Windows XP.
> I want to use the eUML front end.
> My states shall use a polymorphic base class and are defined
> like this:
>
> // State base class
> struct Worker { virtual void work() = 0; };
>
> // a state
> struct Running_ : msmf::state<Worker>, euml_state<Running_>
> {
> void work() { ... }
> } const Running;
>
> My transition table is defined with BOOST_MSM_EUML_TRANSITION_TABLE()
>
> My state machine is defined like this:
>
> BOOST_MSM_EUML_DECLARE_STATE_MACHINE((
> trans_table,
> init_ << AnyState,
> no_action, // fsm_entry
> no_action, // fsm_exit
> attributes_ << one_attr << another_attr,
> configure_ << no_configure_,
> Log_No_Transition,
> Log_Exception),
> MyFSM_fe)
>
> struct FSM : msmb::state_machine<MyFSM_fe> {};
>
> All OK until here.
>
> But now I want to add the state base class to the
> above invocation of BOOST_MSM_EUML_DECLARE_STATE_MACHINE to be
> able to say :
>
> fsm.get_state_by_id(fsm.current_state()[0])->work()
>
> at any given time.
>
> BOOST_MSM_EUML_DECLARE_STATE_MACHINE((
> trans_table,
> init_ << Running,
> no_action, // fsm_entry
> no_action, // fsm_exit
> attributes_ << one_attr << another_attr,
> configure_ << no_configure_,
> Log_No_Transition,
> Log_Exception,
> Worker),
> MyFSM_fe)
>
> But this gives me a compile error:
>
> C2275: 'Worker' : illegal use of this type as an expression.
>
> Is there any way to achieve what I need ? Can I somehow
> _NOT_ use the macro and create the same state machine (i.e. with
> attributes!) ?
>
> Thanks for any help!
>
> Stefan

Hi,
I just tried it out. Worker is a type and we need an instance in
BOOST_MSM_EUML_DECLARE_STATE_MACHINE, so it should be:
...
Log_Exception,
Worker()),
MyFSM_fe)

Unfortunately it would not compile because of the pure virtual. At the
moment I'm afraid we have to live with the limitation of having a simple
virtual work().

HTH,
Christophe


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