13 #ifndef BERRYLISTENERLIST_H
14 #define BERRYLISTENERLIST_H
18 #include <QReadWriteLock>
58 template<
class T,
typename C = ListenerListEquals>
70 void Add(
const T& listener)
76 QWriteLocker l(&mutex);
77 const int oldSize = listeners.size();
78 for (
int i = 0; i < oldSize; ++i)
80 T& listener2 = listeners[i];
81 if (comparator(listener, listener2))
85 listeners.push_back(listener);
102 QReadLocker l(&mutex);
114 QReadLocker l(&mutex);
115 return listeners.empty();
126 QWriteLocker l(&mutex);
129 const int oldSize = listeners.size();
130 for (
int i = 0; i < oldSize; ++i)
132 T& listener2 = listeners[i];
133 if (comparator(listener, listener2))
135 listeners.removeAt(i);
148 QReadLocker l(&mutex);
149 return listeners.size();
157 QWriteLocker l(&mutex);
168 mutable QReadWriteLock mutex;
175 #endif // BERRYLISTENERLIST_H