Boost logo

Boost :

Subject: Re: [boost] [msm] eUML guard/action location
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2010-01-12 18:48:43

> 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
Ok, for states, it's trivial:


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:

        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
// the action instance for use in the stt
// the action code

# define BOOST_MSM_ACTION(tuple) \
    struct BOOST_MSM_ACTION_TYPE(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?

Boost list run by bdawes at, gregod at, cpdaniel at, john at