This example should improve the understanding of the Controller and how it works. First there is an Overview of the model of OpenCAGE, called Mainloop. Then a sequence diagram shows a typical sequence of actions.
This means an overview of all relevant classes of the Controller.
The Action Handler is connected to the GUI. If it gets an Event from a Dialog, for example, it tells the specific Command Factory to produce a Command. The Command Factory creates a Command and defines respectively creates the Data Gate, the Data Source and the Data Drain for the Command. The Preset Data is fetched from the Preset Parameter Pot (PPP). Later if the preferences of the Dialog differ from the Preset Parameter Pot (PPP), they will be written in the Command Parameter Pot (CPP). The Command is recieved by The Action Handler and it is putted in the Master Inpile (MIP). Then the Command passes trough the Command Pipiline, where Observers can be registered. In the end the Command is handed over to the Command Catchment Bassin (CCB).
Here the example of Starting Analysis is shown.
At the start of OpenCAGE the class Init creates the Analysis Master and its Factory, here the Analysis Command Factory (Analysis CmdF.). If a new Event (New_Event(event)) is recieved, it is handed over to the Action Handler. The Action Handler tells the Analysis Command Factory to create a Command (Create_Command()). Now, the Command, its Command Parameter Pot (CPP) and its Data Gate are created. The Data Source is set and Data Drains can be added. Then the Analysis Command Factory sets the Gate for the Command. After that, the Command is handed over back to the Action Handler which puts the Command on top of the Pipe (Blow(command)), more exact would be in the Master Inpile (MIP).
Now the Command passes trough the phases of the Command Pipeline (Pipe). First the Debug Observer is registered. The Observers are informed about every step the Command does (Notify(new_state)). Second, Collect Data is up. The Command collects all required data by using its Data Gate. The data is normaly fetched from the GUI object, here Analysis Master. The Command Parameter Pot (CPP) is updated. After that the Data Gate is destroyed and the Command hands over the collected data . Then a Script Observer can be registered. In this case it is not. Now, the Execution phase begins. The Command executes itself and is registered in the Command Catchment Bassin (CCB). Here the Command stays until it is not needed any more and therefor destroyed.