21#include <com/sun/star/lang/EventObject.hpp>
38template <
class key,
class listener,
class equalImpl = std::equal_to<key>>
48 assert(rGuard.owns_lock());
49 std::vector<key> aInterfaceTypes;
50 aInterfaceTypes.reserve(
m_aMap.size());
51 for (
const auto& rPair :
m_aMap)
53 if (rPair.second->getLength(rGuard))
55 aInterfaceTypes.push_back(rPair.first);
56 return aInterfaceTypes;
60 assert(rGuard.owns_lock());
61 for (
const auto& rPair :
m_aMap)
63 if (rPair.second->getLength(rGuard))
74 const key& rKey)
const
76 auto iter =
find(rGuard, rKey);
78 return (*iter).second.get();
97 inline sal_Int32
addInterface(::std::unique_lock<::std::mutex>& rGuard,
const key& rKey,
98 const css::uno::Reference<listener>& rListener)
100 auto iter =
find(rGuard, rKey);
104 m_aMap.emplace_back(rKey, pLC);
105 return pLC->addInterface(rGuard, rListener);
108 return (*iter).second->addInterface(rGuard, rListener);
119 inline sal_Int32
removeInterface(::std::unique_lock<::std::mutex>& rGuard,
const key& rKey,
120 const css::uno::Reference<listener>& rListener)
123 auto iter =
find(rGuard, rKey);
126 return (*iter).second->removeInterface(rGuard, rListener);
136 const css::lang::EventObject& rEvt)
138 assert(rGuard.owns_lock());
142 tempMap = std::move(
m_aMap);
152 std::unique_lock tempGuard(tempMutex);
153 for (
auto& rPair : tempMap)
160 aIt.
next()->disposing(rEvt);
162 catch (css::uno::RuntimeException&)
174 inline void clear(std::unique_lock<std::mutex>& rGuard)
176 assert(rGuard.owns_lock());
178 for (
const auto& rPair :
m_aMap)
179 rPair.second->clear();
184 typedef ::std::vector<std::pair<key, std::unique_ptr<OInterfaceContainerHelper4<listener>>>>
187 typename InterfaceMap::const_iterator
find(std::unique_lock<std::mutex>& rGuard,
188 const key& rKey)
const
190 assert(rGuard.owns_lock());
192 auto iter =
m_aMap.begin();
197 if (
equal(iter->first, rKey))
A container of interfaces.
This is the iterator of an OInterfaceContainerHelper4.
bool hasMoreElements() const
Return true, if there are more elements in the iterator.
css::uno::Reference< ListenerT > const & next()
Return the next element of the iterator.
A helper class to store interface references of different types.
::std::vector< std::pair< key, std::unique_ptr< OInterfaceContainerHelper4< listener > > > > InterfaceMap
OMultiTypeInterfaceContainerHelperVar4 & operator=(const OMultiTypeInterfaceContainerHelperVar4 &)=delete
void clear(std::unique_lock< std::mutex > &rGuard)
Remove all elements of all containers.
sal_Int32 removeInterface(::std::unique_lock<::std::mutex > &rGuard, const key &rKey, const css::uno::Reference< listener > &rListener)
Removes an element from the container with the specified key.
OMultiTypeInterfaceContainerHelperVar4(const OMultiTypeInterfaceContainerHelperVar4 &)=delete
std::vector< key > getContainedTypes(std::unique_lock< std::mutex > &rGuard) const
Return all id's under which at least one interface is added.
bool hasContainedTypes(std::unique_lock< std::mutex > &rGuard) const
OMultiTypeInterfaceContainerHelperVar4()
sal_Int32 addInterface(::std::unique_lock<::std::mutex > &rGuard, const key &rKey, const css::uno::Reference< listener > &rListener)
Inserts an element into the container with the specified key.
void disposeAndClear(std::unique_lock< std::mutex > &rGuard, const css::lang::EventObject &rEvt)
Call disposing on all references in the container, that support XEventListener.
InterfaceMap::const_iterator find(std::unique_lock< std::mutex > &rGuard, const key &rKey) const
OInterfaceContainerHelper4< listener > * getContainer(std::unique_lock< std::mutex > &rGuard, const key &rKey) const
Return the container created under this key.