Boost logo

Boost Users :

Subject: Re: [Boost-users] [MSM] Boost.MSM: statemachine to transition ontemplatized event-type
From: christophe.j.henry_at_[hidden]
Date: 2015-06-01 15:19:04


Hi,
>I have a question about optimization regarding guard conditions.
>How can one optimize the states and guard-checking??

<snip>
>Is it possible to use MSM to create a parentstate "StateEval" with substates "StateEven", "StateOdd", "StateFloat" ?,
> the idea being to make transition_table as short as possible.
>
>Something like this maby (but it does not work
>
> struct transition_table : mpl::vector<
> Row<StateEval, EventT, StateEval::StateEven, none, none>,
> Row<StateEval, EventT, StateEval::StateOdd, none, GuardToOdd>,
> Row<StateEval, EventT, StateEval::StateFloat, none, GuardToFloat>
> >{};
>
>
>Basically: is it possible to create a parentstate, that listens to events (even when an inner substate is already active)?
>

>Thanks.

>nicesw123

I think what you want is a composite state / submachine (http://www.boost.org/doc/libs/1_58_0/libs/msm/doc/HTML/ch02s02.html#d0e151).
You want a submachine named StateEval and 3 substates inside, called StateEven, StateOdd, and StateFloat.
Then you want 3 direct entries (which I dislike as it is a fsm goto, please consider direct entry transitions, on the above page).
Then you save some transitions by having in your current fsm transitions originate from StateEval instead of substates. Correct?

Then yes, it works of course. See: http://www.boost.org/doc/libs/1_58_0/libs/msm/doc/HTML/ch03s02.html#d0e529. There is also an example (http://www.boost.org/doc/libs/1_58_0/libs/msm/doc/HTML/examples/CompositeTutorial.cpp) which also supports the functor front end.
About entries, you could look at: http://www.boost.org/doc/libs/1_58_0/libs/msm/doc/HTML/ch03s02.html#d0e875.

HTH,
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