2 ms·
We needed a state machine to manage app startup in Ardour, and initially (since we're using C++) we used a boost library for this. It was pretty cool - you jus
by PaulDavisThe1st 2y ago
We needed a state machine to manage app startup in Ardour, and initially (since we're using C++) we used a boost library for this.
It was pretty cool - you just create a text based table describing state transitions and various methods that execute before, after and as a result of the transition, and it generates all the code for you. It was very, very quick to get things basically working with this template library.
But then ... we had to start dealing with corner cases and some fiddly little details of precisely how this FSM was supposed to work.
We still have the table in a comment in the code, because it's probably one of the easiest things to read to understand the FSM, but the implementation is now just the usual C/C++ nested switch statements.