next up previous
Next: View Up: Models, Controllers and Views Previous: Model

Controller

User's controllers must derive from this class. A controller is always associated with one model, that the controller can monitor and modify. At the other side the controller can control a View. Two members called model and view holds the corresponding instances.

Typically (but not always!) a Controller instance is also an Observer for some Observable Property inside the controlled model. Indeed, the constructor gets a model instance, that the controller uses to register itself as an observer of the model.

An important method that user can override is registerView, that the associated view will call during registration. This can be used to connect custom signals to widgets of the view, or to perform some initialization that can be performed only when model, controller and view are actually connected. registerView gets the view instance that is performing its registration within the controller. If user overrides registerView, they must call method registerView of the base class.

The controller holds all the code that lives between data in model and the view. For example the controller will read a property value from the model, and will send that value to the view, to visualize it. If the property in the model is an Observable Property that the Controller is interested in monitoring, than when somebody will change the property, the controller will be notified and will update the view.


next up previous
Next: View Up: Models, Controllers and Views Previous: Model
Roberto Cavada 2004-11-16