本文整理汇总了C++中ListenerList::remove_if方法的典型用法代码示例。如果您正苦于以下问题:C++ ListenerList::remove_if方法的具体用法?C++ ListenerList::remove_if怎么用?C++ ListenerList::remove_if使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListenerList
的用法示例。
在下文中一共展示了ListenerList::remove_if方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
// ============================================================================
void IncidentSvc::i_fireIncident
( const Incident& incident ,
const std::string& listenerType )
{
boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
// Special case: FailInputFile incident must set the application return code
if (incident.type() == IncidentType::FailInputFile
|| incident.type() == IncidentType::CorruptedInputFile) {
SmartIF<IProperty> appmgr(serviceLocator());
if (incident.type() == IncidentType::FailInputFile)
// Set the return code to Gaudi::ReturnCode::FailInput (2)
Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::FailInput).ignore();
else
Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::CorruptedInput).ignore();
}
ListenerMap::iterator itmap = m_listenerMap.find( listenerType );
if ( m_listenerMap.end() == itmap ) return;
// setting this pointer will avoid that a call to removeListener() during
// the loop triggers a segfault
m_currentIncidentType = &(incident.type());
ListenerList* llist = (*itmap).second;
ListenerList::iterator itlist;
bool weHaveToCleanUp = false;
// loop over all registered Listeners
for( itlist = llist->begin(); itlist != llist->end(); itlist++ )
{
VERMSG << "Calling '" << getListenerName((*itlist).iListener)
<< "' for incident [" << incident.type() << "]" << endmsg;
// handle exceptions if they occur
try {
(*itlist).iListener->handle(incident);
}
catch( const GaudiException& exc ) {
error() << "Exception with tag=" << exc.tag() << " is caught"
" handling incident" << m_currentIncidentType << endmsg;
error() << exc << endmsg;
if ( (*itlist).rethrow ) { throw (exc); }
}
catch( const std::exception& exc ) {
error() << "Standard std::exception is caught"
" handling incident" << m_currentIncidentType << endmsg;
error() << exc.what() << endmsg;
if ( (*itlist).rethrow ) { throw (exc); }
}
catch(...) {
error() << "UNKNOWN Exception is caught"
" handling incident" << m_currentIncidentType << endmsg;
if ( (*itlist).rethrow ) { throw; }
}
// check if at least one of the listeners is a one-shot
weHaveToCleanUp |= itlist->singleShot;
}
if (weHaveToCleanUp) {
// remove all the listeners that need to be removed from the list
llist->remove_if( listenerToBeRemoved() );
// if the list is empty, we can remove it
if( llist->size() == 0) {
delete llist;
m_listenerMap.erase(itmap);
}
}
m_currentIncidentType = 0;
}