JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::ChangeBroadcaster Class Reference

Holds a list of ChangeListeners, and sends messages to them when instructed. More...

#include <juce_ChangeBroadcaster.h>

Inheritance diagram for juce::ChangeBroadcaster:
Collaboration diagram for juce::ChangeBroadcaster:

Classes

class  ChangeBroadcasterCallback
 

Public Member Functions

 ChangeBroadcaster () noexcept
 Creates an ChangeBroadcaster. More...
 
virtual ~ChangeBroadcaster ()
 Destructor. More...
 
void addChangeListener (ChangeListener *listener)
 Registers a listener to receive change callbacks from this broadcaster. More...
 
void dispatchPendingMessages ()
 If a change message has been sent but not yet dispatched, this will call sendSynchronousChangeMessage() to make the callback immediately. More...
 
void removeAllChangeListeners ()
 Removes all listeners from the list. More...
 
void removeChangeListener (ChangeListener *listener)
 Unregisters a listener from the list. More...
 
void sendChangeMessage ()
 Causes an asynchronous change message to be sent to all the registered listeners. More...
 
void sendSynchronousChangeMessage ()
 Sends a synchronous change message to all the registered listeners. More...
 

Private Member Functions

void callListeners ()
 

Private Attributes

std::atomic< boolanyListeners { false }
 
ChangeBroadcasterCallback broadcastCallback
 
ListenerList< ChangeListenerchangeListeners
 

Friends

class ChangeBroadcasterCallback
 

Detailed Description

Holds a list of ChangeListeners, and sends messages to them when instructed.

See also
ChangeListener

@tags{Events}

Constructor & Destructor Documentation

◆ ChangeBroadcaster()

juce::ChangeBroadcaster::ChangeBroadcaster ( )
noexcept

Creates an ChangeBroadcaster.

◆ ~ChangeBroadcaster()

virtual juce::ChangeBroadcaster::~ChangeBroadcaster ( )
virtual

Destructor.

Member Function Documentation

◆ addChangeListener()

void juce::ChangeBroadcaster::addChangeListener ( ChangeListener listener)

Registers a listener to receive change callbacks from this broadcaster.

Trying to add a listener that's already on the list will have no effect.

◆ callListeners()

void juce::ChangeBroadcaster::callListeners ( )
private

◆ dispatchPendingMessages()

void juce::ChangeBroadcaster::dispatchPendingMessages ( )

If a change message has been sent but not yet dispatched, this will call sendSynchronousChangeMessage() to make the callback immediately.

For thread-safety reasons, you must only call this method on the main message thread.

◆ removeAllChangeListeners()

void juce::ChangeBroadcaster::removeAllChangeListeners ( )

Removes all listeners from the list.

◆ removeChangeListener()

void juce::ChangeBroadcaster::removeChangeListener ( ChangeListener listener)

Unregisters a listener from the list.

If the listener isn't on the list, this won't have any effect.

◆ sendChangeMessage()

void juce::ChangeBroadcaster::sendChangeMessage ( )

Causes an asynchronous change message to be sent to all the registered listeners.

The message will be delivered asynchronously by the main message thread, so this method will return immediately. To call the listeners synchronously use sendSynchronousChangeMessage().

Referenced by juce::SelectedItemSet< SelectableItemType >::changed().

◆ sendSynchronousChangeMessage()

void juce::ChangeBroadcaster::sendSynchronousChangeMessage ( )

Sends a synchronous change message to all the registered listeners.

This will immediately call all the listeners that are registered. For thread-safety reasons, you must only call this method on the main message thread.

See also
dispatchPendingMessages

Referenced by juce::SelectedItemSet< SelectableItemType >::changed().

Friends And Related Function Documentation

◆ ChangeBroadcasterCallback

friend class ChangeBroadcasterCallback
friend

Member Data Documentation

◆ anyListeners

std::atomic<bool> juce::ChangeBroadcaster::anyListeners { false }
private

◆ broadcastCallback

ChangeBroadcasterCallback juce::ChangeBroadcaster::broadcastCallback
private

◆ changeListeners

ListenerList<ChangeListener> juce::ChangeBroadcaster::changeListeners
private

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