A lightweight version of the ListenerList that doesn't provide any guarantees when mutating the list from a callback, but allows callbacks to be triggered concurrently without a mutex. More...
#include <juce_ListenerList.h>


Public Types | |
| using | DummyBailOutChecker = typename ListenerList< ListenerClass >::DummyBailOutChecker |
| A dummy bail-out checker that always returns false. | |
| using | ListenerType = ListenerClass |
| using | ThisType = LightweightListenerList< ListenerClass > |
Public Member Functions | |
| LightweightListenerList ()=default | |
| Creates an empty list. | |
| ~LightweightListenerList () | |
| Destructor. | |
| void | add (ListenerClass *listenerToAdd) |
| Adds a listener to the list. | |
| ErasedScopeGuard | addScoped (ListenerClass &listenerToAdd) |
| Adds a listener that will be automatically removed when the Guard is destroyed. | |
| template<typename Callback > | |
| void | call (Callback &&callback) const |
| Calls an invokable object for each listener in the list. | |
| template<typename... MethodArgs, typename... Args> | |
| void | call (void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args) const |
| Calls a specific listener method for each listener in the list. | |
| template<typename Callback , typename BailOutCheckerType > | |
| void | callChecked (const BailOutCheckerType &bailOutChecker, Callback &&callback) const |
| Calls an invokable object for each listener in the list, additionally checking the bail-out checker before each call. | |
| template<typename BailOutCheckerType , typename... MethodArgs, typename... Args> | |
| void | callChecked (const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args) const |
| Calls a specific listener method for each listener in the list, additionally checking the bail-out checker before each call. | |
| template<typename Callback , typename BailOutCheckerType > | |
| void | callCheckedExcluding (ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, Callback &&callback) const |
| Calls an invokable object for each listener in the list, except for the listener specified by listenerToExclude, additionally checking the bail-out checker before each call. | |
| template<typename BailOutCheckerType , typename... MethodArgs, typename... Args> | |
| void | callCheckedExcluding (ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args) const |
| Calls a specific listener method for each listener in the list, except for the listener specified by listenerToExclude, additionally checking the bail-out checker before each call. | |
| template<typename Callback > | |
| void | callExcluding (ListenerClass *listenerToExclude, Callback &&callback) const |
| Calls an invokable object for each listener in the list, except for the listener specified by listenerToExclude. | |
| template<typename... MethodArgs, typename... Args> | |
| void | callExcluding (ListenerClass *listenerToExclude, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args) const |
| Calls a specific listener method for each listener in the list, except for the listener specified by listenerToExclude. | |
| void | clear () |
| Clears the list. | |
| bool | contains (ListenerClass *listener) const noexcept |
| Returns true if the specified listener has been added to the list. | |
| bool | isEmpty () const noexcept |
| Returns true if no listeners are registered, false otherwise. | |
| void | remove (ListenerClass *listenerToRemove) |
| Removes a listener from the list. | |
| int | size () const noexcept |
| Returns the number of registered listeners. | |
Private Attributes | |
| Array< ListenerClass * > | listeners |
A lightweight version of the ListenerList that doesn't provide any guarantees when mutating the list from a callback, but allows callbacks to be triggered concurrently without a mutex.
@tags{Core}
| using juce::LightweightListenerList< ListenerClass >::DummyBailOutChecker = typename ListenerList<ListenerClass>::DummyBailOutChecker |
A dummy bail-out checker that always returns false.
See the class description for info about writing a bail-out checker.
| using juce::LightweightListenerList< ListenerClass >::ListenerType = ListenerClass |
| using juce::LightweightListenerList< ListenerClass >::ThisType = LightweightListenerList<ListenerClass> |
|
default |
Creates an empty list.
|
inline |
Destructor.
References jassert.
|
inline |
Adds a listener to the list.
A listener can only be added once, so if the listener is already in the list, this method has no effect.
If you need to add a Listener during a callback, use the ListenerList type.
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::addIfNotAlreadyThere(), jassert, jassertfalse, and juce::LightweightListenerList< ListenerClass >::listeners.
Referenced by juce::detail::CallbackListenerList< Args >::addListener(), and juce::LightweightListenerList< ListenerClass >::addScoped().
|
inline |
Adds a listener that will be automatically removed when the Guard is destroyed.
Be very careful to ensure that the ErasedScopeGuard is destroyed or released before the ListenerList is destroyed, otherwise the ErasedScopeGuard may attempt to dereference a dangling pointer when it is destroyed, which will result in a crash.
References juce::LightweightListenerList< ListenerClass >::add(), and juce::LightweightListenerList< ListenerClass >::remove().
|
inline |
Calls an invokable object for each listener in the list.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
Referenced by juce::detail::CallbackListenerList< Args >::call().
|
inline |
Calls a specific listener method for each listener in the list.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
|
inline |
Calls an invokable object for each listener in the list, additionally checking the bail-out checker before each call.
See the class description for info about writing a bail-out checker.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
|
inline |
Calls a specific listener method for each listener in the list, additionally checking the bail-out checker before each call.
See the class description for info about writing a bail-out checker.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
|
inline |
Calls an invokable object for each listener in the list, except for the listener specified by listenerToExclude, additionally checking the bail-out checker before each call.
See the class description for info about writing a bail-out checker.
References juce::LightweightListenerList< ListenerClass >::listeners.
Referenced by juce::LightweightListenerList< ListenerClass >::call(), juce::LightweightListenerList< ListenerClass >::call(), juce::LightweightListenerList< ListenerClass >::callChecked(), juce::LightweightListenerList< ListenerClass >::callChecked(), juce::LightweightListenerList< ListenerClass >::callCheckedExcluding(), juce::LightweightListenerList< ListenerClass >::callExcluding(), and juce::LightweightListenerList< ListenerClass >::callExcluding().
|
inline |
Calls a specific listener method for each listener in the list, except for the listener specified by listenerToExclude, additionally checking the bail-out checker before each call.
See the class description for info about writing a bail-out checker.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
|
inline |
Calls an invokable object for each listener in the list, except for the listener specified by listenerToExclude.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
|
inline |
Calls a specific listener method for each listener in the list, except for the listener specified by listenerToExclude.
References juce::LightweightListenerList< ListenerClass >::callCheckedExcluding().
|
inline |
Clears the list.
If you need to clear the list during a callback, use the ListenerList type.
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::clear(), jassert, and juce::LightweightListenerList< ListenerClass >::listeners.
|
inlinenoexcept |
Returns true if the specified listener has been added to the list.
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::contains(), and juce::LightweightListenerList< ListenerClass >::listeners.
|
inlinenoexcept |
Returns true if no listeners are registered, false otherwise.
References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::isEmpty(), and juce::LightweightListenerList< ListenerClass >::listeners.
|
inline |
Removes a listener from the list.
If the listener wasn't in the list, this has no effect.
If you need to remove a Listener during a callback, use the ListenerList type.
References jassert, juce::LightweightListenerList< ListenerClass >::listeners, and juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::removeFirstMatchingValue().
Referenced by juce::detail::CallbackListenerList< Args >::addListener(), and juce::LightweightListenerList< ListenerClass >::addScoped().
|
inlinenoexcept |
Returns the number of registered listeners.
References juce::LightweightListenerList< ListenerClass >::listeners, and juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::size().
|
private |
Referenced by juce::LightweightListenerList< ListenerClass >::add(), juce::LightweightListenerList< ListenerClass >::callCheckedExcluding(), juce::LightweightListenerList< ListenerClass >::clear(), juce::LightweightListenerList< ListenerClass >::contains(), juce::LightweightListenerList< ListenerClass >::isEmpty(), juce::LightweightListenerList< ListenerClass >::remove(), and juce::LightweightListenerList< ListenerClass >::size().