Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

TSE3::Listener< interface_type > Class Template Reference

Listener interface for Notifier events. More...

#include <Notifier.h>

Collaboration diagram for TSE3::Listener< interface_type >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef Notifier< interface_type > notifier_type

Public Member Functions

void attachTo (notifier_type *notifier)
void detachFrom (notifier_type *notifier)

Protected Types

typedef interface_type::notifier_type c_notifier_type

Protected Member Functions

 Listener ()
virtual void Notifier_Deleted (c_notifier_type *)
virtual ~Listener ()

Friends

class notifier_type

Detailed Description

template<class interface_type>
class TSE3::Listener< interface_type >

Listener interface for Notifier events.

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<NotifierType>. Following the example in the Notifier documentation, this would be:

class Voyeur : public Listener<ExhibtionistListener> { public: virtual void eventOne(Exhibitionist *src) { ... } virtual void eventTwo(Exhibitionist *src, int a) { ... } virtual void Notifier_Deleted(Exhibitionist *src) { // The 'src' is being deleted - you do not need to // detach from it, the link is automatically broken.

// This method is not defined in the // ExhibitionistListener base class, but is defined by // the Listener<ExhibitionistListener> class. You // don't have to implement it if you don't need it. } };

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.

Author:
Pete Goodliffe
Version:
3.00
See also:
Notifier


Member Typedef Documentation

template<class interface_type>
typedef Notifier<interface_type> TSE3::Listener< interface_type >::notifier_type
 

The type of Notifier class this listener works with.

template<class interface_type>
typedef interface_type::notifier_type TSE3::Listener< interface_type >::c_notifier_type [protected]
 

The concrete Notifier type (i.e. the class that derives from Notifier<interface_type>.


Constructor & Destructor Documentation

template<class interface_type>
TSE3::Listener< interface_type >::Listener  )  [inline, protected]
 

Creates a new Listener which is not attached to any Notifier.

Use attachTo to attach to .

You can only subclass this type, not instanitate it directly.

template<class interface_type>
virtual TSE3::Listener< interface_type >::~Listener  )  [inline, 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.


Member Function Documentation

template<class interface_type>
void TSE3::Listener< interface_type >::attachTo notifier_type notifier  )  [inline]
 

Attaches this Listener to notifier.

You can only attach to a 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

template<class interface_type>
void TSE3::Listener< interface_type >::detachFrom notifier_type notifier  )  [inline]
 

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

template<class interface_type>
virtual void TSE3::Listener< interface_type >::Notifier_Deleted c_notifier_type  )  [inline, protected, virtual]
 

This may be implemented by Listener classes if they care about a Notifier object being deleted.

It is called by the 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


Friends And Related Function Documentation

template<class interface_type>
friend class notifier_type [friend]
 


The documentation for this class was generated from the following file:
Generated on Wed May 25 14:46:42 2005 for TSE3 by doxygen 1.3.2