wrongElk
wrongElk

Reputation: 91

Hierarchical state machine with Boost MSM

Here is a question to those who have experience with Boost MSM. I have a very large state machine implemented with Boost MSM and finally today I ran out of the vector limit of 50 (there are too many events coming in to my state machine which cannot be avoided). I have created higher vector headers (vector60, vector70 etc) but I wanted to compact my state machine as a whole.

Question is, does MSM support hierarchical state machines. For example (correct me if I am wrong), in an hierarchical state machine, if an event is not handled in a particular state, that event will be forwarded to the parent state of the current state & so on.

As part of reducing the transition table size, I was hoping to create a parent state where events with common handlers will be processed thereby reducing the transition table size.

Any advise/comments appreciated.

Thanks

Upvotes: 4

Views: 1945

Answers (1)

Takatoshi Kondo
Takatoshi Kondo

Reputation: 3550

Yes, Boost.MSM support hierarchical state machines. The hierarchical state machines called as "sub machine state". It is UML term and Boost.MSM also uses it.

Here is an example of a sub machine state: http://redboltz.wikidot.com/sub-machine-state

Transition from the parent state machine to the sub state machine, you can use entry point pseudo state. See http://redboltz.wikidot.com/entry-point-pseudo-state

Transition from the sub state machine to the parent state machine, you can use exit point pseudo state. See http://redboltz.wikidot.com/exit-point-pseudo-state

The event is evaluated inner most state to outer state. So you can write common transition on the parent state machine. Here is a little practical example: http://redboltz.wikidot.com/practical-sub-machine-example

All examples contains UML state machine diagram and complete code.

Upvotes: 7

Related Questions