LibreOffice Module comphelper (master) 1
|
A container of interfaces. More...
#include <interfacecontainer4.hxx>
Classes | |
class | NotifySingleListener |
Public Member Functions | |
OInterfaceContainerHelper4 () | |
sal_Int32 | getLength (std::unique_lock< std::mutex > &rGuard) const |
Return the number of Elements in the container. More... | |
std::vector< css::uno::Reference< ListenerT > > | getElements (std::unique_lock< std::mutex > &rGuard) const |
Return all interfaces added to this container. More... | |
sal_Int32 | addInterface (std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace) |
Inserts an element into the container. More... | |
sal_Int32 | removeInterface (std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace) |
Removes an element from the container. More... | |
void | disposeAndClear (::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt) |
Call disposing on all object in the container that support XEventListener. More... | |
void | clear (::std::unique_lock<::std::mutex > &rGuard) |
Clears the container without calling disposing(). More... | |
template<typename FuncT > | |
void | forEach (std::unique_lock< std::mutex > &rGuard, FuncT const &func) |
Executes a functor for each contained listener of specified type, e.g. More... | |
template<typename EventT > | |
void | notifyEach (std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) |
Calls a UNO listener method for each contained listener. More... | |
Private Member Functions | |
OInterfaceContainerHelper4 (const OInterfaceContainerHelper4 &)=delete | |
OInterfaceContainerHelper4 & | operator= (const OInterfaceContainerHelper4 &)=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 |
Friends | |
class | OInterfaceIteratorHelper4< 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/interfacecontainer3.hxx, except that it (a) uses std::mutex instead of osl::Mutex and (b) does not store a reference to the mutex, but relies on the calling class to take a lock around using it.
ListenerT | UNO event listener type |
Definition at line 124 of file interfacecontainer4.hxx.
|
inline |
Definition at line 274 of file interfacecontainer4.hxx.
References DEFAULT.
|
privatedelete |
sal_Int32 comphelper::OInterfaceContainerHelper4< ListenerT >::addInterface | ( | std::unique_lock< std::mutex > & | rGuard, |
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 |
rGuard | this parameter only here to make that this container is accessed while locked |
Definition at line 337 of file interfacecontainer4.hxx.
References maData.
Referenced by OInstanceLocker::addEventListener(), and comphelper::WeakComponentImplHelperBase::addEventListener().
void comphelper::OInterfaceContainerHelper4< ListenerT >::clear | ( | ::std::unique_lock<::std::mutex > & | rGuard | ) |
Clears the container without calling disposing().
rGuard | this parameter only here to make that this container is accessed while locked |
Definition at line 397 of file interfacecontainer4.hxx.
References maData.
|
inlinestaticprivate |
Definition at line 242 of file interfacecontainer4.hxx.
void comphelper::OInterfaceContainerHelper4< ListenerT >::disposeAndClear | ( | ::std::unique_lock<::std::mutex > & | rGuard, |
const css::lang::EventObject & | rEvt | ||
) |
Call disposing on all object in the container that support XEventListener.
Then clear the container. The guard is unlock()'ed before calling the listeners.
Definition at line 368 of file interfacecontainer4.hxx.
References DEFAULT, comphelper::OInterfaceIteratorHelper4< ListenerT >::hasMoreElements(), maData, and comphelper::OInterfaceIteratorHelper4< ListenerT >::next().
Referenced by OInstanceLocker::dispose(), and comphelper::WeakComponentImplHelperBase::dispose().
|
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> |
rGuard | this parameter only here to make that this container is accessed while locked |
Definition at line 281 of file interfacecontainer4.hxx.
References comphelper::OInterfaceIteratorHelper4< ListenerT >::hasMoreElements(), maData, comphelper::OInterfaceIteratorHelper4< ListenerT >::next(), comphelper::OInterfaceIteratorHelper4< ListenerT >::remove(), and size.
std::vector< css::uno::Reference< ListenerT > > comphelper::OInterfaceContainerHelper4< ListenerT >::getElements | ( | std::unique_lock< std::mutex > & | rGuard | ) | const |
Return all interfaces added to this container.
rGuard | this parameter only here to make that this container is accessed while locked |
Definition at line 330 of file interfacecontainer4.hxx.
References maData.
sal_Int32 comphelper::OInterfaceContainerHelper4< ListenerT >::getLength | ( | std::unique_lock< std::mutex > & | rGuard | ) | const |
Return the number of Elements in the container.
Only useful if you have acquired the mutex.
rGuard | this parameter only here to make that this container is accessed while locked |
Definition at line 323 of file interfacecontainer4.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 |
rGuard | this parameter only here to make that this container is accessed while locked |
Example:
Definition at line 313 of file interfacecontainer4.hxx.
|
privatedelete |
sal_Int32 comphelper::OInterfaceContainerHelper4< ListenerT >::removeInterface | ( | std::unique_lock< std::mutex > & | rGuard, |
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 |
rGuard | this parameter only here to make that this container is accessed while locked |
Definition at line 346 of file interfacecontainer4.hxx.
References find(), and maData.
Referenced by OInstanceLocker::removeEventListener(), and comphelper::WeakComponentImplHelperBase::removeEventListener().
|
friend |
Definition at line 228 of file interfacecontainer4.hxx.
|
private |
Definition at line 236 of file interfacecontainer4.hxx.