MessageListener Class Reference

MessageListener subclasses can post and receive Message objects. More...

Inherited by ActionListenerList, ApplicationCommandTarget::CommandTargetMessageInvoker, AsyncUpdater::AsyncUpdaterInternal, ChangeListenerList, Component [protected], and InterprocessConnection [private].

List of all members.

Public Member Functions

virtual ~MessageListener ()
 Destructor.
virtual void handleMessage (const Message &message)=0
 This is the callback method that receives incoming messages.
void postMessage (Message *message) const throw ()
 Sends a message to the message queue, for asynchronous delivery to this listener later on.
bool isValidMessageListener () const throw ()
 Checks whether this MessageListener has been deleted.

Protected Member Functions

 MessageListener () throw ()
 Creates a MessageListener.

Detailed Description

MessageListener subclasses can post and receive Message objects.

See also:
Message, MessageManager, ActionListener, ChangeListener

Constructor & Destructor Documentation

MessageListener::MessageListener (  )  throw () [protected]

Creates a MessageListener.

virtual MessageListener::~MessageListener (  )  [virtual]

Destructor.

When a MessageListener is deleted, it removes itself from a global list of registered listeners, so that the isValidMessageListener() method will no longer return true.


Member Function Documentation

virtual void MessageListener::handleMessage ( const Message message  )  [pure virtual]

This is the callback method that receives incoming messages.

This is called by the MessageManager from its dispatch loop.

See also:
postMessage

Implemented in ActionListenerList, ChangeListenerList, and Component.

void MessageListener::postMessage ( Message message  )  const throw ()

Sends a message to the message queue, for asynchronous delivery to this listener later on.

This method can be called safely by any thread.

Parameters:
message the message object to send - this will be deleted automatically by the message queue, so don't keep any references to it after calling this method.
See also:
handleMessage
bool MessageListener::isValidMessageListener (  )  const throw ()

Checks whether this MessageListener has been deleted.

Although not foolproof, this method is safe to call on dangling or null pointers. A list of active MessageListeners is kept internally, so this checks whether the object is on this list or not.

Note that it's possible to get a false-positive here, if an object is deleted and another is subsequently created that happens to be at the exact same memory location, but I can't think of a good way of avoiding this.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:13 2010 for JUCE by  doxygen 1.6.3