基于boost状态机生成类

发布于 2024-08-25 20:44:29 字数 223 浏览 7 评论 0原文

我正在开发一个基于网络的服务器,它可能有数百个状态和操作/事件。到目前为止,我已经使用简单的 switch 语句进行了管理,但现在感觉需要一个可以通过文本/xml 文件在外部配置的状态机。

对于允许我从文件外部配置状态/事件的现有 C++ 状态机,您有何建议?

我查看了 boost 状态机,但它似乎缺乏从状态机文件生成类的能力,并且我不想手动创建 100 个类?

还有什么其他选择?

I am developing a network based server which can potentially have 100s of states and actions/events. So far I have managed with simple switch statements but now feel a need for a state machine which I can configure externally by text/xml file.

What is your suggestion for existing C++ state machine which allows me to configure states/events externally from the file?

I looked at the boost state machine but it seems it lacks the ability to generate the classes from state machine file and I don't want to create 100s of class manually?

What are other options?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百变从容 2024-09-01 20:44:30

如果你想要灵活,你应该寻找 Qt State Machine
http://doc.qt.nokia.com/4.6/statemachine-api。 html

If you want to be flexible, you should look for Qt State Machine
http://doc.qt.nokia.com/4.6/statemachine-api.html

第几種人 2024-09-01 20:44:30

QP (http://www.state-machine.com) 是另一种选择,在我看来,它对模型驱动开发非常友好。我最近读了一篇学期论文,它支持我的观点: http://security.hsr.ch/ mse/projects/2011_Code_Generator_for_UML_State_Machines.pdf

理论上,您还可以使用 boost::msm eUML 前端,它具有非常非常无噪声的语法。这是来自 boost 的一个小例子:

BOOST_MSM_EUML_TRANSITION_TABLE(( 
Playing  == Stopped + play [some_guard] / (some_action , start_playback) ,
Open     == Stopped + open_close/ open_drawer                            ,
Stopped  == Stopped + stop                                               ,
Empty    == Open    + open_close / close_drawer                          ,
Open     == Empty   + open_close / open_drawer                           ,
Stopped  == Empty   + cd_detected [good_disk_format] / store_cd_info
),transition_table)  

我不知道如何认真对待 eUML 的“实验”状态,到目前为止我还没有遇到任何问题。

QP (http://www.state-machine.com) is another option which is, in my mind, quite model driven development friendly. I read a Semester Thesis recently which supports my opinion: http://security.hsr.ch/mse/projects/2011_Code_Generator_for_UML_State_Machines.pdf

Theoretically you could also use the boost::msm eUML front end which has a very very noise free syntax. here is a trivial example from boost:

BOOST_MSM_EUML_TRANSITION_TABLE(( 
Playing  == Stopped + play [some_guard] / (some_action , start_playback) ,
Open     == Stopped + open_close/ open_drawer                            ,
Stopped  == Stopped + stop                                               ,
Empty    == Open    + open_close / close_drawer                          ,
Open     == Empty   + open_close / open_drawer                           ,
Stopped  == Empty   + cd_detected [good_disk_format] / store_cd_info
),transition_table)  

I don't know how seriously to take the "experimental" status of eUML, I have not had any problems with it so far.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文