|
|
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
derived class.
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
typedef Notifier | notifier_type |
The type of Notifier class this listener works with.
void attachTo (notifier_type *notifier)
| attachTo |
Attaches this Listener to notifier
.
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.
Parameters:
notifier | The Notifier object to attach to |
void detachFrom (notifier_type *notifier)
| detachFrom |
Detaches this Listener from notifier
.
If the listener is not already attached to this Notifier no error is raised.
Parameters:
notifier | The Notifier object to detach from |
friend class notifier_type | notifier_type |
Listener ()
| Listener |
[protected]
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 | c_notifier_type |
[protected]
The concrete Notifier type (i.e. the class that derives from
Notifier
void Notifier_Deleted (c_notifier_type * )
| Notifier_Deleted |
[protected virtual]
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 notifier
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.
Parameters:
notifier | The Notifier that has been deleted |
~Listener ()
| ~Listener |
[protected virtual]
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.