|
| | ListenerList ()=default |
| | ~ListenerList () |
| 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) |
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);
};
listeners.
add (someCallbackObjects...);
listeners.
call ([] (MyListenerType&
l) {
l.myCallbackMethod (1234,
true); });
Definition juce_ListenerList.h:70
void call(Callback &&callback)
Definition juce_ListenerList.h:135
void add(ListenerClass *listenerToAdd)
Definition juce_ListenerList.h:91
int * l
Definition inflate.c:1579
It is guaranteed that every Listener is called during an iteration if it's inside the ListenerList before the iteration starts and isn't removed until its end. This guarantee holds even if some Listeners are removed or new ones are added during the iteration.
Listeners added during an iteration are guaranteed to be not called in that iteration.
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.
@tags{Core}