class Listener

Listener interface for Notifier events. More...

Full nameTSE3::Listener
Definition#include <Notifier.h>
Template formListener<class interface_type>
Inheritsinterface_type (unknown) [public ]
Inherited byMixer, Part, Part, Part, Part, Phrase, PhraseList, Song, Track, Track, Transport, Transport, Transport, Transport, Transport
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Members

Protected Types

Protected Methods


Detailed Description

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


     class Voyeur : public Listener
     {
         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 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.

See also: Notifier

typedef Notifier notifier_type

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:
notifierThe 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:
notifierThe 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:
notifierThe 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.