23#include <com/sun/star/lang/EventObject.hpp>
24#include <com/sun/star/lang/DisposedException.hpp>
42template <
class ListenerT>
class OInterfaceContainerHelper4;
75 assert(rGuard.owns_lock());
84 css::uno::Reference<ListenerT>
const&
next();
93 void remove(::std::unique_lock<::std::mutex>& rGuard);
106template <
class ListenerT>
110 return (*std::as_const(
maData))[nRemain];
113template <
class ListenerT>
116 rCont.removeInterface(rGuard, (*std::as_const(
maData))[nRemain]);
142 sal_Int32
getLength(std::unique_lock<std::mutex>& rGuard)
const;
149 std::vector<css::uno::Reference<ListenerT>>
150 getElements(std::unique_lock<std::mutex>& rGuard)
const;
170 sal_Int32
addInterface(std::unique_lock<std::mutex>& rGuard,
171 const css::uno::Reference<ListenerT>& rxIFace);
182 const css::uno::Reference<ListenerT>& rxIFace);
189 const css::lang::EventObject& rEvt);
195 void clear(::std::unique_lock<::std::mutex>& rGuard);
209 template <
typename FuncT>
210 inline void forEach(std::unique_lock<std::mutex>& rGuard, FuncT
const& func)
const;
234 template <
typename EventT>
235 inline void notifyEach(std::unique_lock<std::mutex>& rGuard,
236 void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&),
237 const EventT& Event)
const;
265 typedef void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&);
277 void operator()(
const css::uno::Reference<ListenerT>& listener)
const
291template <
typename FuncT>
293 FuncT
const& func)
const
295 assert(rGuard.owns_lock());
306 auto xListener = iter.
next();
311 catch (css::lang::DisposedException
const& exc)
313 if (exc.Context == xListener)
324template <
class ListenerT>
325template <
typename EventT>
327 std::unique_lock<std::mutex>& rGuard,
328 void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&),
const EventT& Event)
const
330 forEach<NotifySingleListener<EventT>>(rGuard,
334template <
class ListenerT>
338 assert(rGuard.owns_lock());
343template <
class ListenerT>
344std::vector<css::uno::Reference<ListenerT>>
347 assert(rGuard.owns_lock());
352template <
class ListenerT>
355 const css::uno::Reference<ListenerT>& rListener)
357 assert(rGuard.owns_lock());
359 assert(rListener.is());
360 maData->push_back(rListener);
364template <
class ListenerT>
366 std::unique_lock<std::mutex>& rGuard,
const css::uno::Reference<ListenerT>& rListener)
368 assert(rGuard.owns_lock());
370 assert(rListener.is());
374 [&rListener](
const css::uno::Reference<css::uno::XInterface>& rItem) {
375 return rItem.get() == rListener.get();
380 it = std::find(
maData->begin(),
maData->end(), rListener);
388template <
class ListenerT>
390 const css::lang::EventObject& rEvt)
398 while (aIt.hasMoreElements())
402 aIt.next()->disposing(rEvt);
404 catch (css::uno::RuntimeException&)
417template <
class ListenerT>
420 assert(rGuard.owns_lock());
NotificationMethod const m_pMethod
NotifySingleListener(NotificationMethod method, const EventT &event)
typedef void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &)
void operator()(const css::uno::Reference< ListenerT > &listener) const
A container of interfaces.
std::vector< css::uno::Reference< ListenerT > > getElements(std::unique_lock< std::mutex > &rGuard) const
Return all interfaces added to this container.
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event) const
Calls a UNO listener method for each contained listener.
void forEach(std::unique_lock< std::mutex > &rGuard, FuncT const &func) const
Executes a functor for each contained listener of specified type, e.g.
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
Return the number of Elements in the container.
OInterfaceContainerHelper4(OInterfaceContainerHelper4 &&)=default
OInterfaceContainerHelper4 & operator=(const OInterfaceContainerHelper4 &)=delete
static o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > & DEFAULT()
OInterfaceContainerHelper4(const OInterfaceContainerHelper4 &)=delete
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Inserts an element into the container.
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
OInterfaceContainerHelper4 & operator=(OInterfaceContainerHelper4 &&)=default
o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > maData
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Removes an element from the container.
void clear(::std::unique_lock<::std::mutex > &rGuard)
Clears the container without calling disposing().
OInterfaceContainerHelper4()
This is the iterator of an OInterfaceContainerHelper4.
OInterfaceIteratorHelper4(std::unique_lock< std::mutex > &rGuard, OInterfaceContainerHelper4< ListenerT > &rCont_)
Create an iterator over the elements of the container.
OInterfaceIteratorHelper4 & operator=(const OInterfaceIteratorHelper4 &)=delete
void remove(::std::unique_lock<::std::mutex > &rGuard)
Removes the current element (the last one returned by next()) from the underlying container.
o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > maData
OInterfaceIteratorHelper4(const OInterfaceIteratorHelper4 &)=delete
bool hasMoreElements() const
Return true, if there are more elements in the iterator.
OInterfaceContainerHelper4< ListenerT > & rCont
css::uno::Reference< ListenerT > const & next()
Return the next element of the iterator.
value_type & make_unique()
std::vector< sal_Int8, boost::noinit_adaptor< std::allocator< sal_Int8 > > > maData
This is a straight copy of the include/comphelper/compbase.hxx file, copied here because it is nigh i...