LibreOffice Module comphelper (master)  1
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
comphelper::OListenerContainer Class Referenceabstract

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>

Inheritance diagram for comphelper::OListenerContainer:
[legend]
Collaboration diagram for comphelper::OListenerContainer:
[legend]

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::OInterfaceIteratorHelper2createIterator ()
 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
 

Detailed Description

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.

See also
http://www.openoffice.org/servlets/ReadMsg?list=interface-announce&msgId=494345
OListenerContainerBase

Definition at line 57 of file listenernotification.hxx.

Constructor & Destructor Documentation

comphelper::OListenerContainer::OListenerContainer ( ::osl::Mutex &  _rMutex)
protected

Definition at line 34 of file listenernotification.cxx.

comphelper::OListenerContainer::~OListenerContainer ( )
protectedvirtual

Definition at line 39 of file listenernotification.cxx.

Member Function Documentation

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.

::std::unique_ptr< ::comphelper::OInterfaceIteratorHelper2 > comphelper::OListenerContainer::createIterator ( )
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.

bool comphelper::OListenerContainer::empty ( ) const
inline

determines whether the listener container is currently empty

Definition at line 138 of file listenernotification.hxx.

References comphelper::OInterfaceContainerHelper2::getLength(), and m_aListeners.

void comphelper::OListenerContainer::impl_addListener ( const css::uno::Reference< css::lang::XEventListener > &  _rxListener)
protected
bool comphelper::OListenerContainer::impl_notify ( const css::lang::EventObject &  _rEvent)
protected

notifies all listeners of the given event, using THB's notification pattern

internally, this method will call <member>implNotify</member> for every listener

Returns
<TRUE> if all listeners have been notified, <FALSE> else. The latter can happen if <member>implNotify</member> cancels the notification loop.
See also
implNotify

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().

void comphelper::OListenerContainer::impl_removeListener ( const css::uno::Reference< css::lang::XEventListener > &  _rxListener)
protected
virtual bool comphelper::OListenerContainer::implNotify ( const css::uno::Reference< css::lang::XEventListener > &  _rxListener,
const css::lang::EventObject &  _rEvent 
)
protectedpure virtual

call a single listener

Exceptions
css::uno::Exceptionif 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.
Parameters
_rxListenerspecifies the listener to call. Is guaranteed to not be <NULL>
_rEventthe 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.
Returns
<TRUE> if the remaining listeners should be called, <FALSE> if the notification loop should be cancelled
See also
notify

Implemented in comphelper::OListenerContainerBase< ListenerClass, EventClass >, comphelper::OSimpleListenerContainer< LISTENER, EVENT >, and comphelper::OSimpleListenerContainer< css::beans::XPropertyChangeListener, css::beans::PropertyChangeEvent >.

Referenced by impl_notify().

Member Data Documentation

::comphelper::OInterfaceContainerHelper2 comphelper::OListenerContainer::m_aListeners
private

The documentation for this class was generated from the following files: