TL;DR: How should I structure my C++ project to allow for starting, stopping, and pausing my program?
I am designing an application that needs to allow users to start, pause, and stop the running of a test. The test functionality itself will be fairly straightforward, but the architecture around it has been a challenge. The program is written on Linux, in C++, using QT for UI and NetBeans for the IDE.
My high level design is as follows:
- Execution FIFO with action IDs. Actions will be generated from a custom XML configuration file
- When the program is started, the "PC" (program counter) will begin executing actions from the FIFO, keeping track of the current and next action
- If the pause button is pressed, the PC will cease to increment to allow users to view the status of various aspects of the test (think a break point)
- If the start button is pressed, the PC resumes
- If the stop button is pressed, the PC will be set to a figurative "-1" to represent non-running
My specific questions are:
Does logic like this make sense?
while notStopped if notPaused load action from fifo execute action pop else display paused / breakpoint data
Where should an execution like above (or revised) reside? Is main an appropriate location? Is a giant loop the best practice for this use case?
Where should "global" data go? Obviously global variables aren't an option, but how will all aspects of the program understand they are "paused" or "stopped"?