Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2005-03-14 03:34:08


Peter Petrov wrote:
> Suppose that we have nested states, and we use state-local storage in
> the outer state. Now, for as long as we don't leave the outer state,
> (only making transitions between its inner states), it is natural to
> keep its storage. I.e. the lifetime of the storage should be the same as
> the logical lifetime of the state.
>
> Judging from your brief description of your approach, I presume that
> leaving an inner-state will also destroy the outer-state, since they are
> the same object (you said: "inheritance is used to model states
> hierarchy").

You're right. It has a different model. There is no outer state.
Inheritance is used only to reduce number of transitions from
a group of states to one transition from their common base.

Of course, you can store outer state data in base class as shared_ptr
and pass this pointer to all derived states.

-- 
Alexander Nasonov

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