LibreOffice Module comphelper (master)
1
|
abstract base class which manages a listener container, including THB's listener notification pattern which cares for removing listeners which throw a DisposedException upon notification More...
#include <listenernotification.hxx>
Public Member Functions | |
void | disposing (const css::lang::EventObject &_rEventSource) |
sends a XEventObject::disposing notification to all listeners, and clears the listener container More... | |
void | clear () |
clears the container without calling <member scope="css::lang">XEventListener::disposing</member> at the listeners More... | |
bool | empty () const |
determines whether the listener container is currently empty More... | |
::std::unique_ptr< ::comphelper::OInterfaceIteratorHelper2 > | createIterator () |
creates an iterator for looping through all registered listeners More... | |
Protected Member Functions | |
OListenerContainer (::osl::Mutex &_rMutex) | |
virtual | ~OListenerContainer () |
void | impl_addListener (const css::uno::Reference< css::lang::XEventListener > &_rxListener) |
void | impl_removeListener (const css::uno::Reference< css::lang::XEventListener > &_rxListener) |
bool | impl_notify (const css::lang::EventObject &_rEvent) |
notifies all listeners of the given event, using THB's notification pattern More... | |
virtual bool | implNotify (const css::uno::Reference< css::lang::XEventListener > &_rxListener, const css::lang::EventObject &_rEvent)=0 |
call a single listener More... | |
Private Attributes | |
::comphelper::OInterfaceContainerHelper2 | m_aListeners |
abstract base class which manages a listener container, including THB's listener notification pattern which cares for removing listeners which throw a DisposedException upon notification
Using this class is pretty easy:
See OListenerContainerBase for an implementation which even saves you some more work, by doing the casts for you.
Definition at line 57 of file listenernotification.hxx.
|
protected |
Definition at line 34 of file listenernotification.cxx.
References m_aListeners.
|
protectedvirtual |
Definition at line 39 of file listenernotification.cxx.
void comphelper::OListenerContainer::clear | ( | ) |
clears the container without calling <member scope="css::lang">XEventListener::disposing</member> at the listeners
Definition at line 71 of file listenernotification.cxx.
References comphelper::OInterfaceContainerHelper2::clear(), and m_aListeners.
|
inline |
creates an iterator for looping through all registered listeners
Definition at line 82 of file listenernotification.hxx.
void comphelper::OListenerContainer::disposing | ( | const css::lang::EventObject & | _rEventSource | ) |
sends a XEventObject::disposing notification to all listeners, and clears the listener container
You'll usually call this from within your own dispose/disposing method
Definition at line 65 of file listenernotification.cxx.
References comphelper::OInterfaceContainerHelper2::disposeAndClear(), and m_aListeners.
|
inline |
determines whether the listener container is currently empty
Definition at line 138 of file listenernotification.hxx.
References comphelper::OInterfaceContainerHelper2::getLength(), and m_aListeners.
|
protected |
Definition at line 42 of file listenernotification.cxx.
References comphelper::OInterfaceContainerHelper2::addInterface(), and m_aListeners.
Referenced by comphelper::OSimpleListenerContainer< css::beans::XPropertyChangeListener, css::beans::PropertyChangeEvent >::addListener(), and comphelper::OListenerContainerBase< ListenerClass, EventClass >::addTypedListener().
|
protected |
notifies all listeners of the given event, using THB's notification pattern
internally, this method will call <member>implNotify</member> for every listener
Definition at line 77 of file listenernotification.cxx.
References comphelper::OInterfaceIteratorHelper2::hasMoreElements(), implNotify(), m_aListeners, comphelper::OInterfaceIteratorHelper2::next(), and comphelper::OInterfaceIteratorHelper2::remove().
Referenced by comphelper::OSimpleListenerContainer< LISTENER, EVENT >::notify(), and comphelper::OListenerContainerBase< ListenerClass, EventClass >::notify().
|
protected |
Definition at line 50 of file listenernotification.cxx.
References comphelper::OInterfaceIteratorHelper2::hasMoreElements(), m_aListeners, comphelper::OInterfaceIteratorHelper2::next(), and comphelper::OInterfaceContainerHelper2::removeInterface().
Referenced by comphelper::OSimpleListenerContainer< css::beans::XPropertyChangeListener, css::beans::PropertyChangeEvent >::removeListener(), and comphelper::OListenerContainerBase< ListenerClass, EventClass >::removeTypedListener().
|
protectedpure virtual |
call a single listener
css::uno::Exception | if the listener throws an exception during notification. Please don't catch any listener exceptions in your implementation of this method, simply let them pass to the caller. |
_rxListener | specifies the listener to call. Is guaranteed to not be <NULL> |
_rEvent | the event to broadcast. This is the same as passed to <member>notify</member>, so if your base class knows the type passed into <member>notify</member>, it can safely assume that <arg>_rEvent</arg> is also of this type. |
Implemented in comphelper::OListenerContainerBase< ListenerClass, EventClass >, comphelper::OSimpleListenerContainer< LISTENER, EVENT >, and comphelper::OSimpleListenerContainer< css::beans::XPropertyChangeListener, css::beans::PropertyChangeEvent >.
Referenced by impl_notify().
|
private |
Definition at line 60 of file listenernotification.hxx.
Referenced by clear(), disposing(), empty(), impl_addListener(), impl_notify(), and impl_removeListener().