19 #ifndef INCLUDED_CPPUHELPER_INTERFACECONTAINER_H 20 #define INCLUDED_CPPUHELPER_INTERFACECONTAINER_H 33 #include <com/sun/star/uno/XInterface.hpp> 34 #include <com/sun/star/lang/EventObject.hpp> 36 #include <com/sun/star/lang/DisposedException.hpp> 51 css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > *
pAsSequence;
92 {
return nRemain != 0; }
97 css::uno::XInterface * SAL_CALL next();
104 void SAL_CALL
remove();
131 inline static void * SAL_CALL
operator new(
size_t nSize )
133 inline static void SAL_CALL
operator delete(
void * pMem )
135 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
137 inline static void SAL_CALL
operator delete(
void *,
void * )
157 sal_Int32 SAL_CALL getLength()
const;
162 css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > SAL_CALL getElements()
const;
180 sal_Int32 SAL_CALL addInterface(
const css::uno::Reference< css::uno::XInterface > & rxIFace );
188 sal_Int32 SAL_CALL removeInterface(
const css::uno::Reference< css::uno::XInterface > & rxIFace );
193 void SAL_CALL disposeAndClear(
const css::lang::EventObject & rEvt );
197 void SAL_CALL clear();
210 template <
typename ListenerT,
typename FuncT>
211 inline void forEach( FuncT
const& func );
234 template<
typename ListenerT,
typename EventT >
235 inline void notifyEach(
void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& ),
const EventT& Event );
253 SAL_DELETED_FUNCTION;
259 void copyAndResetInUse();
262 template< typename ListenerT, typename EventT >
263 class NotifySingleListener
266 typedef void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& );
267 NotificationMethod m_pMethod;
268 const EventT& m_rEvent;
270 NotifySingleListener( NotificationMethod method,
const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
272 void operator()(
const css::uno::Reference<ListenerT>& listener )
const 274 (listener.get()->*m_pMethod)( m_rEvent );
279 template <
typename ListenerT,
typename FuncT>
285 if (xListener.is()) {
289 catch (css::lang::DisposedException
const& exc) {
290 if (exc.Context == xListener)
297 template<
typename ListenerT,
typename EventT >
300 forEach< ListenerT, NotifySingleListener< ListenerT, EventT > >( NotifySingleListener< ListenerT, EventT >( NotificationMethod, Event ) );
310 template<
class key,
class hashImpl =
void,
class equalImpl = std::equal_to<key> >
315 inline static void * SAL_CALL
operator new(
size_t nSize )
317 inline static void SAL_CALL
operator delete(
void * pMem )
319 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
321 inline static void SAL_CALL
operator delete(
void *,
void * )
340 inline css::uno::Sequence< key > SAL_CALL getContainedTypes()
const;
368 inline sal_Int32 SAL_CALL addInterface(
370 const css::uno::Reference< css::uno::XInterface > & r );
382 inline sal_Int32 SAL_CALL removeInterface(
384 const css::uno::Reference< css::uno::XInterface > & rxIFace );
391 inline void SAL_CALL disposeAndClear(
const css::lang::EventObject & rEvt );
395 inline void SAL_CALL clear();
399 typedef ::std::vector< std::pair < key , void* > > InterfaceMap;
400 InterfaceMap *m_pMap;
403 inline typename InterfaceMap::iterator find(
const key &rKey)
const 405 typename InterfaceMap::iterator iter = m_pMap->begin();
406 typename InterfaceMap::iterator end = m_pMap->end();
411 if( equal( iter->first, rKey ) )
434 template <
class container ,
class keyType >
462 const css::uno::Reference < css::uno::XInterface > &r )
465 OSL_ENSURE( !bInDispose,
"do not add listeners in the dispose call" );
466 OSL_ENSURE( !bDisposed,
"object is disposed" );
467 if( ! bInDispose && ! bDisposed )
468 aLC.addInterface( key , r );
476 const css::uno::Reference < css::uno::XInterface > & r )
479 OSL_ENSURE( !bDisposed,
"object is disposed" );
480 if( ! bInDispose && ! bDisposed )
481 aLC.removeInterface( key , r );
491 {
return aLC.getContainer( key ); }
505 {
return (
size_t) s.getTypeName().hashCode(); }
516 inline static void * SAL_CALL
operator new(
size_t nSize )
518 inline static void SAL_CALL
operator delete(
void * pMem )
520 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
522 inline static void SAL_CALL
operator delete(
void *,
void * )
541 css::uno::Sequence< css::uno::Type > SAL_CALL getContainedTypes()
const;
568 sal_Int32 SAL_CALL addInterface(
569 const css::uno::Type & rKey,
570 const css::uno::Reference< css::uno::XInterface > & r );
582 sal_Int32 SAL_CALL removeInterface(
583 const css::uno::Type & rKey,
584 const css::uno::Reference< css::uno::XInterface > & rxIFace );
590 void SAL_CALL disposeAndClear(
const css::lang::EventObject & rEvt );
594 void SAL_CALL clear();
void forEach(FuncT const &func)
Executes a functor for each contained listener of specified type, e.g.
Definition: interfacecontainer.h:280
This enum value can be used for implicit interface query.
Definition: Reference.h:140
void remove()
Removes the current element (the last one returned by next()) from the underlying container...
Specialized class for key type css::uno::Type, without explicit usage of STL symbols.
Definition: interfacecontainer.h:512
sal_Bool bInDispose
In dispose call.
Definition: interfacecontainer.h:444
Definition: Enterable.hxx:26
A mutual exclusion synchronization object.
Definition: mutex.hxx:30
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:408
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > * pAsSequence
Definition: interfacecontainer.h:51
css::uno::Type keyType
Definition: interfacecontainer.h:596
key keyType
Definition: interfacecontainer.h:397
Definition: interfacecontainer.h:502
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
container aLC
ListenerContainer class is thread safe.
Definition: interfacecontainer.h:440
::osl::Mutex & rMutex
The shared mutex.
Definition: interfacecontainer.h:438
A helper class to store interface references of different types.
Definition: interfacecontainer.h:311
element_alias()
Definition: interfacecontainer.h:53
unsigned char sal_Bool
Definition: types.h:48
This is the iterator of a InterfaceContainerHelper.
Definition: interfacecontainer.h:67
#define sal_False
Definition: types.h:49
void removeListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
removes a listener threadsafe
Definition: interfacecontainer.h:474
This is here to optimise space in the common case that there are zero or one listeners.
Definition: interfacecontainer.h:49
OBroadcastHelperVar(::osl::Mutex &rMutex_)
Initialize the structure.
Definition: interfacecontainer.h:450
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
bool hasMoreElements() const
Return true, if there are more elements in the iterator.
Definition: interfacecontainer.h:91
A container of interfaces.
Definition: interfacecontainer.h:127
OInterfaceContainerHelper * getContainer(const keyType &key) const
Return the container created under this key.
Definition: interfacecontainer.h:490
#define OSL_ENSURE(c, m)
Definition: diagnose.h:101
css::uno::XInterface * next()
Return the next element of the iterator.
size_t operator()(const css::uno::Type &s) const
Definition: interfacecontainer.h:504
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:435
void notifyEach(void(ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
Calls a UNO listener method for each contained listener.
Definition: interfacecontainer.h:298
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
A helper class for mutex objects and interfaces.
Definition: mutex.hxx:108
css::uno::XInterface * pAsInterface
Definition: interfacecontainer.h:52
sal_Bool bDisposed
Dispose call ready.
Definition: interfacecontainer.h:442
void addListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
adds a listener threadsafe.
Definition: interfacecontainer.h:460