23#include <com/sun/star/lang/EventObject.hpp>
24#include <com/sun/star/lang/DisposedException.hpp>
37template <
class ListenerT>
class OInterfaceContainerHelper4;
77 css::uno::Reference<ListenerT>
const&
next();
86 void remove(::std::unique_lock<::std::mutex>& rGuard);
99template <
class ListenerT>
103 return (*std::as_const(
maData))[nRemain];
106template <
class ListenerT>
109 rCont.removeInterface(rGuard, (*std::as_const(
maData))[nRemain]);
135 sal_Int32
getLength(std::unique_lock<std::mutex>& rGuard)
const;
142 std::vector<css::uno::Reference<ListenerT>>
164 const css::uno::Reference<ListenerT>& rxIFace);
175 const css::uno::Reference<ListenerT>& rxIFace);
182 const css::lang::EventObject& rEvt);
188 void clear(::std::unique_lock<::std::mutex>& rGuard);
202 template <
typename FuncT>
203 inline void forEach(std::unique_lock<std::mutex>& rGuard, FuncT
const& func);
227 template <
typename EventT>
229 void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&),
230 const EventT& Event);
254 typedef void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&);
266 void operator()(
const css::uno::Reference<ListenerT>& listener)
const
280template <
typename FuncT>
293 auto xListener = iter.
next();
298 catch (css::lang::DisposedException
const& exc)
300 if (exc.Context == xListener)
311template <
class ListenerT>
312template <
typename EventT>
314 std::unique_lock<std::mutex>& rGuard,
315 void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&),
const EventT& Event)
317 forEach<NotifySingleListener<EventT>>(rGuard,
321template <
class ListenerT>
328template <
class ListenerT>
329std::vector<css::uno::Reference<ListenerT>>
335template <
class ListenerT>
338 const css::uno::Reference<ListenerT>& rListener)
340 assert(rListener.is());
341 maData->push_back(rListener);
345template <
class ListenerT>
347 std::unique_lock<std::mutex>& ,
const css::uno::Reference<ListenerT>& rListener)
349 assert(rListener.is());
353 [&rListener](
const css::uno::Reference<css::uno::XInterface>& rItem) {
354 return rItem.get() == rListener.get();
367template <
class ListenerT>
369 const css::lang::EventObject& rEvt)
379 aIt.
next()->disposing(rEvt);
381 catch (css::uno::RuntimeException&)
390template <
class ListenerT>
NotificationMethod const m_pMethod
void operator()(const css::uno::Reference< ListenerT > &listener) const
NotifySingleListener(NotificationMethod method, const EventT &event)
typedef void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &)
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.
OInterfaceContainerHelper4 & operator=(const OInterfaceContainerHelper4 &)=delete
void notifyEach(std::unique_lock< std::mutex > &rGuard, void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
Calls a UNO listener method for each contained listener.
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Inserts an element into the container.
void forEach(std::unique_lock< std::mutex > &rGuard, FuncT const &func)
Executes a functor for each contained listener of specified type, e.g.
OInterfaceContainerHelper4()
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
void clear(::std::unique_lock<::std::mutex > &rGuard)
Clears the container without calling disposing().
OInterfaceContainerHelper4(const OInterfaceContainerHelper4 &)=delete
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
Return the number of Elements in the container.
static o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > & DEFAULT()
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Removes an element from the container.
o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > maData
This is the iterator of an OInterfaceContainerHelper4.
o3tl::cow_wrapper< std::vector< css::uno::Reference< ListenerT > >, o3tl::ThreadSafeRefCountingPolicy > maData
bool hasMoreElements() const
Return true, if there are more elements in the iterator.
OInterfaceContainerHelper4< ListenerT > & rCont
OInterfaceIteratorHelper4 & operator=(const OInterfaceIteratorHelper4 &)=delete
css::uno::Reference< ListenerT > const & next()
Return the next element of the iterator.
OInterfaceIteratorHelper4(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.
OInterfaceIteratorHelper4(std::unique_lock< std::mutex > &, OInterfaceContainerHelper4< ListenerT > &rCont_)
Create an iterator over the elements of the container.
std::vector< sal_Int8, boost::noinit_adaptor< std::allocator< sal_Int8 > > > maData
static PropertyMapEntry const * find(const rtl::Reference< PropertySetInfo > &mxInfo, const OUString &aName) noexcept