![]() |
|
|
Generated: 18 Jul 2008 |


Definition at line 27 of file CounterSvc.cpp.
Public Member Functions | ||||
| CounterSvc (const std::string &name, ISvcLocator *svcLoc) | ||||
| Standard Constructor. | ||||
| virtual | ~CounterSvc () | |||
| Standard destructor. | ||||
| virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvI) | |||
| Query interface. | ||||
| virtual StatusCode | finalize () | |||
| Finalization. | ||||
| virtual Counter * | get (const std::string &group, const std::string &name) const | |||
| Access an existing counter object. | ||||
| virtual ICounterSvc::Counters | get (const std::string &group) const | |||
| get all counters form the given group: | ||||
| virtual StatusCode | create (const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) | |||
| Create a new counter object. | ||||
| virtual CountObject | create (const std::string &group, const std::string &name, longlong initial_value=0) | |||
| Create a new counter object. | ||||
| virtual StatusCode | remove (const std::string &group, const std::string &name) | |||
| Remove a counter object. | ||||
| virtual StatusCode | remove (const std::string &group) | |||
| Remove all counters of a givem group. | ||||
| virtual StatusCode | remove () | |||
| Remove all known counter objects. | ||||
| virtual StatusCode | print (const std::string &group, const std::string &name, Printout &printer) const | |||
| Print counter value. | ||||
| virtual StatusCode | print (const std::string &group, Printout &printer) const | |||
| If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access. | ||||
| virtual StatusCode | print (const Counter *pCounter, Printout &printer) const | |||
| Print counter value. | ||||
| virtual StatusCode | print (const CountObject &pCounter, Printout &printer) const | |||
| Print counter value. | ||||
| virtual StatusCode | print (Printout &printer) const | |||
| ||||
| virtual StatusCode | defaultPrintout (MsgStream &log, const Counter *pCounter) const | |||
| Default Printout for counters. | ||||
| void | print () const | |||
| "standard" printout a'la GaudiCommon | ||||
Private Types | ||||
| typedef GaudiUtils::HashMap< std::string, Counter * > | NameMap | |||
| typedef GaudiUtils::HashMap< std::string, NameMap > | CountMap | |||
Private Member Functions | ||||
| std::pair< std::string, std::string > | _find (const Counter *c) const | |||
| size_t | num () const | |||
Private Attributes | ||||
| CountMap | m_counts | |||
| the actual map of counters | ||||
| bool | m_print | |||
| boolean flag to print statistics | ||||
| std::string | m_header | |||
| the header row | ||||
| std::string | m_format1 | |||
| format for regular statistical printout rows | ||||
| std::string | m_format2 | |||
| format for "efficiency" statistical printout rows | ||||
| bool | m_useEffFormat | |||
| flag to use the special "efficiency" format | ||||
typedef GaudiUtils::HashMap<std::string,Counter*> CounterSvc::NameMap [private] |
Definition at line 234 of file CounterSvc.cpp.
typedef GaudiUtils::HashMap<std::string,NameMap> CounterSvc::CountMap [private] |
Definition at line 235 of file CounterSvc.cpp.
| CounterSvc::CounterSvc | ( | const std::string & | name, | |
| ISvcLocator * | svcLoc | |||
| ) | [inline] |
Standard Constructor.
Definition at line 33 of file CounterSvc.cpp.
References Service::declareProperty(), m_format1, m_format2, m_header, m_print, and m_useEffFormat.
00035 : Service(name, svcLoc) 00036 , m_counts () 00037 , m_print ( true ) 00038 // 00039 // the header row 00040 , m_header ( " Counter :: Group | # | sum | mean/eff^* | rms/err^* | min | max |") 00041 // format for regular statistical printout rows 00042 , m_format1 ( " %|15.15s|%|-15.15s|%|32t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" ) 00043 // format for "efficiency" statistical printout rows 00044 , m_format2 ( "*%|15.15s|%|-15.15s|%|32t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" ) 00045 // flag to use the special "efficiency" format 00046 , m_useEffFormat ( true ) 00047 // 00048 { 00049 declareProperty ("PrintStat" , m_print ) ; 00050 // 00051 declareProperty 00052 ( "StatTableHeader" , m_header , 00053 "The header row for the output Stat-table" ) ; 00054 // 00055 declareProperty 00056 ( "RegularRowFormat" , m_format1 , 00057 "The format for the regular row in the output Stat-table" ) ; 00058 // 00059 declareProperty 00060 ( "EfficiencyRowFormat" , m_format2 , 00061 "The format for the regular row in the outptu Stat-table" ) ; 00062 // 00063 declareProperty 00064 ( "UseEfficiencyRowFormat" , m_useEffFormat , 00065 "Use the special format for printout of efficiency counters" ) ; 00066 }
| virtual CounterSvc::~CounterSvc | ( | ) | [inline, virtual] |
Standard destructor.
Definition at line 68 of file CounterSvc.cpp.
References StatusCode::ignore(), and remove().
| virtual StatusCode CounterSvc::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvI | |||
| ) | [inline, virtual] |
Query interface.
Reimplemented from Service.
Definition at line 71 of file CounterSvc.cpp.
References Service::addRef(), StatusCode::FAILURE, ICounterSvc::interfaceID(), Service::queryInterface(), and StatusCode::SUCCESS.
00072 { 00073 // valid placeholder? 00074 if ( 0 == ppvI ) { return StatusCode::FAILURE ; } // RETURN 00075 if ( ICounterSvc::interfaceID() == riid ) 00076 { 00077 *ppvI = static_cast<ICounterSvc*>(this); 00078 addRef(); // NB! : inrement the reference count! 00079 return StatusCode::SUCCESS; // RETURN 00080 } 00081 // Interface is not directly availible: try out a base class 00082 return Service::queryInterface( riid, ppvI ); 00083 }
| virtual StatusCode CounterSvc::finalize | ( | void | ) | [inline, virtual] |
Finalization.
< finalize the base class
Reimplemented from Service.
Definition at line 85 of file CounterSvc.cpp.
References MSG::DEBUG, Service::finalize(), StatusCode::ignore(), m_print, Service::outputLevel(), print(), and remove().
00086 { 00087 if ( outputLevel() <= MSG::DEBUG || m_print ) { print () ; } 00088 remove().ignore() ; 00089 // finalize the base class 00090 return Service::finalize() ; 00091 }
| CounterSvc::Counter * CounterSvc::get | ( | const std::string & | group, | |
| const std::string & | name | |||
| ) | const [virtual] |
Access an existing counter object.
| group | [IN] Hint for smart printing | |
| name | [IN] Counter name |
Implements ICounterSvc.
Definition at line 257 of file CounterSvc.cpp.
00259 { 00260 CountMap::const_iterator i = m_counts.find ( grp ) ; 00261 if ( m_counts.end() == i ) { return 0 ; } // RETURN 00262 NameMap::const_iterator j = i->second.find ( nam ) ; 00263 if ( i->second.end() == j ) { return 0 ; } // RETURN 00264 return j->second ; // RETURN 00265 }
| ICounterSvc::Counters CounterSvc::get | ( | const std::string & | group | ) | const [virtual] |
get all counters form the given group:
Implements ICounterSvc.
Definition at line 269 of file CounterSvc.cpp.
References GaudiUtils::Map< K, T, M >::end(), GaudiUtils::Map< K, T, M >::find(), m_counts, and std::vector< _Tp, _Alloc >::push_back().
00270 { 00271 ICounterSvc::Counters result ; 00272 CountMap::const_iterator i = m_counts.find ( group ) ; 00273 if ( m_counts.end() == i ) { return result ; } // RETURN 00274 for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00275 { result.push_back( CountObject ( j->second, i->first , j->first ) ) ; } 00276 return result ; 00277 }
| StatusCode CounterSvc::create | ( | const std::string & | group, | |
| const std::string & | name, | |||
| longlong | initial_value, | |||
| Counter *& | refpCounter | |||
| ) | [virtual] |
Create a new counter object.
If the counter object exists already the existing object is returned. In this event the return code is COUNTER_EXISTS. The ownership of the actual counter stays with the service.
| group | [IN] Hint for smart printing | |
| name | [IN] Counter name | |
| initial_value | [IN] Initial counter value | |
| refpCounter | [OUT] Reference to store pointer to counter. |
Implements ICounterSvc.
Definition at line 282 of file CounterSvc.cpp.
References StatEntity::addFlag(), get(), std::make_pair(), and StatusCode::SUCCESS.
00286 { 00287 // try to find existing counter: 00288 refpCounter = get ( grp , nam ) ; 00289 if ( 0 != refpCounter ) { return COUNTER_EXISTS ; } // RETURN 00290 // create the new counter 00291 Counter* newc = new Counter() ; 00292 refpCounter = newc ; 00293 if ( 0 != initial_value ) { 00294 refpCounter->addFlag ( static_cast<double>(initial_value) ) ; 00295 } 00296 // find a proper group 00297 CountMap::iterator i = m_counts.find ( grp ) ; 00298 // (create a group if needed) 00299 if ( m_counts.end() == i ) 00300 { i = m_counts.insert ( std::make_pair ( grp , NameMap() ) ).first ; } 00301 // insert new counter with priper name into proper group: 00302 i->second.insert( std::make_pair( nam , newc ) ).first ; 00303 return StatusCode::SUCCESS ; // RETURN 00304 }
| CounterSvc::CountObject CounterSvc::create | ( | const std::string & | group, | |
| const std::string & | name, | |||
| longlong | initial_value = 0 | |||
| ) | [virtual] |
Create a new counter object.
If the counter object exists already, a std::runtime_error exception is thrown. The ownership of the actual counter stays with the service.
| group | [IN] Hint for smart printing | |
| name | [IN] Counter name | |
| initial_value | [IN] Initial counter value | |
| refpCounter | [OUT] Reference to store pointer to counter. |
Implements ICounterSvc.
Definition at line 309 of file CounterSvc.cpp.
References StatusCode::isSuccess(), and name.
00312 { 00313 Counter* p = 0; 00314 StatusCode sc = create ( group, name, initial_value, p ) ; 00315 if ( sc.isSuccess() && 0 != p ) { return CountObject ( p , group , name ) ; } 00316 throw std::runtime_error("CounterSvc::Counter('"+group+"::"+name+"') exists already!"); 00317 }
| StatusCode CounterSvc::remove | ( | const std::string & | group, | |
| const std::string & | name | |||
| ) | [virtual] |
Remove a counter object.
If the counter object does not exists, the return code is COUNTER_NOT_PRESENT. The counter may not be used anymore after this call.
| group | [IN] Hint for smart printing | |
| name | [IN] Counter name | |
| initial_value | [IN] Initial counter value | |
| refpCounter | [OUT] Reference to store pointer to counter. |
Implements ICounterSvc.
Definition at line 322 of file CounterSvc.cpp.
References StatusCode::SUCCESS.
00324 { 00325 CountMap::iterator i = m_counts.find ( grp ) ; 00326 if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } // RETURN 00327 NameMap::iterator j = i->second.find ( nam ) ; 00328 if ( i->second.end() == j ) { return COUNTER_NOT_PRESENT ; } // RETURN 00329 delete j->second ; 00330 i->second.erase ( j ) ; 00331 return StatusCode::SUCCESS ; 00332 }
| StatusCode CounterSvc::remove | ( | const std::string & | group | ) | [virtual] |
Remove all counters of a givem group.
If no such counter exists the return code is COUNTER_NOT_PRESENT
| group | [IN] Hint for smart printing |
Implements ICounterSvc.
Definition at line 336 of file CounterSvc.cpp.
References ICounterSvc::COUNTER_NOT_PRESENT, GaudiUtils::Map< K, T, M >::end(), GaudiUtils::Map< K, T, M >::find(), m_counts, and StatusCode::SUCCESS.
00337 { 00338 CountMap::iterator i = m_counts.find ( grp ) ; 00339 if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } // RETURN 00340 for ( NameMap::iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00341 { delete j->second ; } 00342 i->second.clear() ; 00343 return StatusCode::SUCCESS ; 00344 }
| StatusCode CounterSvc::remove | ( | ) | [virtual] |
Remove all known counter objects.
Definition at line 348 of file CounterSvc.cpp.
References GaudiUtils::Map< K, T, M >::begin(), GaudiUtils::Map< K, T, M >::clear(), GaudiUtils::Map< K, T, M >::end(), StatusCode::ignore(), m_counts, and StatusCode::SUCCESS.
Referenced by finalize(), and ~CounterSvc().
00349 { 00350 // remove group by group 00351 for ( CountMap::iterator i = m_counts.begin() ; m_counts.end() != i ; ++i ) 00352 { remove ( i->first ).ignore () ; } 00353 m_counts.clear() ; 00354 return StatusCode::SUCCESS; 00355 }
| StatusCode CounterSvc::print | ( | const std::string & | group, | |
| const std::string & | name, | |||
| Printout & | printer | |||
| ) | const [virtual] |
Print counter value.
| group | [IN] Hint for smart printing | |
| name | [IN] Counter name | |
| printer | [IN] Print actor |
Definition at line 360 of file CounterSvc.cpp.
References c, get(), and name.
00363 { 00364 const Counter* c = get( grp , nam ) ; 00365 if ( 0 == c ) { return COUNTER_NOT_PRESENT ; } // RETURN 00366 // create the stream and use it! 00367 MsgStream log ( msgSvc() , name() ) ; 00368 return printer ( log , c ) ; 00369 }
| StatusCode CounterSvc::print | ( | const std::string & | group, | |
| Printout & | printer | |||
| ) | const [virtual] |
If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access.
| group | [IN] Hint for smart printing | |
| printer | [IN] Print actor |
Definition at line 374 of file CounterSvc.cpp.
References name, and StatusCode::SUCCESS.
00376 { 00377 CountMap::const_iterator i = m_counts.find ( grp ) ; 00378 if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } 00379 MsgStream log(msgSvc(), name()); 00380 for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00381 { printer ( log , j->second ).ignore() ; } 00382 // 00383 return StatusCode::SUCCESS; // RETURN 00384 }
| StatusCode CounterSvc::print | ( | const Counter * | pCounter, | |
| Printout & | printer | |||
| ) | const [virtual] |
Print counter value.
| pCounter | [IN] Pointer to Counter object | |
| printer | [IN] Print actor |
Definition at line 389 of file CounterSvc.cpp.
References name.
| StatusCode CounterSvc::print | ( | const CountObject & | pCounter, | |
| Printout & | printer | |||
| ) | const [virtual] |
Print counter value.
| refCounter | [IN] Reference to CountObject object | |
| printer | [IN] Print actor |
Definition at line 399 of file CounterSvc.cpp.
References Stat::counter().
00401 { return print( refCounter.counter() , printer ) ; }
| StatusCode CounterSvc::print | ( | Printout & | printer | ) | const [virtual] |
| printer | [IN] Print actor |
Definition at line 405 of file CounterSvc.cpp.
References GaudiUtils::Map< K, T, M >::begin(), GaudiUtils::Map< K, T, M >::end(), m_counts, Service::msgSvc(), Service::name(), and StatusCode::SUCCESS.
00406 { 00407 MsgStream log ( msgSvc() , name() ) ; 00408 for( CountMap::const_iterator i = m_counts.begin(); i != m_counts.end(); ++i) 00409 { 00410 for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00411 { printer ( log , j->second ).ignore() ; } 00412 } 00413 return StatusCode::SUCCESS; 00414 }
| StatusCode CounterSvc::defaultPrintout | ( | MsgStream & | log, | |
| const Counter * | pCounter | |||
| ) | const [virtual] |
Default Printout for counters.
Implements ICounterSvc.
Definition at line 419 of file CounterSvc.cpp.
References MSG::ALWAYS, c, endreq(), StatusCode::FAILURE, std::pair< _T1, _T2 >::first, std::pair< _T1, _T2 >::second, and StatusCode::SUCCESS.
00421 { 00422 if ( 0 == c ) { return StatusCode::FAILURE ; } 00423 std::pair<std::string,std::string> p = _find ( c ) ; 00424 00425 log << MSG::ALWAYS 00426 << CountObject( const_cast<Counter*>(c) , p.first , p.second ) 00427 << endreq ; 00428 00429 return StatusCode::SUCCESS; 00430 }
| std::pair<std::string,std::string> CounterSvc::_find | ( | const Counter * | c | ) | const [inline, private] |
Definition at line 207 of file CounterSvc.cpp.
References GaudiUtils::Map< K, T, M >::begin(), c, GaudiUtils::Map< K, T, M >::end(), m_counts, and std::make_pair().
00208 { 00209 if ( 0 == c ) { return std::pair<std::string,std::string>() ; } 00210 for ( CountMap::const_iterator i = m_counts.begin() ; m_counts.end() != i ; ++i ) 00211 { 00212 for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00213 { if ( j->second == c ) { return std::make_pair( i->first , j->first ) ; } } 00214 } 00215 return std::pair<std::string,std::string>() ; 00216 }
| size_t CounterSvc::num | ( | ) | const [inline, private] |
Definition at line 218 of file CounterSvc.cpp.
References GaudiUtils::Map< K, T, M >::begin(), GaudiUtils::Map< K, T, M >::end(), and m_counts.
Referenced by print().
00219 { 00220 size_t result = 0 ; 00221 { 00222 for ( CountMap::const_iterator i = m_counts.begin(); i != m_counts.end(); ++i ) 00223 { 00224 for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00225 { if ( 0 != j->second ) { ++result ; } ; } 00226 } 00227 } 00228 return result ; 00229 }
| void CounterSvc::print | ( | ) | const |
"standard" printout a'la GaudiCommon
Definition at line 434 of file CounterSvc.cpp.
References MSG::ALWAYS, GaudiUtils::Map< K, T, M >::begin(), c, GaudiUtils::Map< K, T, M >::end(), endreq(), Gaudi::Utils::formatAsTableRow(), m_counts, m_format1, m_format2, m_header, m_useEffFormat, Service::msgSvc(), Service::name(), and num().
Referenced by finalize().
00435 { 00436 MsgStream log ( msgSvc() , name() ) ; 00437 // number of counters 00438 const size_t _num = num() ; 00439 if ( 0 != _num ) 00440 { 00441 log << MSG::ALWAYS 00442 << "Number of counters : " << _num << endreq 00443 << m_header << endreq ; 00444 } 00445 for ( CountMap::const_iterator i = m_counts.begin(); i != m_counts.end(); ++i ) 00446 { 00447 for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j ) 00448 { 00449 Counter* c = j->second ; 00450 if ( 0 == c ) { continue ; } 00451 log << 00452 Gaudi::Utils::formatAsTableRow 00453 ( j->first , i->first , *c , m_useEffFormat , m_format1 , m_format2 ) 00454 << endreq ; 00455 } 00456 } 00457 }
CountMap CounterSvc::m_counts [private] |
bool CounterSvc::m_print [private] |
boolean flag to print statistics
Definition at line 239 of file CounterSvc.cpp.
Referenced by CounterSvc(), and finalize().
std::string CounterSvc::m_header [private] |
the header row
Definition at line 241 of file CounterSvc.cpp.
Referenced by CounterSvc(), and print().
std::string CounterSvc::m_format1 [private] |
format for regular statistical printout rows
Definition at line 243 of file CounterSvc.cpp.
Referenced by CounterSvc(), and print().
std::string CounterSvc::m_format2 [private] |
format for "efficiency" statistical printout rows
Definition at line 245 of file CounterSvc.cpp.
Referenced by CounterSvc(), and print().
bool CounterSvc::m_useEffFormat [private] |
flag to use the special "efficiency" format
Definition at line 247 of file CounterSvc.cpp.
Referenced by CounterSvc(), and print().