17 #ifndef BERRYLISTENERLIST_H
18 #define BERRYLISTENERLIST_H
22 #include <QReadWriteLock>
62 template<
class T,
typename C = ListenerListEquals>
74 void Add(
const T& listener)
80 QWriteLocker l(&mutex);
81 const int oldSize = listeners.size();
82 for (
int i = 0; i < oldSize; ++i)
84 T& listener2 = listeners[i];
85 if (comparator(listener, listener2))
89 listeners.push_back(listener);
106 QReadLocker l(&mutex);
118 QReadLocker l(&mutex);
119 return listeners.empty();
130 QWriteLocker l(&mutex);
133 const int oldSize = listeners.size();
134 for (
int i = 0; i < oldSize; ++i)
136 T& listener2 = listeners[i];
137 if (comparator(listener, listener2))
139 listeners.removeAt(i);
152 QReadLocker l(&mutex);
153 return listeners.size();
161 QWriteLocker l(&mutex);
172 mutable QReadWriteLock mutex;
179 #endif // BERRYLISTENERLIST_H
QList< T > GetListeners() const
bool operator()(const T &l1, const T &l2) const
void Add(const T &listener)
void Remove(const T &listener)