Iterate transition table (boost:msm) in runtime in order to read the associated event to an specific transition

强颜欢笑 提交于 2021-01-29 05:11:37

问题


I am new in MPL and Finite MSM from boost. I would like to iterate the transition table in order to get the associated transition event given 2 the transition states (current, next).

I define and I get the transition table (vector50) like this:

struct<my_state_machine_>{
    (...)

    struct transition_table : boost::mpl::vector50<
      a_row < StateA ,eventAB ,StateB ,&my_machine_state_::action>,
      (...)
      > {};
};

typedef boost::msm::back::state_machine<my_state_machine_> my_fsm;
typedef boost::msm::back::state_machine<my_machine_state_>::stt stt;

Then I want to iterate the MPL vector (stt) passing 2 conditions to the lambda, like this:

template <typename T>
struct Finder {
  bool operator()() const { 
    /*todo: it will not compile, but it is the next issue*/
    return T::Current == <A predefined state> && T::Next == <Another state>; 
  }
};
boost::mpl::for_each<stt, boost::type<boost::mpl::_>>(Finder<my_fsm::a_row<StateType, boost::any, StateType, &my_fsm::action(*boost::any) > )>>());

It doesn't compile. I don't know how to pass a generic action or just getting rid of it. I want to iterate the transition table and check both states. I don't care about the action.

Is it possible? How?

Thanks!

来源:https://stackoverflow.com/questions/63852578/iterate-transition-table-boostmsm-in-runtime-in-order-to-read-the-associated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!