36 return iNamed.isValid() ? iNamed->name() : s_unknown ;
41 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
42 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
44 #define DEBMSG ON_DEBUG debug()
45 #define VERMSG ON_VERBOSE verbose()
52 , m_currentIncidentType(0)
54 , m_timerLock ( false )
108 long prio,
bool rethrow,
bool singleShot)
111 boost::recursive_mutex::scoped_lock
lock(m_listenerMapMutex);
114 if( type ==
"" ) ltype =
"ALL";
118 if( itMap == m_listenerMap.end() ) {
127 ListenerList::iterator itlist;
128 for( itlist = llist->
begin(); itlist != llist->
end(); itlist++ ) {
129 if( (*itlist).priority < prio ) {
135 DEBMSG <<
"Adding [" << type <<
"] listener '" << getListenerName(lis)
136 <<
"' with priority " << prio <<
endmsg;
146 boost::recursive_mutex::scoped_lock
lock(m_listenerMapMutex);
151 for ( itmap = m_listenerMap.begin(); itmap != m_listenerMap.end();)
158 removeListener( lis, (*itmap_old).first );
164 if( itmap == m_listenerMap.end() ) {
170 ListenerList::iterator itlist;
171 bool justScheduleForRemoval = ( 0!= m_currentIncidentType )
172 && (type == *m_currentIncidentType);
177 for( itlist = llist->
begin(); itlist != llist->
end(); ) {
178 if( (*itlist).iListener == lis || lis == 0) {
179 if (justScheduleForRemoval) {
180 (itlist++)->singleShot =
true;
183 DEBMSG <<
"Removing [" << type <<
"] listener '"
184 << getListenerName(lis) <<
"'" <<
endmsg;
185 itlist = llist->
erase(itlist);
192 if( llist->
size() == 0) {
194 m_listenerMap.
erase(itmap);
203 struct listenerToBeRemoved{
215 boost::recursive_mutex::scoped_lock
lock(m_listenerMapMutex);
229 if ( m_listenerMap.end() == itmap )
return;
233 m_currentIncidentType = &(incident.
type());
236 ListenerList::iterator itlist;
237 bool weHaveToCleanUp =
false;
240 for( itlist = llist->
begin(); itlist != llist->
end(); itlist++ )
243 VERMSG <<
"Calling '" << getListenerName((*itlist).iListener)
244 <<
"' for incident [" << incident.
type() <<
"]" <<
endmsg;
248 (*itlist).iListener->handle(incident);
251 error() <<
"Exception with tag=" << exc.
tag() <<
" is caught"
252 " handling incident" << m_currentIncidentType <<
endmsg;
254 if ( (*itlist).rethrow ) {
throw (exc); }
257 error() <<
"Standard std::exception is caught"
258 " handling incident" << m_currentIncidentType <<
endmsg;
260 if ( (*itlist).rethrow ) {
throw (exc); }
263 error() <<
"UNKNOWN Exception is caught"
264 " handling incident" << m_currentIncidentType <<
endmsg;
265 if ( (*itlist).rethrow ) {
throw; }
268 weHaveToCleanUp |= itlist->singleShot;
270 if (weHaveToCleanUp) {
272 llist->
remove_if( listenerToBeRemoved() );
274 if( llist->
size() == 0) {
276 m_listenerMap.
erase(itmap);
280 m_currentIncidentType = 0;
291 if ( incident.
type() !=
"ALL" ){
306 if (type ==
"") { ltype =
"ALL"; }
else { ltype =
type; }
314 for (itlist = itr->second->begin(); itlist != itr->second->end(); ++itlist) {