Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.MSM: Exit a composite state after an event has been fired from that composite state?
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2012-12-21 17:57:46


Hi,

> I think the base problem occurs in the compilation phase, due to the fact,
> that the template event type of the *process_event(...)* function isn't
> distinct due to the different types defined in *boost::variant<...>* as
> state above in the main() function.

Indeed, MSM does not support boost::variant. It knows only concrete event
types.

>In contrast to that the following code
> snippet works fine.
>
> ....
> osm.enqueue_event(Event1());
> osm.enqueue_event(Event2());
> osm.enqueue_event(Event3());
>
> osm.execute_queued_events();
>
> ...
>
> Using the *enqueue_event()* function call has unfortunately the
> constraint,
> that for each sub-machine a own event queue is used and for each
> sub-machine
> the call execute_queued_events has to be triggered. I don't want this. I
> want to queue all possible events of the all submachines and to call
> execute_queued_events function from a central position.

Same as last question, you need to enqueue on the top-level fsm, then it
should work. This is no different from what we just discussed.
I know it's not fun to keep a pointer to the top-level fsm but for the time
being, there is no choice. I don't think trying to work around this will
work (I tried ;-) ).

> Do you have an idea how I could solve this issue. Does MSM provide a
> global
> event queue? If not, it would be necessary to provide each sub-machine
> with
> a pointer to the outermost submachine to be able to put events to the
> event
> queue. Afterwards "execute_queued_events()" can be called by the
> control-logic which encloses the overal state machine.

Each fsm has its own event queue, including submachines. If you enqueue into
the one of the top-level fsm, it will work fine.
Actually, this feature is pretty basic. If you look at the code, it just
builds a list of boost::function of functors created by boost::bind.
You could easily build your own if this one does not fit your needs, there
really is no magic there.

> Thank you in advance!
>
> Sorry für die vielen Fragen, muss jedoch abwägen, ob MSM für den
> produktiven
> Einsatz in
> einem noch zu entwickelden Software-Produkt geeignet ist.

Sorry that I answer fast, I'm leaving for 2 weeks tomorrow and will be only
online again on the 7th Jan.

> Grüße,
>
> RaRi

Cheers,
Christophe


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