19 #ifndef _CPPUHELPER_INTERFACECONTAINER_H_
20 #define _CPPUHELPER_INTERFACECONTAINER_H_
26 #include <com/sun/star/uno/XInterface.hpp>
27 #include <com/sun/star/lang/EventObject.hpp>
29 #include "com/sun/star/lang/DisposedException.hpp"
48 class OInterfaceContainerHelper;
81 {
return nRemain != 0; }
86 ::com::sun::star::uno::XInterface * SAL_CALL next()
SAL_THROW(());
99 detail::element_alias aData;
118 inline static void * SAL_CALL
operator new(
size_t nSize )
SAL_THROW(())
120 inline static void SAL_CALL
operator delete(
void * pMem )
SAL_THROW(())
122 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
SAL_THROW(())
124 inline static void SAL_CALL
operator delete(
void *,
void * )
SAL_THROW(())
139 ~OInterfaceContainerHelper() SAL_THROW(());
144 sal_Int32 SAL_CALL getLength() const SAL_THROW(());
149 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElements() const SAL_THROW(());
167 sal_Int32 SAL_CALL addInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW(());
175 sal_Int32 SAL_CALL removeInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW(());
180 void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
184 void SAL_CALL clear() SAL_THROW(());
197 template <typename ListenerT, typename FuncT>
198 inline
void forEach( FuncT const& func );
221 template< typename ListenerT, typename EventT >
222 inline
void notifyEach(
void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ), const EventT& Event );
230 detail::element_alias aData;
231 ::osl::Mutex & rMutex;
237 OInterfaceContainerHelper( const OInterfaceContainerHelper & ) SAL_THROW(());
238 OInterfaceContainerHelper & operator = ( const OInterfaceContainerHelper & ) SAL_THROW(());
244 void copyAndResetInUse() SAL_THROW(());
247 template< typename ListenerT, typename EventT >
248 class NotifySingleListener
251 typedef void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& );
252 NotificationMethod m_pMethod;
253 const EventT& m_rEvent;
255 NotifySingleListener( NotificationMethod method,
const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
257 void operator()( const ::com::sun::star::uno::Reference<ListenerT>& listener )
const
259 (listener.get()->*m_pMethod)( m_rEvent );
264 template <
typename ListenerT,
typename FuncT>
271 if (xListener.is()) {
272 #if defined(EXCEPTIONS_OFF)
278 catch (::com::sun::star::lang::DisposedException
const& exc) {
279 if (exc.Context == xListener)
287 template<
typename ListenerT,
typename EventT >
290 forEach< ListenerT, NotifySingleListener< ListenerT, EventT > >( NotifySingleListener< ListenerT, EventT >( NotificationMethod, Event ) );
300 template<
class key ,
class hashImpl ,
class equalImpl >
305 inline static void * SAL_CALL
operator new(
size_t nSize )
SAL_THROW(())
307 inline static void SAL_CALL
operator delete(
void * pMem )
SAL_THROW(())
309 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
SAL_THROW(())
311 inline static void SAL_CALL
operator delete(
void *,
void * )
SAL_THROW(())
330 inline ::com::sun::star::uno::Sequence< key > SAL_CALL getContainedTypes() const SAL_THROW(());
338 inline OInterfaceContainerHelper * SAL_CALL getContainer( const key & ) const SAL_THROW(());
358 inline sal_Int32 SAL_CALL addInterface(
360 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
373 inline sal_Int32 SAL_CALL removeInterface(
375 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
383 inline
void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
387 inline
void SAL_CALL clear() SAL_THROW(());
391 typedef ::std::vector< std::pair < key ,
void* > > InterfaceMap;
392 InterfaceMap *m_pMap;
393 ::osl::Mutex & rMutex;
395 inline typename InterfaceMap::iterator find(const key &rKey)
const
397 typename InterfaceMap::iterator iter = m_pMap->begin();
398 typename InterfaceMap::iterator end = m_pMap->end();
403 if( equal( iter->first, rKey ) )
426 template < class container , class keyType >
454 const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > &r )
458 OSL_ENSURE( !bInDispose,
"do not add listeners in the dispose call" );
459 OSL_ENSURE( !bDisposed,
"object is disposed" );
460 if( ! bInDispose && ! bDisposed )
461 aLC.addInterface( key , r );
469 const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > & r )
473 OSL_ENSURE( !bDisposed,
"object is disposed" );
474 if( ! bInDispose && ! bDisposed )
475 aLC.removeInterface( key , r );
485 {
return aLC.getContainer( key ); }
499 {
return (
size_t) s.getTypeName().hashCode(); }
510 inline static void * SAL_CALL
operator new(
size_t nSize )
SAL_THROW(())
512 inline static void SAL_CALL
operator delete(
void * pMem )
SAL_THROW(())
514 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
SAL_THROW(())
516 inline static void SAL_CALL
operator delete(
void *,
void * )
SAL_THROW(())
535 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getContainedTypes() const SAL_THROW(());
542 OInterfaceContainerHelper * SAL_CALL getContainer( const ::com::sun::star::uno::Type & rKey ) const SAL_THROW(());
562 sal_Int32 SAL_CALL addInterface(
563 const ::com::sun::star::uno::Type & rKey,
564 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r )
577 sal_Int32 SAL_CALL removeInterface(
578 const ::com::sun::star::uno::Type & rKey,
579 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace )
586 void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW(());
590 void SAL_CALL clear() SAL_THROW(());
595 ::osl::Mutex & rMutex;