Imagine a part of your state machine looks like this:
How do you properly implement the choice part in Qt? I know there are guarded transitions, but that would mean that I need to:
- Create a subclass of a QAbstractTransition which accepts e.g. an
std::function<bool()>
and a flag which determines if the transition happens when that boolean result is true, or when it is false - Create two instances of this class with the same boolean function, but opposite transition guards
- Add two transitions from
S1
using these two instances.
That approach seems kind of clumsy and error prone for something as simple as a choice. Is there a more maintainable approach to implement this?