|
Boost : |
Subject: Re: [boost] [msm] eUML guard/action location
From: David Bergman (David.Bergman_at_[hidden])
Date: 2010-01-12 18:53:38
Cristophe, I could definitely help out with macros and use of PP for MSM, if you need that help. Unfortunately, the next few weeks (at least) are a bit too hectic. But, now you know that I might be willing (if not currently available) :-)
/David
On Jan 12, 2010, at 6:48 PM, Christophe Henry wrote:
>> IMO making it easy for the user to declare these things (maybe with a
>> macro) and documenting that as the normal approach, dropping all the
>> parens, could be a big improvement.
>
> Unfortunately, I'm pretty bad at macros (and try to avoid them as much
> as I can) and after spending quite some time at it, I don't come
> further.
> Ok, for states, it's trivial:
>
> BOOST_MSM_STATE((Empty_Entry(),Empty_Exit()),Empty_,empty)
>
> Where Empty_ is the state type name and empty the instance for use in
> the transition table.
>
> Implemented with:
> # define BOOST_MSM_STATE(expr,state_name,instance_name) \
> typedef BOOST_TYPEOF(build_state(expr)) state_name;state_name
> const instance_name;
>
> Where it gets slightly more "fun" is when I want to also remove the
> parens for the actions/guards. For example, if I have an action called
> start_playback which is:
> struct start_playback : euml_action<start_playback>
> {
> template <class FSM,class EVT,class SourceState,class TargetState>
> void operator()(EVT const& ,FSM&,SourceState& ,TargetState& )
> {
> cout << "player::start_playback" << endl;
> }
> };
>
> I want to use the same principle. start_playback_ will be the type and
> start_playback the instance. I come to:
>
> BOOST_MSM_ACTION((start_playback_,start_playback,
> (({
> template <class FSM,class EVT,class SourceState,class TargetState>
> void operator()(EVT const& ,FSM&,SourceState& ,TargetState& )
> {
> cout << "player::start_playback" << endl;
> }
> }))
> ))
>
> I thought of using PP tuple:
> // the action type
> #define BOOST_MSM_ACTION_TYPE(x) \
> BOOST_PP_TUPLE_ELEM(3,0,x)
> // the action instance for use in the stt
> #define BOOST_MSM_ACTION_INSTANCE(x) \
> BOOST_PP_TUPLE_ELEM(3,1,x)
> // the action code
> #define BOOST_MSM_ACTION_CODE(x) \
> BOOST_PP_TUPLE_REM_CTOR(1,BOOST_PP_TUPLE_ELEM(3,2,x))
>
> # define BOOST_MSM_ACTION(tuple) \
> struct BOOST_MSM_ACTION_TYPE(tuple):
> euml_action<BOOST_MSM_ACTION_TYPE(tuple)> BOOST_MSM_ACTION_CODE(tuple)
> ; BOOST_MSM_ACTION_TYPE(tuple) const BOOST_MSM_ACTION_INSTANCE(tuple)
> ;
>
> But I fail at getting the action correctly so I generate:
> struct start_playback_: euml_action<start_playback_> ({ template... //
> notice the extra parens
>
> I hoped that REM_CTOR would do the job but no.
> Any idea if it is possible?
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk