开发者

Generating classes based on boost state machines

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?


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) 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜