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... | |
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 |
Private Attributes | |
o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > > > | maData |
::osl::Mutex & | rMutex |
Friends | |
class | OInterfaceIteratorHelper3< ListenerT > |
A container of interfaces.
To access the elements use an iterator. This implementation is thread safe.
ListenerT | UNO event listener type |
Definition at line 41 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 124 of file interfacecontainer3.hxx.
|
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.
If you add the same interface more than once, then it will be added to the elements list more than once and thus if you want to remove that interface from the list, you have to call removeInterface() the same number of times. In the latter case, you will also get events fired more than once (if the interface is a listener interface).
rxIFace | interface to be added; it is allowed to the same interface more than once |
Definition at line 285 of file interfacecontainer3.hxx.
void comphelper::OInterfaceContainerHelper3< ListenerT >::clear | ( | ) |
Clears the container without calling disposing().
Definition at line 338 of file interfacecontainer3.hxx.
References maData.
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 318 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 241 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 | ( | ) | const |
Return all interfaces added to this container.
Definition at line 275 of file interfacecontainer3.hxx.
References maData.
sal_Int32 comphelper::OInterfaceContainerHelper3< ListenerT >::getLength | ( | ) | const |
Return the number of Elements in the container.
Only useful if you have acquired the mutex.
Definition at line 267 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 261 of file interfacecontainer3.hxx.
|
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 295 of file interfacecontainer3.hxx.
|
friend |
Definition at line 211 of file interfacecontainer3.hxx.
|
private |
Definition at line 212 of file interfacecontainer3.hxx.
|
private |
Definition at line 213 of file interfacecontainer3.hxx.