Boost logo

Boost Users :

From: Andre Massing (massing_at_[hidden])
Date: 2008-04-06 09:09:39


Hi,

I am implementing a fsm for a kind of a project class, which tracks certain
changes like adding special files or starting a computation. To keep the
interface as small/clean as possible all interactions with the fsm should be
soley processed by the process_event method.
But seemingl I have to declare transition actions public in an outer state to
make them available for inner state reactions/transitions. Is there any nice
way to avoid this and to keep transition actions separated from the public
interface? (Declaring *all* inner states which need access to be friend seems
too ugly to me...)

A small code snippet to demonstrate my issue:

In Project.h:

struct Idle;

struct Project : sc::state_machine< Project, Idle >
{
public:
//....
void solve(const EvSolve &);
//...
};

//...

struct Idle : sc::simple_state< Idle, Project, mpl::list<GeoState,
SolverState> >
{
    typedef mpl::list<
        sc::custom_reaction< EvCompile >,
        sc::custom_reaction< EvSolve >
> reactions;
    sc::result react(const EvCompile &);
    sc::result react(const EvSolve &);
};

In Project.h:

sc::result Idle::react(const EvSolve & ev)
{
//...
return transit<Solve>(&Project::solve, ev);
}

Regards,
Andre


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