DEFINITION MVC; (* Stephan Junker 31.10.93 *) (* MVC implements the objects for the MVC architecture (Model-View-Controller) with dependencies. The model is an object which contains the data. The viewer is an object which displays the data of a model. The controller converts the users commands to calls of methods of the model to change its data, which will then send a message to all viewers depending on it to update the display. Usage: Extend type Model with the data you want to display and the procedures which work on that data. The best programming style is to hide the data and only access it via procedures. Override Open, Close, Update and Control. Then open some viewers and call ModifyData. You will see that the modification is displayed in all opened viewers. *) TYPE Model* = POINTER TO ModelDesc; ModelDesc* = RECORD (* for extension *) PROCEDURE(m : Model) Init*; (* initializes a Model *) PROCEDURE(m : Model) Changed*(aspect : LONGINT); (* must be called every time a change in the models data occured. It will update all viewers which depend on the model m by calling Viewer.Update *) END; Viewer* = POINTER TO ViewDesc; ViewDesc* = RECORD (* for extension *) model* : Model; PROCEDURE(v : Viewer) Init*; (* initializes a viewer *) PROCEDURE(v : Viewer) Open*; (* adds viewer v to the list of viewers depending on model m. This means that the viewer needs an update if data of the model is changed. The real opening of a display must be performed by a method overriding OpenViewer *) PROCEDURE(v : Viewer) Close*; (* deletes viewer v in the list of viewers depending on model m. The real closing of a display must be performed by a method overriding CloseViewer *) PROCEDURE(v: Viewer) Update*(aspect : LONGINT); (* updates the visible contents of viewer v. Model m contains the data, Aspect specifies what is to be updated and is optional. If more than four bytes are needed, it can be interpreted as a pointer. A value of 0 is predefined and means "update everything". Please override. *) END; END MVC.