[msm] Two identical orthogonal regions?
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,
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<1> > initial_state; // excerpt from transition table Row,...>, Row,...> HTH, Christophe
On 24/05/2012 4:23 PM, Christophe Henry wrote:
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<1> > initial_state; // excerpt from transition table Row,...>, Row,...>
HTH, Christophe
Thank you very much, it worked fine! Regards, a.
participants (2)
-
Aurelian Melinte
-
Christophe Henry