[boost.msm] BOOST_MSM_EUML_DECLARE_STATE_MACHINE with state base class
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
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
{ 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
{}; 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
Am 25.05.2014 21:19, schrieb Christophe Henry:
[...] 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().
OK. Meanwhile I thought about using an internal transition to achieve what I need. Thanks, Stefan -- ---------------------------------------------------------------- /dev/random says: Your email has been returned due to insufficient voltage. python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9 9666 829B 49C5 9221 27AF
Am 26.05.2014 08:29, schrieb Stefan Näwe:
Am 25.05.2014 21:19, schrieb Christophe Henry:
[...] 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().
OK.
Meanwhile I thought about using an internal transition to achieve what I need.
...and then I thought: What can a *state* do on an internal transition ? I can do (with msm.euml): ... SomeState + SomeEvent / SomeAction ... But actually I want 'SomeState' to decide what it does on 'SomeEvent'. Wouldn't it make sense to call, for example, SomeState::operator()(SomeEvent const&) (or a templated form of that) in that case ? Or maybe 'SomeState::on_internal(...)' ? Any thoughts? Regards, Stefan -- ---------------------------------------------------------------- /dev/random says: I'm not confused. I'm just well mixed. python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9 9666 829B 49C5 9221 27AF
I can do (with msm.euml):
... SomeState + SomeEvent / SomeAction ...
But actually I want 'SomeState' to decide what it does on 'SomeEvent'.
Wouldn't it make sense to call, for example,
SomeState::operator()(SomeEvent const&)
(or a templated form of that) in that case ? Or maybe 'SomeState::on_internal(...)' ?
Any thoughts?
Regards, Stefan --
Hi Stefan, you can achieve the same with a transition table internal to a state, with the added bonus that you can have guards and therefore several possible actions depending on them. HTH, Christophe
participants (2)
-
Christophe Henry
-
Stefan Näwe