如何在 boost::statechart state_machine 对象中获取当前最派生的状态?
我正在使用 boost::state_chart 库。 出于调试目的,我想知道在任何给定时间我的状态机的状态。 如何获取 state_machine 对象中的当前(最派生的)状态?
I am using boost::state_chart library.
For debug purposes, I would like to know at any given time the state of my state machine.
How to get the current (most derived) state in the state_machine object ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 state_machine::state_begin 和 state_machine::state_end 获取当前状态对象,请参阅此处的“自定义状态查询”:
http://www.boost.org/libs/statechart/doc/tutorial.html#StateQueries
这些为您提供基类指针,如果你想要获得最派生的类型,你必须雇用某种访问者。
You can get at the current state object(s) with state_machine::state_begin and state_machine::state_end, see "Custom State Queries" here:
http://www.boost.org/libs/statechart/doc/tutorial.html#StateQueries
These give you base class pointers, if you want to get at the most-derived type you'd have to employ a visitor of some sort.