23#ifndef INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
24#define INCLUDED_CPPUHELPER_INTERFACECONTAINER_H
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();
135 static void * SAL_CALL
operator new(
size_t nSize )
136 { return ::rtl_allocateMemory( nSize ); }
137 static void SAL_CALL
operator delete(
void * pMem )
139 static void * SAL_CALL
operator new( size_t,
void * pMem )
141 static void SAL_CALL
operator delete(
void *,
void * )
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 );
263 void copyAndResetInUse();
266 template<
typename ListenerT,
typename EventT >
267 class NotifySingleListener
270 typedef void ( SAL_CALL ListenerT::*NotificationMethod )(
const EventT& );
271 NotificationMethod m_pMethod;
272 const EventT& m_rEvent;
274 NotifySingleListener( NotificationMethod method,
const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { }
278 (listener.
get()->*m_pMethod)( m_rEvent );
283template <
typename ListenerT,
typename FuncT>
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 )
323 static void * SAL_CALL
operator new( size_t,
void * pMem )
325 static void SAL_CALL
operator delete(
void *,
void * )
395 inline void SAL_CALL
disposeAndClear(
const css::lang::EventObject & rEvt );
399 inline void SAL_CALL
clear();
403 typedef ::std::vector< std::pair < key , void* > > InterfaceMap;
404 InterfaceMap *m_pMap;
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 >
466 const css::uno::Reference < css::uno::XInterface > &r )
472 aLC.addInterface( key , r );
480 const css::uno::Reference < css::uno::XInterface > & r )
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 )
523 static void * SAL_CALL
operator new( size_t,
void * pMem )
525 static void SAL_CALL
operator delete(
void *,
void * )
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:396
unsigned char sal_Bool
Definition types.h:38
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:611
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Provides simple diagnostic support.
#define CPPUHELPER_DLLPUBLIC
Definition cppuhelperdllapi.h:32
#define OSL_ENSURE(c, m)
If cond is false, reports an error with message msg.
Definition diagnose.h:87
Guard< Mutex > MutexGuard
Definition mutex.hxx:273
Definition typedescription.hxx:43
@ UNO_QUERY
This enum value can be used for implicit interface query.
Definition Reference.h:157
Definition Enterable.hxx:31
OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper, OMultiTypeInterfaceContainerHelper::keyType > OBroadcastHelper
Definition interfacecontainer.h:608
Definition unotype.hxx:103
A mutual exclusion synchronization object.
Definition mutex.hxx:35
interface_type * get() const
Gets interface pointer.
Definition Reference.h:405
Template C++ class representing an IDL sequence.
Definition Sequence.h:61
This is here to optimise space in the common case that there are zero or one listeners.
Definition interfacecontainer.h:54
std::vector< css::uno::Reference< css::uno::XInterface > > * pAsVector
Definition interfacecontainer.h:55
css::uno::XInterface * pAsInterface
Definition interfacecontainer.h:56
element_alias()
Definition interfacecontainer.h:57
~OInterfaceIteratorHelper()
Releases the connection to the container.
void remove()
Removes the current element (the last one returned by next()) from the underlying container.
bool hasMoreElements() const
Return true, if there are more elements in the iterator.
Definition interfacecontainer.h:95
OInterfaceIteratorHelper(OInterfaceContainerHelper &rCont)
Create an iterator over the elements of the container.
css::uno::XInterface * next()
Return the next element of the iterator.
A container of interfaces.
Definition interfacecontainer.h:132
sal_Int32 getLength() const
Return the number of Elements in the container.
void notifyEach(void(ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
Calls a UNO listener method for each contained listener.
Definition interfacecontainer.h:302
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
friend class OInterfaceIteratorHelper
Definition interfacecontainer.h:242
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
Removes an element from the container.
void forEach(FuncT const &func)
Executes a functor for each contained listener of specified type, e.g.
Definition interfacecontainer.h:284
~OInterfaceContainerHelper()
Release all interfaces.
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
Inserts an element into the container.
void clear()
Clears the container without calling disposing().
OInterfaceContainerHelper(::osl::Mutex &rMutex)
Create an interface container.
css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > getElements() const
Return all interfaces added to this container.
A helper class to store interface references of different types.
Definition interfacecontainer.h:316
~OMultiTypeInterfaceContainerHelperVar()
Deletes all containers.
Definition interfacecontainer.hxx:45
sal_Int32 addInterface(const key &rKey, const css::uno::Reference< css::uno::XInterface > &r)
Inserts an element into the container with the specified key.
Definition interfacecontainer.hxx:106
OInterfaceContainerHelper * getContainer(const key &) const
Return the container created under this key.
Definition interfacecontainer.hxx:93
void clear()
Remove all elements of all containers.
Definition interfacecontainer.hxx:179
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all references in the container, that support XEventListener.
Definition interfacecontainer.hxx:142
key keyType
Definition interfacecontainer.h:401
OMultiTypeInterfaceContainerHelperVar(::osl::Mutex &rMutex)
Create a container of interface containers.
Definition interfacecontainer.hxx:37
css::uno::Sequence< key > getContainedTypes() const
Return all id's under which at least one interface is added.
Definition interfacecontainer.hxx:61
sal_Int32 removeInterface(const key &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
Removes an element from the container with the specified key.
Definition interfacecontainer.hxx:124
This struct contains the standard variables of a broadcaster.
Definition interfacecontainer.h:440
OInterfaceContainerHelper * getContainer(const keyType &key) const
Return the container created under this key.
Definition interfacecontainer.h:493
void addListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
adds a listener threadsafe.
Definition interfacecontainer.h:464
OMultiTypeInterfaceContainerHelper aLC
Definition interfacecontainer.h:444
::osl::Mutex & rMutex
Definition interfacecontainer.h:442
sal_Bool bInDispose
Definition interfacecontainer.h:448
void removeListener(const keyType &key, const css::uno::Reference< css::uno::XInterface > &r)
removes a listener threadsafe
Definition interfacecontainer.h:478
sal_Bool bDisposed
Definition interfacecontainer.h:446
OBroadcastHelperVar(::osl::Mutex &rMutex_)
Initialize the structure.
Definition interfacecontainer.h:454
Definition interfacecontainer.h:506
size_t operator()(const css::uno::Type &s) const
Definition interfacecontainer.h:507
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
OMultiTypeInterfaceContainerHelper(::osl::Mutex &rMutex)
Create a container of interface containers.
void clear()
Remove all elements of all containers.
~OMultiTypeInterfaceContainerHelper()
Delete all containers.
css::uno::Sequence< css::uno::Type > getContainedTypes() const
Return all id's under which at least one interface is added.
sal_Int32 removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
Removes an element from the container with the specified key.
OInterfaceContainerHelper * getContainer(const css::uno::Type &rKey) const
Return the container created under this key.
sal_Int32 addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
Inserts an element into the container with the specified key.
css::uno::Type keyType
Definition interfacecontainer.h:599
bool is() const
Checks if reference is null.
Definition Reference.h:101
C++ class representing an IDL meta type.
Definition Type.h:59
inline ::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition Type.hxx:85