78template <
class ListenerClass,
79 class ArrayType = Array<ListenerClass*>>
118 const ScopedLockType lock (listeners->getLock());
120 if (
const auto index = listeners->removeFirstMatchingValue (
listenerToRemove); index >= 0)
122 for (
auto*
it : *iterators)
157 const ScopedLockType lock (listeners->getLock());
161 for (
auto*
it : *iterators)
181 template <
typename Callback>
182 void call (Callback&& callback)
186 std::forward<Callback> (callback));
192 template <
typename Callback>
197 std::forward<Callback> (callback));
206 template <
typename Callback,
typename BailOutCheckerType>
211 std::forward<Callback> (callback));
220 template <
typename Callback,
typename BailOutCheckerType>
231 iterators->push_back (&
it);
235 i->erase (std::remove (i->begin(), i->end(), &
it), i->end());
238 for (;
it.index <
it.end; ++
it.index)
248 callback (*listener);
254 template <
typename...
MethodArgs,
typename... Args>
260 std::forward<Args> (
args)...);
266 template <
typename...
MethodArgs,
typename... Args>
274 std::forward<Args> (
args)...);
290 std::forward<Args> (
args)...);
317 constexpr bool shouldBailOut()
const noexcept {
return false; }
326 using ScopedLockType =
typename ArrayType::ScopedLockType;
329 using SharedListeners = std::shared_ptr<ArrayType>;
330 const SharedListeners listeners = std::make_shared<ArrayType>();
338 using SafeIterators = std::vector<Iterator*>;
339 using SharedIterators = std::shared_ptr<SafeIterators>;
340 const SharedIterators iterators = std::make_shared<SafeIterators>();
void callChecked(const BailOutCheckerType &bailOutChecker, Callback &&callback)
bool isEmpty() const noexcept
void callCheckedExcluding(ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, Callback &&callback)
void callChecked(const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
void call(Callback &&callback)
void callExcluding(ListenerClass *listenerToExclude, Callback &&callback)
void callCheckedExcluding(ListenerClass *listenerToExclude, const BailOutCheckerType &bailOutChecker, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
void call(void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
void add(ListenerClass *listenerToAdd)
ErasedScopeGuard addScoped(ListenerClass &listenerToAdd)
void remove(ListenerClass *listenerToRemove)
bool contains(ListenerClass *listener) const noexcept
int size() const noexcept
void callExcluding(ListenerClass *listenerToExclude, void(ListenerClass::*callbackFunction)(MethodArgs...), Args &&... args)
const ArrayType & getListeners() const noexcept