基于boost状态机生成类
我正在开发一个基于网络的服务器,它可能有数百个状态和操作/事件。到目前为止,我已经使用简单的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想要灵活,你应该寻找 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
QP (http://www.state-machine.com) 是另一种选择,在我看来,它对模型驱动开发非常友好。我最近读了一篇学期论文,它支持我的观点: http://security.hsr.ch/ mse/projects/2011_Code_Generator_for_UML_State_Machines.pdf
理论上,您还可以使用 boost::msm eUML 前端,它具有非常非常无噪声的语法。这是来自 boost 的一个小例子:
我不知道如何认真对待 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:
I don't know how seriously to take the "experimental" status of eUML, I have not had any problems with it so far.