Designing a state machine in C++
- by skyeagle
I have a little problem that involves modelling a state machine.
I have managed to do a little bit of knowledge engineering and 'reverse engineer' a set of primitive deterministic rules that determine state as well as state transitions.
I would like to know what the best practises are regarding:
How to rigorously test my states and state transitions to make sure that the system cannot end up in an undeetermined state.
How to enforce state transition requirements (for example, it should be impossible to go directly from stateFoo to StateFooBar, i.e. to embue each state with 'knowlege' about the states it can transition to.
Ideally, I would like to use clean, pattern based design, with templates wherever possible.
I do need somewhere to start though and I would be grateful for any pointers (no pun intended), that are sent my way.