OpenShot Audio Library | OpenShotAudio: juce::ListenerList< ListenerClass, ArrayType > Class Template Reference

OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
juce::ListenerList< ListenerClass, ArrayType > Class Template Reference

`#include <juce_ListenerList.h>`

## Classes
struct | DummyBailOutChecker
struct | Iterator

## Public Types
using | ThisType = ListenerList< ListenerClass, ArrayType >
using | ListenerType = ListenerClass

## Public Member Functions
| ListenerList ()=default
| ~ListenerList ()=default
void | add (ListenerClass *listenerToAdd)
void | remove (ListenerClass *listenerToRemove)
int | size () const noexcept
bool | isEmpty () const noexcept
void | clear ()
bool | contains (ListenerClass *listener) const noexcept
const ArrayType & | getListeners () const noexcept
template<typename Callback >
void | call (Callback &&callback)
template<typename Callback >
void | callExcluding (ListenerClass *listenerToExclude, Callback &&callback)
template<typename Callback , typename BailOutCheckerType >
void | callChecked (const BailOutCheckerType &bailOutChecker, Callback &&callback)
template<typename Callback , typename BailOutCheckerType >
void | callCheckedExcluding (ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, Callback &&callback)
void | call (void(ListenerClass::*callbackFunction)())
void | callExcluding (ListenerClass *listenerToExclude, void(ListenerClass::*callbackFunction)())
template<class BailOutCheckerType >
void | callChecked (const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)())
template<class BailOutCheckerType >
void | callCheckedExcluding (ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)())
template<typename... MethodArgs, typename... Args>
void | call (void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
template<typename... MethodArgs, typename... Args>
void | callExcluding (ListenerClass *listenerToExclude, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
template<typename BailOutCheckerType , typename... MethodArgs, typename... Args>
void | callChecked (const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
template<typename BailOutCheckerType , typename... MethodArgs, typename... Args>
void | callCheckedExcluding (ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)

## Detailed Description

template<class ListenerClass, class ArrayType = Array<ListenerClass*>>
class juce::ListenerList< ListenerClass, ArrayType >

Holds a set of objects and can invoke a member function callback on each object in the set with a single call.

Use a ListenerList to manage a set of objects which need a callback, and you can invoke a member function by simply calling call() or callChecked().

E.g.

class MyListenerType
{
public:
void myCallbackMethod (int foo, bool bar);
};
ListenerList<MyListenerType> listeners;
listeners.add (someCallbackObjects...);
// This will invoke myCallbackMethod (1234, true) on each of the objects
// in the list...
listeners.call ([] (MyListenerType& l) { l.myCallbackMethod (1234, true); });
juce::ListenerList
Definition: juce_ListenerList.h:69
juce::ListenerList::call
void call(Callback &&callback)
Definition: juce_ListenerList.h:119
juce::ListenerList::add
void add(ListenerClass *listenerToAdd)
Definition: juce_ListenerList.h:84

If you add or remove listeners from the list during one of the callbacks - i.e. while it's in the middle of iterating the listeners, then it's guaranteed that no listeners will be mistakenly called after they've been removed, but it may mean that some of the listeners could be called more than once, or not at all, depending on the list's order.

Sometimes, there's a chance that invoking one of the callbacks might result in the list itself being deleted while it's still iterating - to survive this situation, you can use callChecked() instead of call(), passing it a local object to act as a "BailOutChecker". The BailOutChecker must implement a method of the form "bool shouldBailOut()", and the list will check this after each callback to determine whether it should abort the operation. For an example of a bail-out checker, see the Component::BailOutChecker class, which can be used to check when a Component has been deleted. See also ListenerList::DummyBailOutChecker, which is a dummy checker that always returns false.

Definition at line 68 of file juce_ListenerList.h.

## Member Typedef Documentation

## ◆ ListenerType

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

using juce::ListenerList< ListenerClass, ArrayType >::ListenerType = ListenerClass

Definition at line 186 of file juce_ListenerList.h.

## ◆ ThisType

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

using juce::ListenerList< ListenerClass, ArrayType >::ThisType = ListenerList<ListenerClass, ArrayType>

Definition at line 185 of file juce_ListenerList.h.

## Constructor & Destructor Documentation

## ◆ ListenerList()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

juce::ListenerList< ListenerClass, ArrayType >::ListenerList | ( |  | ) |
| default

Creates an empty list.

## ◆ ~ListenerList()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

juce::ListenerList< ListenerClass, ArrayType >::~ListenerList | ( |  | ) |
| default

Destructor.

## Member Function Documentation

## ◆ add()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

void juce::ListenerList< ListenerClass, ArrayType >::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.

See also
  remove

Definition at line 84 of file juce_ListenerList.h.

## ◆ call() [1/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename Callback >

void juce::ListenerList< ListenerClass, ArrayType >::call | ( | Callback && | callback | ) |
| inline

Calls a member function on each listener in the list, with multiple parameters.

Definition at line 119 of file juce_ListenerList.h.

## ◆ call() [2/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

void juce::ListenerList< ListenerClass, ArrayType >::call | ( | void(ListenerClass::*)() | callbackFunction | ) |
| inline

Definition at line 236 of file juce_ListenerList.h.

## ◆ call() [3/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename... MethodArgs, typename... Args>

void juce::ListenerList< ListenerClass, ArrayType >::call | ( | void(ListenerClass::*)(MethodArgs...) | callbackFunction,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 261 of file juce_ListenerList.h.

## ◆ callChecked() [1/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename Callback , typename BailOutCheckerType >

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

Calls a member function on each listener in the list, with 1 parameter and a bail-out-checker. See the class description for info about writing a bail-out checker.

Definition at line 148 of file juce_ListenerList.h.

## ◆ callChecked() [2/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<class BailOutCheckerType >

void juce::ListenerList< ListenerClass, ArrayType >::callChecked | ( | const BailOutCheckerType & | bailOutChecker,
|  | void(ListenerClass::*)() | callbackFunction
| ) |  |
| inline

Definition at line 247 of file juce_ListenerList.h.

## ◆ callChecked() [3/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename BailOutCheckerType , typename... MethodArgs, typename... Args>

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

Definition at line 282 of file juce_ListenerList.h.

## ◆ callCheckedExcluding() [1/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename Callback , typename BailOutCheckerType >

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

Calls a member function, with 1 parameter, on all but the specified listener in the list with a bail-out-checker. This can be useful if the caller is also a listener and needs to exclude itself. See the class description for info about writing a bail-out checker.

Definition at line 161 of file juce_ListenerList.h.

## ◆ callCheckedExcluding() [2/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<class BailOutCheckerType >

void juce::ListenerList< ListenerClass, ArrayType >::callCheckedExcluding | ( | ListenerClass * | listenerToExclude,
|  | const BailOutCheckerType & | bailOutChecker,
|  | void(ListenerClass::*)() | callbackFunction
| ) |  |
| inline

Definition at line 253 of file juce_ListenerList.h.

## ◆ callCheckedExcluding() [3/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename BailOutCheckerType , typename... MethodArgs, typename... Args>

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

Definition at line 293 of file juce_ListenerList.h.

## ◆ callExcluding() [1/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename Callback >

void juce::ListenerList< ListenerClass, ArrayType >::callExcluding | ( | ListenerClass * | listenerToExclude,
|  | Callback && | callback
| ) |  |
| inline

Calls a member function with 1 parameter, on all but the specified listener in the list. This can be useful if the caller is also a listener and needs to exclude itself.

Definition at line 131 of file juce_ListenerList.h.

## ◆ callExcluding() [2/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

void juce::ListenerList< ListenerClass, ArrayType >::callExcluding | ( | ListenerClass * | listenerToExclude,
|  | void(ListenerClass::*)() | callbackFunction
| ) |  |
| inline

Definition at line 241 of file juce_ListenerList.h.

## ◆ callExcluding() [3/3]

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>
template<typename... MethodArgs, typename... Args>

void juce::ListenerList< ListenerClass, ArrayType >::callExcluding | ( | ListenerClass * | listenerToExclude,
|  | void(ListenerClass::*)(MethodArgs...) | callbackFunction,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 270 of file juce_ListenerList.h.

## ◆ clear()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

void juce::ListenerList< ListenerClass, ArrayType >::clear | ( |  | ) |
| inline

Clears the list.

Definition at line 108 of file juce_ListenerList.h.

## ◆ contains()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

bool juce::ListenerList< ListenerClass, ArrayType >::contains | ( | ListenerClass * | listener | ) | const
| inlinenoexcept

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

Definition at line 111 of file juce_ListenerList.h.

## ◆ getListeners()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

const ArrayType & juce::ListenerList< ListenerClass, ArrayType >::getListeners | ( |  | ) | const
| inlinenoexcept

Returns the raw array of listeners.

Definition at line 114 of file juce_ListenerList.h.

## ◆ isEmpty()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

bool juce::ListenerList< ListenerClass, ArrayType >::isEmpty | ( |  | ) | const
| inlinenoexcept

Returns true if no listeners are registered, false otherwise.

Definition at line 105 of file juce_ListenerList.h.

## ◆ remove()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

void juce::ListenerList< ListenerClass, ArrayType >::remove | ( | ListenerClass * | listenerToRemove | ) |
| inline

Removes a listener from the list. If the listener wasn't in the list, this has no effect.

Definition at line 95 of file juce_ListenerList.h.

## ◆ size()

template<class ListenerClass , class ArrayType = Array<ListenerClass*>>

int juce::ListenerList< ListenerClass, ArrayType >::size | ( |  | ) | const
| inlinenoexcept

Returns the number of registered listeners.

Definition at line 102 of file juce_ListenerList.h.

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

- juce_ListenerList.h