23#include <com/sun/star/lang/EventObject.hpp>
24#include <com/sun/star/lang/DisposedException.hpp>
37template <
class ListenerT>
class OInterfaceContainerHelper4;
70 assert(rGuard.owns_lock());
79 css::uno::Reference<ListenerT>
const&
next();
88 void remove(::std::unique_lock<::std::mutex>& rGuard);
101template <
class ListenerT>
105 return (*std::as_const(
maData))[nRemain];
108template <
class ListenerT>
111 rCont.removeInterface(rGuard, (*std::as_const(
maData))[nRemain]);
137 sal_Int32
getLength(std::unique_lock<std::mutex>& rGuard)
const;
144 std::vector<css::uno::Reference<ListenerT>>
166 const css::uno::Reference<ListenerT>& rxIFace);
177 const css::uno::Reference<ListenerT>& rxIFace);
184 const css::lang::EventObject& rEvt);
190 void clear(::std::unique_lock<::std::mutex>& rGuard);
204 template <
typename FuncT>
205 inline void forEach(std::unique_lock<std::mutex>& rGuard, FuncT
const& func)
const;
229 template <
typename EventT>
231 void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&),
232 const EventT& Event)
const;
260 typedef void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&);
272 void operator()(
const css::uno::Reference<ListenerT>& listener)
const
286template <
typename FuncT>
288 FuncT
const& func)
const
290 assert(rGuard.owns_lock());
301 auto xListener = iter.
next();
306 catch (css::lang::DisposedException
const& exc)
308 if (exc.Context == xListener)
319template <
class ListenerT>
320template <
typename EventT>
322 std::unique_lock<std::mutex>& rGuard,
323 void (SAL_CALL ListenerT::*NotificationMethod)(
const EventT&),
const EventT& Event)
const
325 forEach<NotifySingleListener<EventT>>(rGuard,
329template <
class ListenerT>
333 assert(rGuard.owns_lock());
338template <
class ListenerT>
339std::vector<css::uno::Reference<ListenerT>>
342 assert(rGuard.owns_lock());
347template <
class ListenerT>
350 const css::uno::Reference<ListenerT>& rListener)
352 assert(rGuard.owns_lock());
354 assert(rListener.is());
355 maData->push_back(rListener);
359template <
class ListenerT>
361 std::unique_lock<std::mutex>& rGuard,
const css::uno::Reference<ListenerT>& rListener)
363 assert(rGuard.owns_lock());
365 assert(rListener.is());
369 [&rListener](
const css::uno::Reference<css::uno::XInterface>& rItem) {
370 return rItem.get() == rListener.get();
383template <
class ListenerT>
385 const css::lang::EventObject& rEvt)
393 while (aIt.hasMoreElements())
397 aIt.next()->disposing(rEvt);
399 catch (css::uno::RuntimeException&)
412template <
class ListenerT>
415 assert(rGuard.owns_lock());
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.
void forEach(std::unique_lock< std::mutex > &rGuard, FuncT const &func) const
Executes a functor for each contained listener of specified type, e.g.
OInterfaceContainerHelper4(OInterfaceContainerHelper4 &&)=default
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
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
Inserts an element into the 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.
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()
OInterfaceContainerHelper4 & operator=(OInterfaceContainerHelper4 &&)=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 > &rGuard, OInterfaceContainerHelper4< ListenerT > &rCont_)
Create an iterator over the elements of the container.
value_type & make_unique()
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