19 #ifndef INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
20 #define INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
32 #include <com/sun/star/uno/XInterface.hpp>
33 #include <com/sun/star/lang/EventObject.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
54 class OInterfaceContainerHelper;
87 {
return nRemain != 0; }
92 ::com::sun::star::uno::XInterface * SAL_CALL next();
99 void SAL_CALL
remove();
124 inline static void * SAL_CALL
operator new(
size_t nSize )
126 inline static void SAL_CALL
operator delete(
void * pMem )
128 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
130 inline static void SAL_CALL
operator delete(
void *,
void * )
150 sal_Int32 SAL_CALL getLength()
const;
173 sal_Int32 SAL_CALL addInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
181 sal_Int32 SAL_CALL removeInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
186 void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt );
190 void SAL_CALL clear();
203 template <
typename ListenerT,
typename FuncT>
204 inline void forEach( FuncT
const& func );
227 template<
typename ListenerT,
typename EventT >
228 inline void notifyEach(
void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& ),
const EventT& Event );
250 void copyAndResetInUse();
253 template<
typename ListenerT,
typename EventT >
254 class NotifySingleListener
257 typedef void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& );
258 NotificationMethod m_pMethod;
259 const EventT& m_rEvent;
261 NotifySingleListener( NotificationMethod method,
const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
263 void operator()( const ::com::sun::star::uno::Reference<ListenerT>& listener )
const
265 (listener.get()->*m_pMethod)( m_rEvent );
270 template <
typename ListenerT,
typename FuncT>
277 if (xListener.is()) {
281 catch (::com::sun::star::lang::DisposedException
const& exc) {
282 if (exc.Context == xListener)
289 template<
typename ListenerT,
typename EventT >
292 forEach< ListenerT, NotifySingleListener< ListenerT, EventT > >( NotifySingleListener< ListenerT, EventT >( NotificationMethod, Event ) );
302 template<
class key,
class hashImpl =
void,
class equalImpl = std::equal_to<key> >
307 inline static void * SAL_CALL
operator new(
size_t nSize )
309 inline static void SAL_CALL
operator delete(
void * pMem )
311 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
313 inline static void SAL_CALL
operator delete(
void *,
void * )
332 inline ::com::sun::star::uno::Sequence< key > SAL_CALL
getContainedTypes()
const;
362 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r );
376 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 );
387 inline void SAL_CALL
clear();
391 typedef ::std::vector< std::pair < key , void* > > InterfaceMap;
392 InterfaceMap *m_pMap;
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 )
460 aLC.addInterface( key , r );
468 const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > & r )
473 aLC.removeInterface( key , r );
483 {
return aLC.getContainer( key ); }
496 size_t operator()(const ::com::sun::star::uno::Type & s)
const
497 {
return (
size_t) s.getTypeName().hashCode(); }
508 inline static void * SAL_CALL
operator new(
size_t nSize )
510 inline static void SAL_CALL
operator delete(
void * pMem )
512 inline static void * SAL_CALL
operator new( size_t,
void * pMem )
514 inline static void SAL_CALL
operator delete(
void *,
void * )
560 sal_Int32 SAL_CALL addInterface(
561 const ::com::sun::star::uno::Type & rKey,
562 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r );
574 sal_Int32 SAL_CALL removeInterface(
575 const ::com::sun::star::uno::Type & rKey,
576 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace );
582 void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt );
586 void SAL_CALL clear();