-
Notifications
You must be signed in to change notification settings - Fork 4
Ctrl
MoloVol uses an adapted Model-View-Controller design pattern in order to structure front and backend communication. The user interacts with the GUI (View). When an action is requested, the action is usually managed by the Controller which may send the request, along with inputs, toward the Model. The model deals with the program logic, i.e. all heavy computations.
The advantage of this design pattern is, that the Model operates entirely independent of the View. As a consequence, simultaneous development on front and back end sections of the code are easier. Additionally, the program logic is not affected by external libraries used for the View, which in principle allows replacing the View entirely with the Model unaffected.
The controller is represented by the Ctrl class. The Ctrl class is implemented in a singleton design pattern in order to make sure that only one Ctrl instance can exist and to allow the Controller to be accessed from any class (although it is usually preferable to go through the Model or View).
Ctrl()The constructor should only be called once, exclusively through the static getInstance() function. The first time getInstance() is called it creates and stores a pointer to a Ctrl object. The resulting pointer is stored inside s_instance and remains valid for the entire runtime. Each consecutive calls to getInstance() simply return the stored pointer.
- getInstance() (static)
- runCalculation()
static Ctrl* s_instance
static MainFrame* s_gui
Model* _current_calculation
bool _abort_calculation
bool _calculation_finished
bool _to_gui