LibreOffice Module comphelper (master) 1
|
A container of interfaces. More...
#include <interfacecontainer3.hxx>
Classes | |
class | NotifySingleListener |
Public Member Functions | |
OInterfaceContainerHelper3 (::osl::Mutex &rMutex_) | |
Create an interface container. More... | |
sal_Int32 | getLength () const |
Return the number of Elements in the container. More... | |
std::vector< css::uno::Reference< ListenerT > > | getElements () const |
Return all interfaces added to this container. More... | |
sal_Int32 | addInterface (const css::uno::Reference< ListenerT > &rxIFace) |
Inserts an element into the container. More... | |
sal_Int32 | removeInterface (const css::uno::Reference< ListenerT > &rxIFace) |
Removes an element from the container. More... | |
const css::uno::Reference< ListenerT > & | getInterface (sal_Int32 nIndex) const |
Return an interface by index. More... | |
void | disposeAndClear (const css::lang::EventObject &rEvt) |
Call disposing on all object in the container that support XEventListener. More... | |
void | clear () |
Clears the container without calling disposing(). More... | |
template<typename FuncT > | |
void | forEach (FuncT const &func) |
Executes a functor for each contained listener of specified type, e.g. More... | |
template<typename EventT > | |
void | notifyEach (void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) |
Calls a UNO listener method for each contained listener. More... | |
Private Member Functions | |
OInterfaceContainerHelper3 (const OInterfaceContainerHelper3 &)=delete | |
OInterfaceContainerHelper3 & | operator= (const OInterfaceContainerHelper3 &)=delete |
Static Private Member Functions | |
static o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > & | DEFAULT () |
Private Attributes | |
o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > | maData |
::osl::Mutex & | mrMutex |
Friends | |
class | OInterfaceIteratorHelper3< ListenerT > |
A container of interfaces.
To access the elements use an iterator. This implementation is thread-safe.
This is a copy of the code at include/comphelper/interfacecontainer2.hxx, except that it is templatized on the type of the listener, which allows some parts of the code to avoid doing an UNO_QUERY that can be expensive in bulk.
ListenerT | UNO event listener type |
Definition at line 119 of file interfacecontainer3.hxx.
|
inline |
Create an interface container.
rMutex | the mutex to protect multi thread access. The lifetime must be longer than the lifetime of this object. |
Definition at line 258 of file interfacecontainer3.hxx.
References DEFAULT.
|
privatedelete |
sal_Int32 comphelper::OInterfaceContainerHelper3< ListenerT >::addInterface | ( | const css::uno::Reference< ListenerT > & | rxIFace | ) |
Inserts an element into the container.
The position is not specified, thus it is not specified in which order events are fired.
rxIFace | interface to be added; it is allowed to insert the same interface more than once |
Definition at line 310 of file interfacecontainer3.hxx.
References maData.
Referenced by comphelper::OPropertyBag::addModifyListener().
void comphelper::OInterfaceContainerHelper3< ListenerT >::clear |
Clears the container without calling disposing().
Definition at line 372 of file interfacecontainer3.hxx.
References maData.
|
inlinestaticprivate |
Definition at line 227 of file interfacecontainer3.hxx.
void comphelper::OInterfaceContainerHelper3< ListenerT >::disposeAndClear | ( | const css::lang::EventObject & | rEvt | ) |
Call disposing on all object in the container that support XEventListener.
Then clear the container.
Definition at line 352 of file interfacecontainer3.hxx.
References comphelper::OInterfaceIteratorHelper3< ListenerT >::hasMoreElements(), maData, and comphelper::OInterfaceIteratorHelper3< ListenerT >::next().
|
inline |
Executes a functor for each contained listener of specified type, e.g.
forEach<awt::XPaintListener>(...
.
If a css::lang::DisposedException occurs which relates to the called listener, then that listener is removed from the container.
FuncT | unary functor type, let your compiler deduce this for you |
func | unary functor object expecting an argument of type css::uno::Reference<ListenerT> |
Definition at line 266 of file interfacecontainer3.hxx.
References comphelper::OInterfaceIteratorHelper3< ListenerT >::hasMoreElements(), comphelper::OInterfaceIteratorHelper3< ListenerT >::next(), and comphelper::OInterfaceIteratorHelper3< ListenerT >::remove().
std::vector< css::uno::Reference< ListenerT > > comphelper::OInterfaceContainerHelper3< ListenerT >::getElements |
Return all interfaces added to this container.
Definition at line 300 of file interfacecontainer3.hxx.
References maData.
const css::uno::Reference< ListenerT > & comphelper::OInterfaceContainerHelper3< ListenerT >::getInterface | ( | sal_Int32 | nIndex | ) | const |
Return an interface by index.
Definition at line 344 of file interfacecontainer3.hxx.
sal_Int32 comphelper::OInterfaceContainerHelper3< ListenerT >::getLength |
Return the number of Elements in the container.
Only useful if you have acquired the mutex.
Definition at line 292 of file interfacecontainer3.hxx.
References maData.
|
inline |
Calls a UNO listener method for each contained listener.
The listener method must take a single argument of type EventT, and return void
.
If a css::lang::DisposedException occurs which relates to the called listener, then that listener is removed from the container.
EventT | event type, let your compiler deduce this for you |
NotificationMethod | Pointer to a method of a ListenerT interface. |
Event | Event to notify to all contained listeners |
Example:
Definition at line 286 of file interfacecontainer3.hxx.
Referenced by comphelper::OPropertyBag::setModifiedImpl().
|
privatedelete |
sal_Int32 comphelper::OInterfaceContainerHelper3< ListenerT >::removeInterface | ( | const css::uno::Reference< ListenerT > & | rxIFace | ) |
Removes an element from the container.
It uses interface equality to remove the interface.
rxIFace | interface to be removed |
Definition at line 320 of file interfacecontainer3.hxx.
References find(), and maData.
Referenced by comphelper::OPropertyBag::removeModifyListener().
|
friend |
Definition at line 213 of file interfacecontainer3.hxx.
|
private |
Definition at line 220 of file interfacecontainer3.hxx.
|
private |
Definition at line 221 of file interfacecontainer3.hxx.