Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2004-09-15 23:57:47

Andreas Huber wrote:
> Nitpick: By convention, if there's no transition for the current event
> from the current state then the event is simply discarded. If I read
> your code right, then it wouldn't compile if this is attempted. Wait, it
> seems that it doesn't compile if a given state has no transition for
> *any* of the events? Is that what you were talking about in one of your
> previous posts with enable_if, etc.?

Right. If you add unique id to each transition function (vector of
states can be removed after that) and apply my algorithms you'll get it.

This is how it will look like from a user point of view:

struct Fsm : state_machine<Fsm>
  Stopped operator()( overload_id<1>, Running, EvStartStop )
    return Stopped();

  Running operator()( overload_id<2>, Stopped, EvStartStop )
    return Running();

  Stopped operator()( overload_id<3>, Active, EvReset )
    return Stopped();

  typedef mpl::range_c<1,4> transitions;

There is no states because they can be collected from result types of
call operators (unique_at<Fsm,Fsm::transitions,0>::type gives a list of
positions, list<int_<1>, int_<2> > in the example, and for_all algorithm
transforms sequence of positions into sequence of signatures and then
execute something like create variant or destoy it).

Alexander Nasonov

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