JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::CallbackMessage Class Referenceabstract

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

#include <juce_CallbackMessage.h>

Inheritance diagram for juce::CallbackMessage:
Collaboration diagram for juce::CallbackMessage:

Public Types

using Ptr = ReferenceCountedObjectPtr< MessageBase >
 

Public Member Functions

 CallbackMessage () noexcept
 
 ~CallbackMessage ()
 Destructor. 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...
 
void incReferenceCount () noexcept
 Increments the object's reference count. More...
 
virtual void messageCallback ()=0
 Called when the message is delivered. More...
 
bool post ()
 

Protected Member Functions

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

{Events}

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ CallbackMessage()

juce::CallbackMessage::CallbackMessage ( )
inlinenoexcept

◆ ~CallbackMessage()

juce::CallbackMessage::~CallbackMessage ( )
inline

Destructor.

References JUCE_DECLARE_NON_COPYABLE.

Member Function Documentation

◆ decReferenceCount()

void juce::ReferenceCountedObject::decReferenceCount ( )
inlinenoexceptinherited

Decreases the object's reference count.

If the count gets to zero, the object will be deleted.

References jassert.

◆ decReferenceCountWithoutDeleting()

bool juce::ReferenceCountedObject::decReferenceCountWithoutDeleting ( )
inlinenoexceptinherited

Decreases the object's reference count.

If the count gets to zero, the object will not be deleted, but this method will return true, allowing the caller to take care of deletion.

References jassert.

◆ getReferenceCount()

int juce::ReferenceCountedObject::getReferenceCount ( ) const
inlinenoexceptinherited

Returns the object's current reference count.

◆ incReferenceCount()

void juce::ReferenceCountedObject::incReferenceCount ( )
inlinenoexceptinherited

Increments the object's reference count.

This is done automatically by the smart pointer, but is public just in case it's needed for nefarious purposes.

◆ messageCallback()

virtual void juce::CallbackMessage::messageCallback ( )
pure 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 juce::MessageManager::MessageBase.

◆ post()

bool juce::MessageManager::MessageBase::post ( )
inherited

◆ resetReferenceCount()

void juce::ReferenceCountedObject::resetReferenceCount ( )
inlineprotectednoexceptinherited

Resets the reference count to zero without deleting the object.

You should probably never need to use this!


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