Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
#include <berryListenerList.h>
Public Member Functions | |
void | Add (const T &listener) |
QList< T > | GetListeners () const |
bool | IsEmpty () const |
void | Remove (const T &listener) |
int | Size () const |
void | Clear () |
This class is a thread safe list that is designed for storing lists of listeners. The implementation is optimized for minimal memory footprint, frequent reads and infrequent writes. Modification of the list is synchronized and relatively expensive, while accessing the listeners is very fast. Readers are given access to the underlying array data structure for reading, with the trust that they will not modify the underlying array.
A listener list handles the same listener being added multiple times, and tolerates removal of listeners that are the same as other listeners in the list. For this purpose, listeners can be compared with each other using a custom comparison functor.
Use the GetListeners
method when notifying listeners. The recommended code sequence for notifying all registered listeners of say, FooListener::EventHappened()
, is:
Definition at line 63 of file berryListenerList.h.
|
inline |
Adds a listener to this list. This method has no effect if the same listener is already registered.
listener | the non-null listener to add |
Definition at line 74 of file berryListenerList.h.
|
inline |
Removes all listeners from this list.
Definition at line 159 of file berryListenerList.h.
|
inline |
Returns an array containing all the registered listeners. The resulting array is unaffected by subsequent adds or removes. If there are no listeners registered, the result is an empty array. Use this method when notifying listeners, so that any modifications to the listener list during the notification will have no effect on the notification itself.
Definition at line 104 of file berryListenerList.h.
|
inline |
Returns whether this listener list is empty.
true
if there are no registered listeners, and false
otherwise Definition at line 116 of file berryListenerList.h.
|
inline |
Removes a listener from this list. Has no effect if the same listener was not already registered.
listener | the listener to remove |
Definition at line 128 of file berryListenerList.h.
|
inline |
Returns the number of registered listeners.
Definition at line 150 of file berryListenerList.h.