Oberon || Library || Module Index || Search Engine || Definition || Module
CONST debug = 0; CONST message = 1; CONST warning = 2; CONST error = 3; CONST fatal = 4; CONST bug = 5; CONST nkinds = 6; TYPE Kind = SHORTINT; (* debug..bug *) VAR kindText: ARRAY nkinds OF ARRAY 12 OF CHAR; TYPE Handler = PROCEDURE (event: Events.Event; kind: Kind); TYPE HandlerSet = POINTER TO HandlerSetRec; TYPE HandlerSetRec = RECORD (Disciplines.ObjectRec) END; TYPE WriteProcedure = PROCEDURE (s: Streams.Stream; event: Events.Event); VAR null: HandlerSet; (* empty handler set *)
PROCEDURE CreateHandlerSet(VAR hs: HandlerSet); PROCEDURE InstallHandler(hs: HandlerSet; kind: Kind; handler: Handler); PROCEDURE AssignWriteProcedure(eventType: Events.EventType; write: WriteProcedure); PROCEDURE Write(s: Streams.Stream; event: Events.Event); PROCEDURE CatchEvent(hs: HandlerSet; kind: Kind; type: Events.EventType);
A handler set defines a handler for each kind of events. CreateHandlerSet creates a new handler set and initializes it to the empty set. By default, all events are ignored (empty handler). InstallHandler installs a handler for the given class of events for hs.
Many events contain additional components which contain interesting information beyond the simple text of the message component. AssignWriteProcedure allows to attach a specific write procedure to an event type. Write calls either a previously assign write procedure or, in the default case, copies event.message to s.
CatchEvent associates kind with the given event type and causes the appropiate handler of hs to be called if type is raised.
Oberon || Library || Module Index || Search Engine || Definition || Module