void OInterfaceContainerHelper2::copyAndResetInUse()
{
OSL_ENSURE( bInUse, "OInterfaceContainerHelper2 not in use" ); if( bInUse )
{ // this should be the worst case. If an iterator is active // and a new Listener is added. if( bIsList )
aData.pAsVector = new std::vector< Reference< XInterface > >( *aData.pAsVector ); elseif( aData.pAsInterface )
aData.pAsInterface->acquire();
if( bIsList )
{ // It is not valid to compare the pointer directly, but it's faster. auto it = std::find_if(aData.pAsVector->begin(), aData.pAsVector->end(),
[&rListener](const css::uno::Reference<css::uno::XInterface>& rItem) { return rItem.get() == rListener.get(); });
// interface not found, use the correct compare method if (it == aData.pAsVector->end())
it = std::find(aData.pAsVector->begin(), aData.pAsVector->end(), rListener);
if (it != aData.pAsVector->end())
aData.pAsVector->erase(it);
void OInterfaceContainerHelper2::disposeAndClear( const EventObject & rEvt )
{
ClearableMutexGuard aGuard( rMutex );
OInterfaceIteratorHelper2 aIt( *this ); // Release container, in case new entries come while disposing
OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper2 not in use" ); if( !bIsList && aData.pAsInterface )
aData.pAsInterface->release(); // set the member to null, use the iterator to delete the values
aData.pAsInterface = nullptr;
bIsList = false;
bInUse = false;
aGuard.clear(); while( aIt.hasMoreElements() )
{ try
{
Reference<XEventListener > xLst( aIt.next(), UNO_QUERY ); if( xLst.is() )
xLst->disposing( rEvt );
} catch ( RuntimeException & )
{ // be robust, if e.g. a remote bridge has disposed already. // there is no way to delegate the error to the caller :o(.
}
}
}
void OInterfaceContainerHelper2::clear()
{
MutexGuard aGuard( rMutex ); // Release container, in case new entries come while disposing
OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper2 not in use" ); if (bInUse)
copyAndResetInUse(); if (bIsList) delete aData.pAsVector; elseif (aData.pAsInterface)
aData.pAsInterface->release();
aData.pAsInterface = nullptr;
bIsList = false;
}
std::vector< css::uno::Type > OMultiTypeInterfaceContainerHelper2::getContainedTypes() const
{
::osl::MutexGuard aGuard( rMutex );
std::vector< Type > aInterfaceTypes;
aInterfaceTypes.reserve( m_aMap.size() ); for (constauto& rItem : m_aMap)
{ // are interfaces added to this container? if( rItem.second->getLength() ) // yes, put the type in the array
aInterfaceTypes.push_back(rItem.first);
} return aInterfaceTypes;
}
// search container with id nUik auto iter = findType( rKey ); // container found? if( iter != m_aMap.end() ) return (*iter).second->removeInterface( rListener );
// no container with this id. Always return 0 return0;
}
t_type2ptr::size_type i = 0; for (constauto& rItem : m_aMap)
{
ppListenerContainers[i++] = rItem.second.get();
}
}
}
// create a copy, because do not fire event in a guarded section for( t_type2ptr::size_type i = 0; i < nSize; i++ )
{ if( ppListenerContainers[i] )
ppListenerContainers[i]->disposeAndClear( rEvt );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.