Loading...
Searching...
No Matches
juce::LightweightListenerList< ListenerClass > Class Template Reference

## Detailed Description

template<typename ListenerClass>
class juce::LightweightListenerList< ListenerClass >

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.

See also
  ListenerList, ThreadSafeListenerList

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

- juce_core/containers/juce_ListenerList.h

## Public Types

using | DummyBailOutChecker = typename ListenerList<ListenerClass>::DummyBailOutChecker
| A dummy bail-out checker that always returns false.
using | ThisType = LightweightListenerList<ListenerClass>
using | ListenerType = ListenerClass

## Public Member Functions

| LightweightListenerList ()=default
| Creates an empty list.
| ~LightweightListenerList ()
| Destructor.
void | add (ListenerClass *listenerToAdd)
| Adds a listener to the list.
void | remove (ListenerClass *listenerToRemove)
| Removes a listener from the list.
ErasedScopeGuard | addScoped (ListenerClass &listenerToAdd)
| Adds a listener that will be automatically removed when the Guard is destroyed.
int | size () const noexcept
| Returns the number of registered listeners.
bool | isEmpty () const noexcept
| Returns true if no listeners are registered, false otherwise.
void | clear ()
| Clears the list.
bool | contains (ListenerClass *listener) const noexcept
| Returns true if the specified listener has been added to the list.
template<typename Callback>
void | call (Callback &&callback) const
| Calls an invokable object for each listener in the list.
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 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 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... 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... 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.
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 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.

## Member Typedef Documentation

## DummyBailOutChecker

template<typename ListenerClass>

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.

## ThisType

template<typename ListenerClass>

using juce::LightweightListenerList< ListenerClass >::ThisType = LightweightListenerList<ListenerClass>

## ListenerType

template<typename ListenerClass>

using juce::LightweightListenerList< ListenerClass >::ListenerType = ListenerClass

## Constructors and Destructors

## LightweightListenerList()

template<typename ListenerClass>

juce::LightweightListenerList< ListenerClass >::LightweightListenerList | ( |  | ) |

default

Creates an empty list.

## ~LightweightListenerList()

template<typename ListenerClass>

juce::LightweightListenerList< ListenerClass >::~LightweightListenerList | ( |  | ) |

inline

Destructor.

References jassert.

## Member Functions

## add()

template<typename ListenerClass>

void juce::LightweightListenerList< ListenerClass >::add | ( | ListenerClass * | listenerToAdd | ) |

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.

See also
  remove

References jassert, and jassertfalse.

Referenced by addScoped().

## remove()

template<typename ListenerClass>

void juce::LightweightListenerList< ListenerClass >::remove | ( | ListenerClass * | listenerToRemove | ) |

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.

Referenced by addScoped().

## addScoped()

template<typename ListenerClass>

ErasedScopeGuard juce::LightweightListenerList< ListenerClass >::addScoped | ( | ListenerClass & | listenerToAdd | ) |

inline nodiscard

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 add(), and remove().

## size()

template<typename ListenerClass>

int juce::LightweightListenerList< ListenerClass >::size | ( |  | ) | const

inline nodiscard noexcept

Returns the number of registered listeners.

## isEmpty()

template<typename ListenerClass>

bool juce::LightweightListenerList< ListenerClass >::isEmpty | ( |  | ) | const

inline nodiscard noexcept

Returns true if no listeners are registered, false otherwise.

## clear()

template<typename ListenerClass>

void juce::LightweightListenerList< ListenerClass >::clear | ( |  | ) |

inline

Clears the list.

If you need to clear the list during a callback, use the ListenerList type.

References jassert.

## contains()

template<typename ListenerClass>

bool juce::LightweightListenerList< ListenerClass >::contains | ( | ListenerClass * | listener | ) | const

inline nodiscard noexcept

Returns true if the specified listener has been added to the list.

## call() [1/2]

template<typename ListenerClass>
template<typename Callback>

void juce::LightweightListenerList< ListenerClass >::call | ( | Callback && | callback | ) | const

inline

Calls an invokable object for each listener in the list.

References callCheckedExcluding().

## callExcluding() [1/2]

template<typename ListenerClass>
template<typename Callback>

void juce::LightweightListenerList< ListenerClass >::callExcluding | ( | ListenerClass * | listenerToExclude,
|  | Callback && | callback ) const

inline

Calls an invokable object for each listener in the list, except for the listener specified by listenerToExclude.

References callCheckedExcluding().

## callChecked() [1/2]

template<typename ListenerClass>
template<typename Callback, typename BailOutCheckerType>

void juce::LightweightListenerList< ListenerClass >::callChecked | ( | const BailOutCheckerType & | bailOutChecker,
|  | Callback && | callback ) const

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

## callCheckedExcluding() [1/2]

template<typename ListenerClass>
template<typename Callback, typename BailOutCheckerType>

void juce::LightweightListenerList< ListenerClass >::callCheckedExcluding | ( | ListenerClass * | listenerToExclude,
|  | const BailOutCheckerType & | bailOutChecker,
|  | Callback && | callback ) const

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.

Referenced by call(), call(), callChecked(), callChecked(), callCheckedExcluding(), callExcluding(), and callExcluding().

## call() [2/2]

template<typename ListenerClass>
template<typename... MethodArgs, typename... Args>

void juce::LightweightListenerList< ListenerClass >::call | ( | void(ListenerClass::* | callbackFunction )(MethodArgs...),
|  | Args &&... | args ) const

inline

Calls a specific listener method for each listener in the list.

References callCheckedExcluding().

## callExcluding() [2/2]

template<typename ListenerClass>
template<typename... MethodArgs, typename... Args>

void juce::LightweightListenerList< ListenerClass >::callExcluding | ( | ListenerClass * | listenerToExclude,
|  | void(ListenerClass::* | callbackFunction )(MethodArgs...),
|  | Args &&... | args ) const

inline

Calls a specific listener method for each listener in the list, except for the listener specified by listenerToExclude.

References callCheckedExcluding().

## callChecked() [2/2]

template<typename ListenerClass>
template<typename BailOutCheckerType, typename... MethodArgs, typename... Args>

void juce::LightweightListenerList< ListenerClass >::callChecked | ( | const BailOutCheckerType & | bailOutChecker,
|  | void(ListenerClass::* | callbackFunction )(MethodArgs...),
|  | Args &&... | args ) const

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

## callCheckedExcluding() [2/2]

template<typename ListenerClass>
template<typename BailOutCheckerType, typename... MethodArgs, typename... Args>

void juce::LightweightListenerList< ListenerClass >::callCheckedExcluding | ( | ListenerClass * | listenerToExclude,
|  | const BailOutCheckerType & | bailOutChecker,
|  | void(ListenerClass::* | callbackFunction )(MethodArgs...),
|  | Args &&... | args ) const

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

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited