37 return iNamed.isValid() ? iNamed->name() : s_unknown ;
42 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
43 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
45 #define DEBMSG ON_DEBUG debug()
46 #define VERMSG ON_VERBOSE verbose()
53 , m_currentIncidentType(0)
55 , m_timerLock ( false )
109 long prio,
bool rethrow,
bool singleShot)
112 boost::recursive_mutex::scoped_lock
lock(m_listenerMapMutex);
115 if( type ==
"" ) ltype =
"ALL";
119 if( itMap == m_listenerMap.end() ) {
128 ListenerList::iterator itlist;
129 for( itlist = llist->
begin(); itlist != llist->
end(); itlist++ ) {
130 if( (*itlist).priority < prio ) {
136 DEBMSG <<
"Adding [" << type <<
"] listener '" << getListenerName(lis)
137 <<
"' with priority " << prio <<
endmsg;
147 boost::recursive_mutex::scoped_lock
lock(m_listenerMapMutex);
152 for ( itmap = m_listenerMap.begin(); itmap != m_listenerMap.end();)
159 removeListener( lis, (*itmap_old).first );
165 if( itmap == m_listenerMap.end() ) {
171 ListenerList::iterator itlist;
172 bool justScheduleForRemoval = ( 0!= m_currentIncidentType )
173 && (type == *m_currentIncidentType);
178 for( itlist = llist->
begin(); itlist != llist->
end(); ) {
179 if( (*itlist).iListener == lis || lis == 0) {
180 if (justScheduleForRemoval) {
181 (itlist++)->singleShot =
true;
184 DEBMSG <<
"Removing [" << type <<
"] listener '"
185 << getListenerName(lis) <<
"'" <<
endmsg;
186 itlist = llist->
erase(itlist);
193 if( llist->
size() == 0) {
195 m_listenerMap.
erase(itmap);
204 struct listenerToBeRemoved{
216 boost::recursive_mutex::scoped_lock
lock(m_listenerMapMutex);
230 if ( m_listenerMap.end() == itmap )
return;
234 m_currentIncidentType = &(incident.
type());
237 ListenerList::iterator itlist;
238 bool weHaveToCleanUp =
false;
241 for( itlist = llist->
begin(); itlist != llist->
end(); itlist++ )
244 VERMSG <<
"Calling '" << getListenerName((*itlist).iListener)
245 <<
"' for incident [" << incident.
type() <<
"]" <<
endmsg;
249 (*itlist).iListener->handle(incident);
252 error() <<
"Exception with tag=" << exc.
tag() <<
" is caught"
253 " handling incident" << m_currentIncidentType <<
endmsg;
255 if ( (*itlist).rethrow ) {
throw (exc); }
258 error() <<
"Standard std::exception is caught"
259 " handling incident" << m_currentIncidentType <<
endmsg;
261 if ( (*itlist).rethrow ) {
throw (exc); }
264 error() <<
"UNKNOWN Exception is caught"
265 " handling incident" << m_currentIncidentType <<
endmsg;
266 if ( (*itlist).rethrow ) {
throw; }
269 weHaveToCleanUp |= itlist->singleShot;
271 if (weHaveToCleanUp) {
273 llist->
remove_if( listenerToBeRemoved() );
275 if( llist->
size() == 0) {
277 m_listenerMap.
erase(itmap);
281 m_currentIncidentType = 0;
292 if ( incident.
type() !=
"ALL" ){