A Finite State Machine template and example implementation.