All Classes Namespaces Functions Variables Enumerations Enumerator Modules Pages
Public Member Functions | List of all members
SafeChangeBroadcaster Class Reference
Inheritance diagram for SafeChangeBroadcaster:
AudioSampleBufferComponent Chain::Handler CustomKeyboardState ModulatorSamplerSound ModulatorSamplerSoundPool Processor ScriptingApi::Content SliderPackData Table

Public Member Functions

void sendSynchronousChangeMessage ()
void addChangeListener (SafeChangeListener *listener)
void removeChangeListener (SafeChangeListener *listener)
void removeAllChangeListeners ()
void sendChangeMessage (const String &=String())
void sendAllocationFreeChangeMessage ()

Detailed Description

A drop in replacement for the ChangeBroadcaster class from JUCE but with weak references.

If you use the normal class and forget to unregister a listener in its destructor, it will crash the application. This class uses a weak reference (but still throws an assertion so you still recognize if something is funky), so it handles this case much more gracefully.

Also you can add a string to your message for debugging purposes (with the JUCE class you have no way of knowing what caused the message if you call it asynchronously.

Member Function Documentation

void addChangeListener ( SafeChangeListener 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.

void removeAllChangeListeners ( )

Removes all listeners from the list.

void removeChangeListener ( SafeChangeListener listener)

Unregisters a listener from the list.

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

void sendAllocationFreeChangeMessage ( )

This will send a message without allocating a message slot.

Use this in the audio thread to prevent malloc calls, but don't overuse this feature.

void sendChangeMessage ( const String &  = String())

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().

void 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.

©2017 HISE. This documentation is autogenerated from the HISE source code using Doxygen.