19 #ifndef INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
20 #define INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
29 #include <com/sun/star/uno/XInterface.hpp>
30 #include <com/sun/star/lang/EventObject.hpp>
32 #include <com/sun/star/lang/DisposedException.hpp>
51 class OInterfaceContainerHelper;
84 {
return nRemain != 0; }
89 ::com::sun::star::uno::XInterface * SAL_CALL next()
SAL_THROW(());
102 detail::element_alias aData;
121 inline static void * SAL_CALL
operator new(
size_t nSize )
SAL_THROW(())
123 inline static void SAL_CALL
operator delete(
void * pMem )
SAL_THROW(())
125 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
SAL_THROW(())
127 inline static void SAL_CALL
operator delete(
void *,
void * )
SAL_THROW(())
142 ~OInterfaceContainerHelper() SAL_THROW(());
147 sal_Int32 SAL_CALL getLength() const SAL_THROW(());
152 ::
com::sun::star::uno::Sequence< ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > > SAL_CALL getElements() const SAL_THROW(());
170 sal_Int32 SAL_CALL addInterface( const ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW(());
178 sal_Int32 SAL_CALL removeInterface( const ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW(());
183 void SAL_CALL disposeAndClear( const ::
com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
187 void SAL_CALL clear() SAL_THROW(());
200 template <typename ListenerT, typename FuncT>
201 inline
void forEach( FuncT const& func );
224 template< typename ListenerT, typename EventT >
225 inline
void notifyEach(
void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ), const EventT& Event );
233 detail::element_alias aData;
234 ::
osl::Mutex & rMutex;
240 OInterfaceContainerHelper( const OInterfaceContainerHelper & ) SAL_THROW(());
241 OInterfaceContainerHelper & operator = ( const OInterfaceContainerHelper & ) SAL_THROW(());
247 void copyAndResetInUse() SAL_THROW(());
250 template< typename ListenerT, typename EventT >
251 class NotifySingleListener
254 typedef void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& );
255 NotificationMethod m_pMethod;
256 const EventT& m_rEvent;
258 NotifySingleListener( NotificationMethod method,
const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
260 void operator()( const ::com::sun::star::uno::Reference<ListenerT>& listener )
const
262 (listener.get()->*m_pMethod)( m_rEvent );
267 template <
typename ListenerT,
typename FuncT>
274 if (xListener.is()) {
278 catch (::com::sun::star::lang::DisposedException
const& exc) {
279 if (exc.Context == xListener)
286 template<
typename ListenerT,
typename EventT >
289 forEach< ListenerT, NotifySingleListener< ListenerT, EventT > >( NotifySingleListener< ListenerT, EventT >( NotificationMethod, Event ) );
299 template<
class key,
class hashImpl =
void,
class equalImpl = std::equal_to<key> >
304 inline static void * SAL_CALL
operator new(
size_t nSize )
SAL_THROW(())
306 inline static void SAL_CALL
operator delete(
void * pMem )
SAL_THROW(())
308 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
SAL_THROW(())
310 inline static void SAL_CALL
operator delete(
void *,
void * )
SAL_THROW(())
329 inline ::
com::sun::star::uno::Sequence< key > SAL_CALL getContainedTypes() const SAL_THROW(());
337 inline OInterfaceContainerHelper * SAL_CALL getContainer( const key & ) const SAL_THROW(());
357 inline sal_Int32 SAL_CALL addInterface(
359 const ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > & r )
372 inline sal_Int32 SAL_CALL removeInterface(
374 const ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > & rxIFace )
382 inline
void SAL_CALL disposeAndClear( const ::
com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
386 inline
void SAL_CALL clear() SAL_THROW(());
390 typedef ::std::vector< std::pair < key ,
void* > > InterfaceMap;
391 InterfaceMap *m_pMap;
392 ::
osl::Mutex & rMutex;
394 inline typename InterfaceMap::iterator find(const key &rKey)
const
396 typename InterfaceMap::iterator iter = m_pMap->begin();
397 typename InterfaceMap::iterator end = m_pMap->end();
402 if( equal( iter->first, rKey ) )
425 template < class container , class keyType >
453 const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > &r )
457 OSL_ENSURE( !bInDispose,
"do not add listeners in the dispose call" );
458 OSL_ENSURE( !bDisposed,
"object is disposed" );
459 if( ! bInDispose && ! bDisposed )
460 aLC.addInterface( key , r );
468 const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > & r )
472 OSL_ENSURE( !bDisposed,
"object is disposed" );
473 if( ! bInDispose && ! bDisposed )
474 aLC.removeInterface( key , r );
484 {
return aLC.getContainer( key ); }
498 {
return (
size_t) s.getTypeName().hashCode(); }
509 inline static void * SAL_CALL
operator new(
size_t nSize )
SAL_THROW(())
511 inline static void SAL_CALL
operator delete(
void * pMem )
SAL_THROW(())
513 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
SAL_THROW(())
515 inline static void SAL_CALL
operator delete(
void *,
void * )
SAL_THROW(())
534 ::
com::sun::star::uno::Sequence< ::
com::sun::star::uno::Type > SAL_CALL getContainedTypes() const SAL_THROW(());
541 OInterfaceContainerHelper * SAL_CALL getContainer( const ::
com::sun::star::uno::Type & rKey ) const SAL_THROW(());
561 sal_Int32 SAL_CALL addInterface(
562 const ::
com::sun::star::uno::Type & rKey,
563 const ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > & r )
576 sal_Int32 SAL_CALL removeInterface(
577 const ::
com::sun::star::uno::Type & rKey,
578 const ::
com::sun::star::uno::Reference< ::
com::sun::star::uno::XInterface > & rxIFace )
585 void SAL_CALL disposeAndClear( const ::
com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
589 void SAL_CALL clear() SAL_THROW(());
594 ::
osl::Mutex & rMutex;
OBroadcastHelperVar(::osl::Mutex &rMutex_) SAL_THROW(())
Initialize the structur.
Definition: interfacecontainer.h:441
key keyType
Definition: interfacecontainer.h:388
::osl::Mutex & rMutex
The shared mutex.
Definition: interfacecontainer.h:429
A helper class for mutex objects and interfaces.
Definition: mutex.hxx:123
This is the iterator of a InterfaceContainerHelper.
Definition: interfacecontainer.h:59
element_alias()
Definition: interfacecontainer.h:45
A helper class to store interface references of different types.
Definition: interfacecontainer.h:300
unsigned char sal_Bool
Definition: types.h:46
C++ class representing an IDL meta type.
Definition: Type.h:55
void forEach(FuncT const &func)
Executes a functor for each contained listener of specified type, e.g.
Definition: interfacecontainer.h:268
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
sal_Bool bDisposed
Dispose call ready.
Definition: interfacecontainer.h:433
#define sal_False
Definition: types.h:47
void remove() SAL_THROW(())
Removes the current element (the last one returned by next()) from the underlying container...
void addListener(const keyType &key, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > &r)
adds a listener threadsafe.
Definition: interfacecontainer.h:451
::com::sun::star::uno::XInterface * pAsInterface
Definition: interfacecontainer.h:44
This enum value can be used for implicit interface query.
Definition: Reference.h:138
::com::sun::star::uno::XInterface * next() SAL_THROW(())
Return the next element of the iterator.
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:33
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > * pAsSequence
Definition: interfacecontainer.h:43
A container of interfaces.
Definition: interfacecontainer.h:117
Definition: interfacecontainer.h:495
Definition: conditn.hxx:30
#define OSL_ENSURE(c, m)
Definition: diagnose.h:106
This struct contains the standard variables of a broadcaster.
Definition: interfacecontainer.h:426
Definition: Enterable.hxx:26
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
OInterfaceContainerHelper * getContainer(const keyType &key) const SAL_THROW(())
Return the container created under this key.
Definition: interfacecontainer.h:483
void notifyEach(void(ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
Calls a UNO listener method for each contained listener.
Definition: interfacecontainer.h:287
Specialized class for key type com::sun::star::uno::Type, without explicit usage of STL symbols...
Definition: interfacecontainer.h:505
bool hasMoreElements() const SAL_THROW(())
Return true, if there are more elements in the iterator.
Definition: interfacecontainer.h:83
container aLC
ListenerContainer class is thread safe.
Definition: interfacecontainer.h:431
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
void removeListener(const keyType &key, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > &r)
removes a listener threadsafe
Definition: interfacecontainer.h:466
A mutual exclusion synchronization object.
Definition: mutex.hxx:32
#define CPPUHELPER_DLLPUBLIC
Definition: cppuhelperdllapi.h:28
Definition: interfacecontainer.h:41
size_t operator()(const ::com::sun::star::uno::Type &s) const SAL_THROW(())
Definition: interfacecontainer.h:497
sal_Bool bInDispose
In dispose call.
Definition: interfacecontainer.h:435
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.