Try OpenEdge Now
skip to main content
Object-oriented Programming
Object-oriented Programming and ABL : Overview of class-based ABL : Defining class events
 

Defining class events

You can define events as class members that allow you to send (publish) notification of any run-time conditions that you detect. Your application can then respond to this notification by executing one or more methods and internal procedures (event handlers) that you specify (subscribe) for the event. ABL allows you to define a class event with a name and a signature using the DEFINE EVENT statement. The signature defines the parameters (if any) that any subscribed event handler must have. An event can be defined with an access mode of PRIVATE, PROTECTED, or PUBLIC, where PUBLIC is the default. The event access mode determines where in an application you can subscribe event handlers to the event. You define no executable code in an event definition. Event handlers provide all the code that executes for an event.
Within an abstract class, you can also define an event as ABSTRACT, which means that it must be overridden and implemented in a subclass. An abstract event is defined by its signature, declared as a prototype. The first non-abstract derived class in the subclass hierarchy must override and implement the event as non-abstract, unless an abstract class has already done so. However, unlike abstract properties and methods, there is no executable code to implement an abstract class event. So, the overriding event definition used to implement an abstract event is very similar to the abstract prototype originally used to define the abstract event. The result of implementing an abstract event is that the subclass which implements the event is the only class where you can directly publish the event. Any override of an abstract class event can also specify a less restrictive access mode.
Note: Unlike methods, you can only override an inherited event that is defined as abstract.
ABL also supports static events that are associated with a class type rather than a class instance as for instance events. Unless otherwise specified, any reference to a class event in this manual refers to an instance event. For more information on static class members, see Usingstatic members of a class.
You can publish and subscribe event handlers to class events by calling built-in methods (event methods) that ABL supports only on class events. For more information on the event methods for publishing and responding to class events, see Publishing and responding to class events. For more information on defining class events, see Definingevents within a class.
* Comparison with procedure-based programming