23#include <com/sun/star/lang/EventObject.hpp>
43template <
class listener,
class key,
class equalImpl = std::equal_to<key>>
64 ::osl::MutexGuard aGuard(
rMutex);
65 std::vector<key> aInterfaceTypes;
66 aInterfaceTypes.reserve(
m_aMap.size());
67 for (
const auto& rPair :
m_aMap)
69 if (rPair.second->getLength())
71 aInterfaceTypes.push_back(rPair.first);
72 return aInterfaceTypes;
77 ::osl::MutexGuard aGuard(
rMutex);
78 for (
const auto& rPair :
m_aMap)
80 if (rPair.second->getLength())
93 ::osl::MutexGuard aGuard(
rMutex);
95 auto iter =
find(rKey);
97 return (*iter).second.get();
119 inline sal_Int32
addInterface(
const key& rKey,
const css::uno::Reference<listener>& rListener)
121 ::osl::MutexGuard aGuard(
rMutex);
122 auto iter =
find(rKey);
126 m_aMap.emplace_back(rKey, pLC);
127 return pLC->addInterface(rListener);
130 return (*iter).second->addInterface(rListener);
144 const css::uno::Reference<listener>& rListener)
146 ::osl::MutexGuard aGuard(
rMutex);
149 auto iter =
find(rKey);
152 return (*iter).second->removeInterface(rListener);
168 ::osl::MutexGuard aGuard(
rMutex);
169 tempMap = std::move(
m_aMap);
172 for (
auto& rPair : tempMap)
173 rPair.second->disposeAndClear(rEvt);
181 ::osl::MutexGuard aGuard(
rMutex);
183 for (
const auto& rPair :
m_aMap)
184 rPair.second->clear();
190 typedef ::std::vector<std::pair<key, std::unique_ptr<OInterfaceContainerHelper3<listener>>>>
195 typename InterfaceMap::const_iterator
find(
const key& rKey)
const
197 auto iter =
m_aMap.begin();
203 if (
equal(iter->first, rKey))
A container of interfaces.
A helper class to store interface references of different types.
sal_Int32 addInterface(const key &rKey, const css::uno::Reference< listener > &rListener)
Inserts an element into the container with the specified key.
std::vector< key > getContainedTypes() const
Return all id's under which at least one interface is added.
OMultiTypeInterfaceContainerHelperVar3(::osl::Mutex &rMutex_)
Create a container of interface containers.
void clear()
Remove all elements of all containers.
::std::vector< std::pair< key, std::unique_ptr< OInterfaceContainerHelper3< listener > > > > InterfaceMap
OMultiTypeInterfaceContainerHelperVar3(const OMultiTypeInterfaceContainerHelperVar3 &)=delete
sal_Int32 removeInterface(const key &rKey, const css::uno::Reference< listener > &rListener)
Removes an element from the container with the specified key.
bool hasContainedTypes() const
OMultiTypeInterfaceContainerHelperVar3 & operator=(const OMultiTypeInterfaceContainerHelperVar3 &)=delete
InterfaceMap::const_iterator find(const key &rKey) const
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all references in the container, that support XEventListener.
OInterfaceContainerHelper3< listener > * getContainer(const key &rKey) const
Return the container created under this key.