The Notifier/Listener Framework

The TSE3 library uses a version of the "Observer" design pattern (GoF book), both as a part of it's public API and for internal implementation.

This design pattern is a framework for publishing information about events of interest. These events are multicast to every interested object. Objects can register an interest and revoke this at any time.

In the TSE3 implementation, the object which multicasts the events is of the Notifier class. Object which listen to these events are Listener classes.

These classes are documented fully in the tse3/Notifier.h header file. The system is flexible, and type safe. The multicast 'events' are implemented as callbacks on member functions. These member functions may have any number of parameters of any type.

Essentially, for each Notifier type a specific interface class is defined. This interface describes each of the possible events that may be emitted by that Notifier. Let's call this interface interface_type.

Now a class that can emit events inherits from Notifier<interface_type>. The implementation of the class can emit events by calling it's protected notify method.

A class that listens to these events inherits from Listener<interface_type>. This means that it also inherits the interface_type, and so implements the member functions that recieve events.

Now, a Listener can register an interest in events by calling Listener::attachTo for the appropriate Notifier, and revoke this interest with Listener::detachFrom.

History

In TSE3 versions 0.0.12 and later the Notifier framework is considerably improved. The system is now a lot more safe, elegant and above all easy to use.

See also

Notifier.h for definitions of the notifier framework classes and KDOC class documentation.
© Pete Goodliffe, 2000