Boost logo

Boost Users :

From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2007-03-27 15:54:26


Hi Philippe

> I would like to reuse a state in statechart at different places of
> the state machine (so it can be a sub-state of at least 2 other
> states) or in different state
> machines. Since the state class has a template parameter with the
> context I am a bit stuck here. Have you done that yet or have an idea
> about how to do it ?

Make the state in question a template, example:

http://www.boost-consulting.com/boost/libs/statechart/doc/tutorial.html#SubmachinesAndParameterizedStates

Here the states On and Off are parametrized with an enum. You can of
course parametrize them with just about anything, including their
context. Templated states have a few gotchas though:

-
http://www.boost-consulting.com/boost/libs/statechart/doc/faq.html#TemplatedStates
- All base class members become dependent names. You therefore need to
prepend base member function calls with this-> and fully qualify base
typedefs.

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