问题
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