Best way to interchange state machines?
-
I have an interface that I want my back end to react differently based on the state machine.
basically, state machine detects button presses, and transitions based on how it was configured. Is there an easy way to reset the transitions and remake them?
My UI has 6 buttons and sets a device with up to 8 modes. I want the state machine to have three distinct operating modes:
6 button on/off: device plays mode specific sound on loop until a different mode is selected or the same mode is selected, toggling the sound off.
4 button on/off with volume buttons: device has 4 mode buttons, and two that raise or lower the volume.
4 button on/off with volume buttons: device has 4 mode buttons which rotate between two modes and the off state, allowing the device to have 8 modes total, and two volume buttons.
I understand the logic in the state machine behind implementing each of these, but I need a clean way to change between each of these separate state machines. Here are my options:
Option 1: 1 state machine to rule them all: create a single giant state machine with 3 different parent states.
Option 2: create three separate state machines objects, perhaps all inheriting from one parent which contains virtual methods.
Option 3: create a single smaller object, with slots that allow it to set/reset the transitions between states when the mode changes.
Is there a better idea from a design/architect standpoint or which would you recommend of the above?
-
This isn't really a Qt question.
I would personally go with Option 2 though.
You would probably get better results on a C++ based message board, maybe "stackoverflow.com":www.stackoverflow.com...