Boost logo

Boost Users :

From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2007-12-01 06:14:57


Hi Chris

> I have the following requirement: States A and B, where B has two
> substates
> B1 and B2. When transition occurs from B to A, and then from A
> back to B,
> under some conditions it is desired for B1 to be the initial
> substate, while
> in others we would like the substate to be chosen based on B's
> shallow
> history.
>
> Is there a concise way to obtain this behavior from the statecharts
> library?

Yep, you'd make B1 a shallow-history inner initial state, as follows:

struct B : sc::simple_state< B, Machine,
  mpl::list< sc::shallow_history< B1 > >, sc::has_shallow_history >
{
  // ...
};

(Note the need to wrap the history state into an mpl::list, see
<http://www.boost.org/libs/statechart/doc/tutorial.html#History>)

Now, whenever you need B1 to be the inner initial state (regardless
of previous history), you simply clear history information before
transitioning to B, as documented here:

<http://www.boost.org/libs/statechart/doc/reference.html#clear_shallow_history>

There's now also a FAQ item:
<http://www.boost-consulting.com/boost/libs/statechart/doc/faq.html#DisableHistory>

HTH,

-- 
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header. 

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