Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2005-02-12 17:17:13


David Abrahams wrote:
> What is "class state?" Can you describe its domain? What are the
> principle abstractions in that domain?
Ok, you catched me. In most cases, these members are shared across states.
So, they have to be members of Fsm.
Class states might hold a "baton" to pass on to a next state but I don't see
any important use case.

> If I try to map what you're describing onto the state machine designs
> that we did for "C++ Template Metaprogramming" (and that I posted
> here), I could achieve something similar by simply putting storage for
> auxilliary data (like speed) in a data member of the derived FSM
> class.

The man who invented examples is the greatest inventor of all time! After
looking at mpl example I understand what do you mean.

My code can be rewriten to support your style. You could typedef Running as
state<0>, Stopped as state<1> and so on.
The framework could find out that all state<N> are stateless (what a mess!
:) and left out storage generation for them.
I wonder when and why you need these numbers? Not for passing to switch
statement, I hope?
I suppose, you use them to check for a particular state of set of states
like whether FSM is in final state(s) or not.
If you do so, I do so as well.

> While I have to admit that your particular example seems to naturally
> call for associating that auxilliary data directly with the state
> class, that model doesn't generalize well AFAICT. There could be
> auxilliary data that's needed -- persistently -- for more than one
> state.

Agree.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk