Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.msm] BOOST_MSM_EUML_DECLARE_STATE_MACHINE with state base class
From: Stefan Näwe (stefan.naewe_at_[hidden])
Date: 2014-05-28 02:26:33


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

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