33 ,
m_header (
" Counter :: Group | # | sum | mean/eff^* | rms/err^* | min | max |")
35 ,
m_format1 (
" %|15.15s|%|-15.15s|%|32t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
37 ,
m_format2 (
"*%|15.15s|%|-15.15s|%|32t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" )
46 "The header row for the output Stat-table" ) ;
50 "The format for the regular row in the output Stat-table" ) ;
54 "The format for the regular row in the outptu Stat-table" ) ;
58 "Use the special format for printout of efficiency counters" ) ;
79 (
const std::string& group ,
80 const std::string&
name )
const;
96 (
const std::string& group ,
97 const std::string&
name ,
112 (
const std::string& group ,
113 const std::string&
name ,
125 (
const std::string& group ,
126 const std::string&
name ) ;
133 (
const std::string& group ) ;
144 (
const std::string& group,
145 const std::string&
name,
146 Printout& printer)
const;
155 (
const std::string& group,
156 Printout& printer)
const;
165 Printout& printer)
const;
174 Printout& printer)
const;
182 const Counter* pCounter)
const ;
187 if ( 0 == c ) {
return std::pair<std::string,std::string>() ; }
191 {
if ( j->second == c ) {
return std::make_pair(
i->first , j->first ) ; } }
193 return std::pair<std::string,std::string>() ;
196 inline size_t num ()
const
203 {
if ( 0 != j->second ) { ++result ; } ; }
210 void print ()
const ;
235 ( const
std::
string& grp ,
236 const
std::
string& nam )
const
239 if ( m_counts.end() ==
i ) {
return 0 ; }
241 if ( i->second.end() == j ) {
return 0 ; }
253 { result.push_back(
CountObject ( j->second, i->first , j->first ) ) ; }
261 #pragma warning(push)
262 #pragma warning(disable:2259)
265 (
const std::string& grp ,
266 const std::string& nam ,
271 refpCounter =
get ( grp , nam ) ;
272 if ( 0 != refpCounter ) {
return COUNTER_EXISTS ; }
276 if ( 0 != initial_value ) {
277 refpCounter->
addFlag ( static_cast<double>(initial_value) ) ;
282 if ( m_counts.end() ==
i )
283 { i = m_counts.insert ( std::make_pair ( grp ,
NameMap() ) ).first ; }
285 i->second.insert( std::make_pair( nam , newc ) );
296 (
const std::string& group ,
297 const std::string& name ,
301 StatusCode sc = create ( group, name, initial_value, p ) ;
303 throw std::runtime_error(
"CounterSvc::Counter('"+group+
"::"+name+
"') exists already!");
309 (
const std::string& grp ,
310 const std::string& nam )
313 if ( m_counts.end() ==
i ) {
return COUNTER_NOT_PRESENT ; }
315 if ( i->second.end() == j ) {
return COUNTER_NOT_PRESENT ; }
317 i->second.erase ( j ) ;
328 {
delete j->second ; }
339 {
remove (
i->first ).ignore () ; }
347 (
const std::string& grp,
348 const std::string& nam,
351 const Counter*
c =
get( grp , nam ) ;
352 if ( 0 == c ) {
return COUNTER_NOT_PRESENT ; }
355 return printer ( log , c ) ;
360 class conditionalPrint {
367 void operator() (
const Pair &p) {
369 (*printer)(*
log, p.second).ignore();
378 (
const std::string& grp ,
382 if ( m_counts.end() ==
i ) {
return COUNTER_NOT_PRESENT ; }
386 typedef std::map<std::string, Counter*> sorted_map_t;
387 sorted_map_t sorted_map(i->second.begin(), i->second.end());
388 std::for_each(sorted_map.begin(), sorted_map.end(),
389 conditionalPrint(printer, log));
400 return printer ( log , pCounter ) ;
408 {
return print( refCounter.
counter() , printer ) ; }
416 typedef std::map<std::pair<std::string,std::string>,
Counter*> sorted_map_t;
417 sorted_map_t sorted_map;
422 sorted_map[std::make_pair(
i->first, j->first)] = j->second;
425 std::for_each(sorted_map.begin(), sorted_map.end(),
426 conditionalPrint(printer, log));
437 std::pair<std::string,std::string> p = _find ( c ) ;
440 <<
CountObject( const_cast<Counter*>(c) , p.first , p.second )
452 const size_t _num =
num() ;
456 <<
"Number of counters : " << _num <<
endmsg
461 typedef std::map<std::pair<std::string,std::string>,
Counter*> sorted_map_t;
462 sorted_map_t sorted_map;
468 if ( 0 == c ) { continue ; }
469 sorted_map[std::make_pair(
i->first, j->first)] =
c;
472 for (sorted_map_t::const_iterator
i = sorted_map.begin();
i != sorted_map.end(); ++
i )
std::pair< std::string, std::string > _find(const Counter *c) const
GaudiUtils::HashMap< std::string, NameMap > CountMap
Definition of the MsgStream class used to transmit messages.
virtual StatusCode remove()
Remove all known counter objects.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode create(const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter)
Create a new counter object.
std::string m_header
the header row
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
bool isSuccess() const
Test for a status code of SUCCESS.
StatEntity * counter() const
alternative access to underlying counter (for ICounterSvc::CounterObj)
int outputLevel() const
get the Service's output level
bool m_useEffFormat
flag to use the special "efficiency" format
bool m_print
boolean flag to print statistics
std::vector< CountObject > Counters
the actual type of vectors of initialized counters
std::string m_format2
format for "efficiency" statistical printout rows
Simple implementation of the abstract interface ICounterSvc.
#define DECLARE_COMPONENT(type)
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
StatEntity Counter
the actual type of counter
GaudiUtils::HashMap< std::string, Counter * > NameMap
void print() const
"standard" printout a'la GaudiCommon
Print counters for each element in the range [first, last) e.g.
This class is used for returning status codes from appropriate routines.
Base class used to extend a class implementing other interfaces.
CountMap m_counts
the actual map of counters
CounterSvc(const std::string &name, ISvcLocator *svcLoc)
Standard Constructor.
iterator find(const key_type &key)
Stat CountObject
Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...
virtual ~CounterSvc()
Standard destructor.
std::string m_format1
format for regular statistical printout rows
map_type::const_iterator const_iterator
unsigned long addFlag(const double Flag)
add a flag
virtual const std::string & name() const
Retrieve name of the service.
map_type::iterator iterator
virtual StatusCode defaultPrintout(MsgStream &log, const Counter *pCounter) const
Default Printout for counters.
std
AIDA -> ROTO converter.
Common class providing an architecture-independent hash map.
Templated class to add the standard messaging functionalities.
virtual Counter * get(const std::string &group, const std::string &name) const
Access an existing counter object.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
The basic counter used for Monitoring purposes.
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode finalize()
Finalization.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.