Boost logo

Boost Users :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2008-06-20 03:09:37


On Thu, Jun 19, 2008 at 5:22 PM, Andreas Huber
<ahd6974-spamboostorgtrap_at_[hidden]> wrote:
> "Felipe Magno de Almeida" <felipe.m.almeida_at_[hidden]> wrote in message

[snip]

> Hm, something along these lines might actually work. Remember though, that a
> transition could potentially create more than one state object, so an
> example factory object could look like this:
>
> class MyStateFactory
> {
> public:
> MyStateFactory(/* arguments that should be passed to state ctors */)
> {
> /* store arguments in data members */
> }
>
> template<class State>
> boost::intrusive_ptr<State> construct()
> {
> return new State(/* ctor arguments here */);
> }
> };
>
> construct() would be called once for each state that is created as a result
> of a transition. If you want to treat different state types differently
> you'd need to specialize.

I was thinking more that boost.statechart would always use a functional factory,
like boost::function<State*>() to instantiate states.
And that when using transit<>(args), transit could create a different
factory for this
and pass along. when no argument is given or *can* be given, a simple
boost::factory<State>() would be used as factory.

> Thoughts?

Is this possible?

> Regards,
>
> --
> Andreas Huber

-- 
Felipe Magno de Almeida

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