|
Boost Users : |
Subject: Re: [Boost-users] [msm] Two identical orthogonal regions?
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2012-05-24 16:23:08
> Hi,
>
> I am trying to put two identical orthogonal regions in a state machine
> (each region would model a "channel" and I can have multiple such
> channels).
>
> One way I can think of is duplicating the states through typedefs and
> duplicating entries in the transition table.
>
> Is there a way to avoid this duplication?
>
> Regards,
> a.
Hi,
for MSM they just need to be different types. You can define structs
inheriting from base states, you can templatize them with an int parameter,
you can even define a submachine which you inherit from and paste 2
instances, one in each region.
Though I didn't try it since the times of MSM v1, something like the
following should work (assuming Functor Front-end):
struct SubFront : msm::front_state_machine_def<SubFront>{...};
typedef msm::back::state_machine<SubFront> SubHelper;
template <int index>
struct Sub: public SubHelper{};
// Outer machine
// we have only the submachines in the regions so that it is easier to
duplicate
typedef mpl::vector<Sub<0>, Sub<1> > initial_state;
// excerpt from transition table
Row<Sub<0>,...>,
Row<Sub<1>,...>
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