The Listener class receives events sent from a Notifier class.
Listener inherits from the specified
interface_type so you don't need
to mupltiply inherit from both Listener the
interface_type in your
To instatiate the Listener class inherit from Listener
class Voyeur : public Listener
Upon deletion, the Listener class ensures that it is detached from every Notifier it has been attached to. This prevents a Notifier later trying to callback to an invalid object.
See also: Notifier
The type of Notifier class this listener works with.
|void attachTo (notifier_type *notifier)
Attaches this Listener to
You can only attach to a Notifer object once - any subsequent attempt to attach to it results in nothing happening; it is not an error, but the Listener will still only ever receive one copy of any event.
|notifier||The Notifier object to attach to|
|void detachFrom (notifier_type *notifier)
Detaches this Listener from
If the listener is not already attached to this Notifier no error is raised.
|notifier||The Notifier object to detach from|
|friend class notifier_type|
| Listener ()
Creates a new Listener which is not attached to any Notifier.
Use attachTo to attach to Notifiers.
You can only subclass this type, not instanitate it directly.
|typedef interface_type::notifier_type c_notifier_type|
The concrete Notifier type (i.e. the class that derives from
| void Notifier_Deleted (c_notifier_type * )
This may be implemented by Listener classes if they care about a Notifier object being deleted.
It is called by the Notifer destructor - so the
is in the process of being deleted. Therefore it is not safe to
call methods on the event source object any more.
You do not need to detachFrom the the Notifier since the link is automatically broken for you.
|notifier||The Notifier that has been deleted|
| ~Listener ()
The destructor ensures that the Listener is detached from every Notifier it has been attached to.
This means that you don't have to specifically detach from all Notifier sources yourself, although it is still considered good practice to do so.