如何在Boost MSM中传递附加参数int状态进入或退出函数

问题描述 投票:0回答:1

我想在Boost.MSM状态进入或退出函数中提供我自己的函数参数。有可能吗?

例如,原始示例是:

BOOST_MSM_EUML_ACTION(state_entry)
{
  template <class Event, class Fsm, class State>
  void operator()(const Event &ev, Fsm &fsm, State &state) const
  {
    std::cout << "Entering\n";
  }
};

BOOST_MSM_EUML_ACTION(state_exit)
{
  template <class Event, class Fsm, class State>
  void operator()(const Event &ev, Fsm &fsm, State &state) const
  {
    std::cout << "Exiting\n";
  }
};

BOOST_MSM_EUML_STATE((state_entry, state_exit), Off)
BOOST_MSM_EUML_STATE((state_entry, state_exit), On)

我想要的是类似的东西:

BOOST_MSM_EUML_ACTION(state_entry)
{
  template <class Event, class Fsm, class State>
  void operator()(const Event &ev, Fsm &fsm, State &state, int n) const
  {
    std::cout << "Entering\n";
  }
};

BOOST_MSM_EUML_STATE((state_entry(100), state_exit), Off)
boost state-machine
1个回答
0
投票

不确定是否可以。但是据我所知,您必须在那些函数之外声明该属性。例如,首先声明新属性:

© www.soinside.com 2019 - 2024. All rights reserved.