JUCE
Public Member Functions | List of all members
CallbackMessage Class Referenceabstract

A message that invokes a callback method when it gets delivered. More...

Inheritance diagram for CallbackMessage:

Public Member Functions

 CallbackMessage ()=default
 
 ~CallbackMessage () override=default
 Destructor. More...
 
virtual void messageCallback () override=0
 Called when the message is delivered. More...
 
- Public Member Functions inherited from MessageManager::MessageBase
 MessageBase ()=default
 
 ~MessageBase () override=default
 
bool post ()
 
- Public Member Functions inherited from ReferenceCountedObject
void incReferenceCount () noexcept
 Increments the object's reference count. More...
 
void decReferenceCount () noexcept
 Decreases the object's reference count. More...
 
bool decReferenceCountWithoutDeleting () noexcept
 Decreases the object's reference count. More...
 
int getReferenceCount () const noexcept
 Returns the object's current reference count. More...
 

Additional Inherited Members

- Public Types inherited from MessageManager::MessageBase
using Ptr = ReferenceCountedObjectPtr< MessageBase >
 
- Protected Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject ()=default
 Creates the reference-counted object (with an initial ref count of zero). More...
 
 ReferenceCountedObject (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
 ReferenceCountedObject (ReferenceCountedObject &&) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&) noexcept
 Copying from another object does not affect this one's reference-count. More...
 
virtual ~ReferenceCountedObject ()
 Destructor. More...
 
void resetReferenceCount () noexcept
 Resets the reference count to zero without deleting the object. More...
 

Detailed Description

A message that invokes a callback method when it gets delivered.

You can use this class to fire off actions that you want to be performed later on the message thread.

To use it, create a subclass of CallbackMessage which implements the messageCallback() method, then call post() to dispatch it. The event thread will then invoke your messageCallback() method later on, and will automatically delete the message object afterwards.

Always create a new instance of a CallbackMessage on the heap, as it will be deleted automatically after the message has been delivered.

Note that this class was essential back in the days before C++11, but in modern times you may prefer to use MessageManager::callAsync() with a lambda.

See also
MessageManager::callAsync, MessageListener, ActionListener, ChangeListener

Constructor & Destructor Documentation

◆ CallbackMessage()

CallbackMessage::CallbackMessage ( )
default

◆ ~CallbackMessage()

CallbackMessage::~CallbackMessage ( )
overridedefault

Destructor.

Member Function Documentation

◆ messageCallback()

virtual void CallbackMessage::messageCallback ( )
overridepure virtual

Called when the message is delivered.

You should implement this method and make it do whatever action you want to perform.

Note that like all other messages, this object will be deleted immediately after this method has been invoked.

Implements MessageManager::MessageBase.


The documentation for this class was generated from the following file: