LibreOffice Module cppuhelper (master) 1
|
A container of interfaces. More...
#include <interfacecontainer.h>
Classes | |
class | NotifySingleListener |
Public Member Functions | |
OInterfaceContainerHelper (::osl::Mutex &rMutex) | |
Create an interface container. More... | |
~OInterfaceContainerHelper () | |
Release all interfaces. More... | |
sal_Int32 SAL_CALL | getLength () const |
Return the number of Elements in the container. More... | |
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > SAL_CALL | getElements () const |
Return all interfaces added to this container. More... | |
sal_Int32 SAL_CALL | addInterface (const css::uno::Reference< css::uno::XInterface > &rxIFace) |
Inserts an element into the container. More... | |
sal_Int32 SAL_CALL | removeInterface (const css::uno::Reference< css::uno::XInterface > &rxIFace) |
Removes an element from the container. More... | |
void SAL_CALL | disposeAndClear (const css::lang::EventObject &rEvt) |
Call disposing on all object in the container that support XEventListener. More... | |
void SAL_CALL | clear () |
Clears the container without calling disposing(). More... | |
template<typename ListenerT , typename FuncT > | |
void | forEach (FuncT const &func) |
Executes a functor for each contained listener of specified type, e.g. More... | |
template<typename ListenerT , typename EventT > | |
void | notifyEach (void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) |
Calls a UNO listener method for each contained listener. More... | |
Static Public Member Functions | |
static void *SAL_CALL | operator new (size_t nSize) |
static void SAL_CALL | operator delete (void *pMem) |
static void *SAL_CALL | operator new (size_t, void *pMem) |
static void SAL_CALL | operator delete (void *, void *) |
Private Member Functions | |
OInterfaceContainerHelper (const OInterfaceContainerHelper &) SAL_DELETED_FUNCTION | |
OInterfaceContainerHelper & | operator= (const OInterfaceContainerHelper &) SAL_DELETED_FUNCTION |
void | copyAndResetInUse () |
Private Attributes | |
detail::element_alias | aData |
bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >, otherwise aData.pAsInterface == of type (XEventListener *) More... | |
::osl::Mutex & | rMutex |
sal_Bool | bInUse |
TRUE -> used by an iterator. More... | |
sal_Bool | bIsList |
TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >. More... | |
Friends | |
class | OInterfaceIteratorHelper |
A container of interfaces.
To access the elements use an iterator. This implementation is thread save.
Definition at line 131 of file interfacecontainer.h.
cppu::OInterfaceContainerHelper::OInterfaceContainerHelper | ( | ::osl::Mutex & | rMutex | ) |
Create an interface container.
rMutex | the mutex to protect multi thread access. The lifetime must be longer than the lifetime of this object. |
References getLength().
cppu::OInterfaceContainerHelper::~OInterfaceContainerHelper | ( | ) |
Release all interfaces.
All iterators must be destroyed before the container is destructed.
Definition at line 128 of file interfacecontainer.cxx.
References aData, bInUse, bIsList, cppu::detail::element_alias::pAsInterface, and cppu::detail::element_alias::pAsVector.
|
private |
sal_Int32 cppu::OInterfaceContainerHelper::addInterface | ( | const css::uno::Reference< css::uno::XInterface > & | 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 null or the same interface more than once |
Definition at line 176 of file interfacecontainer.cxx.
References aData, bInUse, bIsList, copyAndResetInUse(), cppu::detail::element_alias::pAsInterface, cppu::detail::element_alias::pAsVector, rMutex, and SAL_WARN_IF.
Referenced by cppu::OMultiTypeInterfaceContainerHelper::addInterface(), cppu::OMultiTypeInterfaceContainerHelperVar< key, hashImpl, equalImpl >::addInterface(), and cppu::OMultiTypeInterfaceContainerHelperInt32::addInterface().
void cppu::OInterfaceContainerHelper::clear | ( | ) |
Clears the container without calling disposing().
Definition at line 283 of file interfacecontainer.cxx.
References aData, bInUse, bIsList, copyAndResetInUse(), cppu::detail::element_alias::pAsInterface, cppu::detail::element_alias::pAsVector, and rMutex.
|
private |
Definition at line 160 of file interfacecontainer.cxx.
References aData, bInUse, bIsList, cppu::detail::element_alias::pAsInterface, and cppu::detail::element_alias::pAsVector.
Referenced by addInterface(), clear(), cppu::OInterfaceIteratorHelper::OInterfaceIteratorHelper(), and removeInterface().
void cppu::OInterfaceContainerHelper::disposeAndClear | ( | const css::lang::EventObject & | rEvt | ) |
Call disposing on all object in the container that support XEventListener.
Then clear the container.
Definition at line 253 of file interfacecontainer.cxx.
References aData, bInUse, bIsList, cppu::OInterfaceIteratorHelper::hasMoreElements(), cppu::OInterfaceIteratorHelper::next(), cppu::detail::element_alias::pAsInterface, and rMutex.
Referenced by cppu::OMultiTypeInterfaceContainerHelperVar< key, hashImpl, equalImpl >::disposeAndClear(), cppu::OMultiTypeInterfaceContainerHelper::disposeAndClear(), and cppu::OMultiTypeInterfaceContainerHelperInt32::disposeAndClear().
|
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.
ListenerT | listener type |
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 284 of file interfacecontainer.h.
References cppu::OInterfaceIteratorHelper::hasMoreElements(), cppu::OInterfaceIteratorHelper::next(), and cppu::OInterfaceIteratorHelper::remove().
Sequence< Reference< XInterface > > cppu::OInterfaceContainerHelper::getElements | ( | ) | const |
Return all interfaces added to this container.
Definition at line 147 of file interfacecontainer.cxx.
References aData, bIsList, comphelper::containerToSequence(), cppu::detail::element_alias::pAsInterface, cppu::detail::element_alias::pAsVector, rMutex, and x.
sal_Int32 cppu::OInterfaceContainerHelper::getLength | ( | ) | const |
Return the number of Elements in the container.
Only useful if you have acquired the mutex.
Definition at line 137 of file interfacecontainer.cxx.
References aData, bIsList, cppu::detail::element_alias::pAsInterface, cppu::detail::element_alias::pAsVector, and rMutex.
Referenced by cppu::OMultiTypeInterfaceContainerHelperVar< key, hashImpl, equalImpl >::getContainedTypes(), cppu::OMultiTypeInterfaceContainerHelper::getContainedTypes(), and cppu::OMultiTypeInterfaceContainerHelperInt32::getContainedTypes().
|
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.
ListenerT | UNO event listener type, let your compiler deduce this for you |
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 302 of file interfacecontainer.h.
|
inlinestatic |
Definition at line 141 of file interfacecontainer.h.
|
inlinestatic |
Definition at line 137 of file interfacecontainer.h.
|
inlinestatic |
Definition at line 135 of file interfacecontainer.h.
|
inlinestatic |
Definition at line 139 of file interfacecontainer.h.
|
private |
sal_Int32 cppu::OInterfaceContainerHelper::removeInterface | ( | const css::uno::Reference< css::uno::XInterface > & | rxIFace | ) |
Removes an element from the container.
It uses interface equality to remove the interface.
rxIFace | interface to be removed |
Definition at line 204 of file interfacecontainer.cxx.
References aData, bInUse, bIsList, copyAndResetInUse(), get(), p, cppu::detail::element_alias::pAsInterface, cppu::detail::element_alias::pAsVector, rMutex, and SAL_WARN_IF.
Referenced by cppu::OInterfaceIteratorHelper::remove().
|
friend |
Definition at line 242 of file interfacecontainer.h.
|
private |
bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >, otherwise aData.pAsInterface == of type (XEventListener *)
Definition at line 247 of file interfacecontainer.h.
Referenced by addInterface(), clear(), copyAndResetInUse(), disposeAndClear(), getElements(), getLength(), cppu::OInterfaceIteratorHelper::OInterfaceIteratorHelper(), removeInterface(), ~OInterfaceContainerHelper(), and cppu::OInterfaceIteratorHelper::~OInterfaceIteratorHelper().
|
private |
TRUE -> used by an iterator.
Definition at line 250 of file interfacecontainer.h.
Referenced by addInterface(), clear(), copyAndResetInUse(), disposeAndClear(), cppu::OInterfaceIteratorHelper::OInterfaceIteratorHelper(), removeInterface(), ~OInterfaceContainerHelper(), and cppu::OInterfaceIteratorHelper::~OInterfaceIteratorHelper().
|
private |
TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >.
Definition at line 252 of file interfacecontainer.h.
Referenced by addInterface(), clear(), copyAndResetInUse(), disposeAndClear(), getElements(), getLength(), cppu::OInterfaceIteratorHelper::OInterfaceIteratorHelper(), removeInterface(), ~OInterfaceContainerHelper(), and cppu::OInterfaceIteratorHelper::~OInterfaceIteratorHelper().
|
private |
Definition at line 248 of file interfacecontainer.h.
Referenced by addInterface(), clear(), disposeAndClear(), getElements(), getLength(), cppu::OInterfaceIteratorHelper::OInterfaceIteratorHelper(), removeInterface(), and cppu::OInterfaceIteratorHelper::~OInterfaceIteratorHelper().