MessageListener subclasses can post and receive Message objects. More...
Inherited by ActionBroadcaster::CallbackReceiver, ApplicationCommandTarget::CommandTargetMessageInvoker, and InterprocessConnection [private].
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 noexcept |
| Sends a message to the message queue, for asynchronous delivery to this listener later on. | |
| bool | isValidMessageListener () const noexcept |
| Checks whether this MessageListener has been deleted. | |
Protected Member Functions | |
| MessageListener () noexcept | |
| Creates a MessageListener. | |
MessageListener subclasses can post and receive Message objects.
| MessageListener::MessageListener | ( | ) | [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.
| 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.
| void MessageListener::postMessage | ( | Message * | message ) | const |
Sends a message to the message queue, for asynchronous delivery to this listener later on.
This method can be called safely by any thread.
| 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. |
| bool MessageListener::isValidMessageListener | ( | ) | const |
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.