23#ifndef INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
24#define INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
33#include "osl/diagnose.h"
34#include "osl/mutex.hxx"
36#include "com/sun/star/uno/Sequence.hxx"
37#include "com/sun/star/lang/EventObject.hpp"
39#include "com/sun/star/lang/DisposedException.hpp"
42namespace com {
namespace sun {
namespace star {
namespace uno {
class XInterface; } } } }
55 std::vector< css::uno::Reference< css::uno::XInterface > > *
pAsVector;
63class OInterfaceContainerHelper;
96 {
return nRemain != 0; }
101 css::uno::XInterface * SAL_CALL next();
119 SAL_DELETED_FUNCTION;
121 SAL_DELETED_FUNCTION;
135 static void * SAL_CALL
operator new(
size_t nSize )
136 { return ::rtl_allocateMemory( nSize ); }
137 static void SAL_CALL
operator delete(
void * pMem )
138 { ::rtl_freeMemory( pMem ); }
139 static void * SAL_CALL
operator new( size_t,
void * pMem )
141 static void SAL_CALL
operator delete(
void *,
void * )
166 css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > SAL_CALL getElements()
const;
184 sal_Int32 SAL_CALL addInterface(
const css::uno::Reference< css::uno::XInterface > & rxIFace );
192 sal_Int32 SAL_CALL removeInterface(
const css::uno::Reference< css::uno::XInterface > & rxIFace );
197 void SAL_CALL disposeAndClear(
const css::lang::EventObject & rEvt );
201 void SAL_CALL clear();
214 template <
typename ListenerT,
typename FuncT>
215 inline void forEach( FuncT
const& func );
238 template<
typename ListenerT,
typename EventT >
239 inline void notifyEach(
void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& ),
const EventT& Event );
255 SAL_DELETED_FUNCTION;
257 SAL_DELETED_FUNCTION;
263 void copyAndResetInUse();
266 template<
typename ListenerT,
typename EventT >
270 typedef void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& );
276 void operator()(
const css::uno::Reference<ListenerT>& listener )
const
283template <
typename ListenerT,
typename FuncT>
288 css::uno::Reference<ListenerT>
const xListener( iter.
next(), css::uno::UNO_QUERY );
289 if (xListener.is()) {
293 catch (css::lang::DisposedException
const& exc) {
294 if (exc.Context == xListener)
301template<
typename ListenerT,
typename EventT >
314template<
class key,
class hashImpl =
void,
class equalImpl = std::equal_to<key> >
319 static void * SAL_CALL
operator new(
size_t nSize )
320 { return ::rtl_allocateMemory( nSize ); }
321 static void SAL_CALL
operator delete(
void * pMem )
322 { ::rtl_freeMemory( pMem ); }
323 static void * SAL_CALL
operator new( size_t,
void * pMem )
325 static void SAL_CALL
operator delete(
void *,
void * )
374 const css::uno::Reference< css::uno::XInterface > & r );
388 const css::uno::Reference< css::uno::XInterface > & rxIFace );
395 inline void SAL_CALL
disposeAndClear(
const css::lang::EventObject & rEvt );
399 inline void SAL_CALL
clear();
407 typename InterfaceMap::iterator
find(
const key &rKey)
const
409 typename InterfaceMap::iterator iter =
m_pMap->begin();
410 typename InterfaceMap::iterator
end =
m_pMap->end();
415 if(
equal( iter->first, rKey ) )
438template <
class container ,
class keyType >
458 , bInDispose( false )
466 const css::uno::Reference < css::uno::XInterface > &r )
468 ::osl::MutexGuard guard( rMutex );
469 OSL_ENSURE( !bInDispose,
"do not add listeners in the dispose call" );
470 OSL_ENSURE( !bDisposed,
"object is disposed" );
471 if( ! bInDispose && ! bDisposed )
472 aLC.addInterface( key , r );
480 const css::uno::Reference < css::uno::XInterface > & r )
482 ::osl::MutexGuard guard( rMutex );
483 if( ! bInDispose && ! bDisposed )
484 aLC.removeInterface( key , r );
494 {
return aLC.getContainer( key ); }
508 {
return static_cast<size_t>(s.getTypeName().hashCode()); }
519 static void * SAL_CALL
operator new(
size_t nSize )
520 { return ::rtl_allocateMemory( nSize ); }
521 static void SAL_CALL
operator delete(
void * pMem )
522 { ::rtl_freeMemory( pMem ); }
523 static void * SAL_CALL
operator new( size_t,
void * pMem )
525 static void SAL_CALL
operator delete(
void *,
void * )
544 css::uno::Sequence< css::uno::Type > SAL_CALL getContainedTypes()
const;
571 sal_Int32 SAL_CALL addInterface(
572 const css::uno::Type & rKey,
573 const css::uno::Reference< css::uno::XInterface > & r );
585 sal_Int32 SAL_CALL removeInterface(
586 const css::uno::Type & rKey,
587 const css::uno::Reference< css::uno::XInterface > & rxIFace );
593 void SAL_CALL disposeAndClear(
const css::lang::EventObject & rEvt );
597 void SAL_CALL clear();
typedef void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &)
NotifySingleListener(NotificationMethod method, const EventT &event)
void operator()(const css::uno::Reference< ListenerT > &listener) const
NotificationMethod m_pMethod
A container of interfaces.
sal_Bool bInUse
TRUE -> used by an iterator.
OInterfaceContainerHelper(const OInterfaceContainerHelper &) SAL_DELETED_FUNCTION
sal_Bool bIsList
TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >.
void forEach(FuncT const &func)
Executes a functor for each contained listener of specified type, e.g.
detail::element_alias aData
bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >, otherwise aData....
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
Calls a UNO listener method for each contained listener.
OInterfaceContainerHelper(::osl::Mutex &rMutex)
Create an interface container.
This is the iterator of an InterfaceContainerHelper.
OInterfaceContainerHelper & rCont
css::uno::XInterface *SAL_CALL next()
Return the next element of the iterator.
detail::element_alias aData
bool SAL_CALL hasMoreElements() const
Return true, if there are more elements in the iterator.
void SAL_CALL remove()
Removes the current element (the last one returned by next()) from the underlying container.
OInterfaceIteratorHelper(const OInterfaceIteratorHelper &) SAL_DELETED_FUNCTION
A helper class to store interface references of different types.
~OMultiTypeInterfaceContainerHelperVar()
Deletes all containers.
sal_Int32 SAL_CALL addInterface(const key &rKey, const css::uno::Reference< css::uno::XInterface > &r)
Inserts an element into the container with the specified key.
OInterfaceContainerHelper *SAL_CALL getContainer(const key &) const
Return the container created under this key.
OMultiTypeInterfaceContainerHelperVar & operator=(const OMultiTypeInterfaceContainerHelperVar &) SAL_DELETED_FUNCTION
void SAL_CALL clear()
Remove all elements of all containers.
InterfaceMap::iterator find(const key &rKey) const
void SAL_CALL disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all references in the container, that support XEventListener.
::std::vector< std::pair< key, void * > > InterfaceMap
OMultiTypeInterfaceContainerHelperVar(::osl::Mutex &rMutex)
Create a container of interface containers.
OMultiTypeInterfaceContainerHelperVar(const OMultiTypeInterfaceContainerHelperVar &) SAL_DELETED_FUNCTION
css::uno::Sequence< key > SAL_CALL getContainedTypes() const
Return all id's under which at least one interface is added.
sal_Int32 SAL_CALL removeInterface(const key &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
Removes an element from the container with the specified key.
Specialized class for key type css::uno::Type, without explicit usage of STL symbols.
OMultiTypeInterfaceContainerHelper(::osl::Mutex &rMutex)
Create a container of interface containers.
OMultiTypeInterfaceContainerHelper(const OMultiTypeInterfaceContainerHelper &) SAL_DELETED_FUNCTION
#define CPPUHELPER_DLLPUBLIC
const ContainerEvent & m_rEvent
ContainerApprovalMethod m_pMethod
double getLength(const B2DPolygon &rCandidate)
OUStringBuffer & remove(OUStringBuffer &rIn, sal_Unicode c)
OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper, OMultiTypeInterfaceContainerHelper::keyType > OBroadcastHelper
This struct contains the standard variables of a broadcaster.
void addListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
adds a listener threadsafe.
container aLC
ListenerContainer class is thread safe.
::osl::Mutex & rMutex
The shared mutex.
sal_Bool bInDispose
In dispose call.
void removeListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
removes a listener threadsafe
sal_Bool bDisposed
Dispose call ready.
OBroadcastHelperVar(::osl::Mutex &rMutex_)
Initialize the structure.
OInterfaceContainerHelper *SAL_CALL getContainer(const keyType &key) const
Return the container created under this key.
size_t operator()(const css::uno::Type &s) const
This is here to optimise space in the common case that there are zero or one listeners.
std::vector< css::uno::Reference< css::uno::XInterface > > * pAsVector
css::uno::XInterface * pAsInterface