All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CounterSvc Class Reference

Simple implementation of the abstract interface ICounterSvc. More...

Inheritance diagram for CounterSvc:
Collaboration diagram for CounterSvc:

Public Member Functions

 CounterSvc (const std::string &name, ISvcLocator *svcLoc)
 Standard Constructor. More...
 
virtual ~CounterSvc ()
 Standard destructor. More...
 
virtual StatusCode finalize ()
 Finalization. More...
 
virtual Counterget (const std::string &group, const std::string &name) const
 Access an existing counter object. More...
 
virtual ICounterSvc::Counters get (const std::string &group) const
 get all counters form the given group: More...
 
virtual StatusCode create (const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter)
 Create a new counter object. More...
 
virtual CountObject create (const std::string &group, const std::string &name, longlong initial_value=0)
 Create a new counter object. More...
 
virtual StatusCode remove (const std::string &group, const std::string &name)
 Remove a counter object. More...
 
virtual StatusCode remove (const std::string &group)
 Remove all counters of a given group. More...
 
virtual StatusCode remove ()
 Remove all known counter objects. More...
 
virtual StatusCode print (const std::string &group, const std::string &name, Printout &printer) const
 Print counter value. More...
 
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. More...
 
virtual StatusCode print (const Counter *pCounter, Printout &printer) const
 Print counter value. More...
 
virtual StatusCode print (const CountObject &pCounter, Printout &printer) const
 Print counter value. More...
 
virtual StatusCode print (Printout &printer) const
 
virtual StatusCode defaultPrintout (MsgStream &log, const Counter *pCounter) const
 Default Printout for counters. More...
 
void print () const
 "standard" printout a'la GaudiCommon More...
 
- Public Member Functions inherited from extends1< Service, ICounterSvc >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces1< ICounterSvc >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from ICounterSvc
 DeclareInterfaceID (ICounterSvc, 4, 0)
 InterfaceID. More...
 

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 More...
 
bool m_print
 boolean flag to print statistics More...
 
std::string m_header
 the header row More...
 
std::string m_format1
 format for regular statistical printout rows More...
 
std::string m_format2
 format for "efficiency" statistical printout rows More...
 
bool m_useEffFormat
 flag to use the special "efficiency" format More...
 

Additional Inherited Members

- Public Types inherited from extends1< Service, ICounterSvc >
typedef extends1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1
< ICounterSvc
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces1< ICounterSvc >
typedef
ICounterSvc::iid::iids::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from ICounterSvc
enum  { COUNTER_NOT_PRESENT = 2, COUNTER_EXISTS = 4, COUNTER_REMOVED = 3 }
 
typedef StatEntity Counter
 the actual type of counter More...
 
typedef Stat CountObject
 Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...; ++(*cnt);. More...
 
typedef std::vector< CountObjectCounters
 the actual type of vectors of initialized counters More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Member Functions inherited from ICounterSvc
virtual ~ICounterSvc ()
 protected virtual destructor More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Simple implementation of the abstract interface ICounterSvc.

Author
Markus FRANK
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-05-25

Definition at line 23 of file CounterSvc.cpp.

Member Typedef Documentation

typedef GaudiUtils::HashMap<std::string,NameMap> CounterSvc::CountMap
private

Definition at line 213 of file CounterSvc.cpp.

typedef GaudiUtils::HashMap<std::string,Counter*> CounterSvc::NameMap
private

Definition at line 212 of file CounterSvc.cpp.

Constructor & Destructor Documentation

CounterSvc::CounterSvc ( const std::string &  name,
ISvcLocator svcLoc 
)
inline

Standard Constructor.

Definition at line 26 of file CounterSvc.cpp.

28  : base_class(name, svcLoc)
29  , m_counts ()
30  , m_print ( true )
31  //
32  // the header row
33  , m_header ( " Counter :: Group | # | sum | mean/eff^* | rms/err^* | min | max |")
34  // format for regular statistical printout rows
35  , m_format1 ( " %|15.15s|%|-15.15s|%|32t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
36  // format for "efficiency" statistical printout rows
37  , m_format2 ( "*%|15.15s|%|-15.15s|%|32t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" )
38  // flag to use the special "efficiency" format
39  , m_useEffFormat ( true )
40  //
41  {
42  declareProperty ("PrintStat" , m_print ) ;
43  //
45  ( "StatTableHeader" , m_header ,
46  "The header row for the output Stat-table" ) ;
47  //
49  ( "RegularRowFormat" , m_format1 ,
50  "The format for the regular row in the output Stat-table" ) ;
51  //
53  ( "EfficiencyRowFormat" , m_format2 ,
54  "The format for the regular row in the outptu Stat-table" ) ;
55  //
57  ( "UseEfficiencyRowFormat" , m_useEffFormat ,
58  "Use the special format for printout of efficiency counters" ) ;
59  }
std::string m_header
the header row
Definition: CounterSvc.cpp:219
bool m_useEffFormat
flag to use the special "efficiency" format
Definition: CounterSvc.cpp:225
bool m_print
boolean flag to print statistics
Definition: CounterSvc.cpp:217
std::string m_format2
format for "efficiency" statistical printout rows
Definition: CounterSvc.cpp:223
extends1 base_class
Typedef to this class.
Definition: extends.h:12
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
std::string m_format1
format for regular statistical printout rows
Definition: CounterSvc.cpp:221
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:211
virtual CounterSvc::~CounterSvc ( )
inlinevirtual

Standard destructor.

Definition at line 61 of file CounterSvc.cpp.

61 { remove().ignore() ; }

Member Function Documentation

std::pair<std::string,std::string> CounterSvc::_find ( const Counter c) const
inlineprivate

Definition at line 185 of file CounterSvc.cpp.

186  {
187  if ( 0 == c ) { return std::pair<std::string,std::string>() ; }
188  for ( CountMap::const_iterator i = m_counts.begin() ; m_counts.end() != i ; ++i )
189  {
190  for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j )
191  { if ( j->second == c ) { return std::make_pair( i->first , j->first ) ; } }
192  }
193  return std::pair<std::string,std::string>() ;
194  }
tuple c
Definition: gaudirun.py:341
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
map_type::const_iterator const_iterator
Definition: Map.h:99
iterator begin()
Definition: Map.h:130
list i
Definition: ana.py:128
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.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
initial_value[IN] Initial counter value
refpCounter[OUT] Reference to store pointer to counter.
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 265 of file CounterSvc.cpp.

269 {
270  // try to find existing counter:
271  refpCounter = get ( grp , nam ) ;
272  if ( 0 != refpCounter ) { return COUNTER_EXISTS ; } // RETURN
273  // create the new counter
274  Counter* newc = new Counter() ;
275  refpCounter = newc ;
276  if ( 0 != initial_value ) {
277  refpCounter->addFlag ( static_cast<double>(initial_value) ) ; // icc remark #2259
278  }
279  // find a proper group
280  CountMap::iterator i = m_counts.find ( grp ) ;
281  // (create a group if needed)
282  if ( m_counts.end() == i )
283  { i = m_counts.insert ( std::make_pair ( grp , NameMap() ) ).first ; }
284  // insert new counter with proper name into proper group:
285  i->second.insert( std::make_pair( nam , newc ) );
286  return StatusCode::SUCCESS ; // RETURN
287 }
StatEntity Counter
the actual type of counter
Definition: ICounterSvc.h:84
GaudiUtils::HashMap< std::string, Counter * > NameMap
Definition: CounterSvc.cpp:212
std::pair< iterator, bool > insert(const value_type &val)
Definition: Map.h:165
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator find(const key_type &key)
Definition: Map.h:148
list i
Definition: ana.py:128
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.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
initial_value[IN] Initial counter value
refpCounter[OUT] Reference to store pointer to counter.
Returns
Fully initialized CountObject.

Implements ICounterSvc.

Definition at line 296 of file CounterSvc.cpp.

299 {
300  Counter* p = 0;
301  StatusCode sc = create ( group, name, initial_value, p ) ;
302  if ( sc.isSuccess() && 0 != p ) { return CountObject ( p , group , name ) ; }
303  throw std::runtime_error("CounterSvc::Counter('"+group+"::"+name+"') exists already!");
304 }
virtual StatusCode create(const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter)
Create a new counter object.
Definition: CounterSvc.cpp:265
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
StatEntity Counter
the actual type of counter
Definition: ICounterSvc.h:84
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Stat CountObject
Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...
Definition: ICounterSvc.h:100
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
StatusCode CounterSvc::defaultPrintout ( MsgStream log,
const Counter pCounter 
) const
virtual

Default Printout for counters.

Implements ICounterSvc.

Definition at line 433 of file CounterSvc.cpp.

435 {
436  if ( 0 == c ) { return StatusCode::FAILURE ; }
437  std::pair<std::string,std::string> p = _find ( c ) ;
438 
439  log << MSG::ALWAYS
440  << CountObject( const_cast<Counter*>(c) , p.first , p.second )
441  << endmsg ;
442 
443  return StatusCode::SUCCESS;
444 }
std::pair< std::string, std::string > _find(const Counter *c) const
Definition: CounterSvc.cpp:185
tuple c
Definition: gaudirun.py:341
Stat CountObject
Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...
Definition: ICounterSvc.h:100
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode CounterSvc::finalize ( )
inlinevirtual

Finalization.

< finalize the base class

Reimplemented from Service.

Definition at line 63 of file CounterSvc.cpp.

64  {
65  if ( outputLevel() <= MSG::DEBUG || m_print ) { print () ; }
66  remove().ignore() ;
67  // finalize the base class
68  return Service::finalize() ;
69  }
int outputLevel() const
get the Service's output level
Definition: Service.h:250
bool m_print
boolean flag to print statistics
Definition: CounterSvc.cpp:217
void print() const
"standard" printout a'la GaudiCommon
Definition: CounterSvc.cpp:448
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:199
CounterSvc::Counter * CounterSvc::get ( const std::string &  group,
const std::string &  name 
) const
virtual

Access an existing counter object.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
Returns
Pointer to existing counter object (NULL if non existing).

Implements ICounterSvc.

Definition at line 235 of file CounterSvc.cpp.

237 {
239  if ( m_counts.end() == i ) { return 0 ; } // RETURN
240  NameMap::const_iterator j = i->second.find ( nam ) ;
241  if ( i->second.end() == j ) { return 0 ; } // RETURN
242  return j->second ; // RETURN
243 }
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator find(const key_type &key)
Definition: Map.h:148
map_type::const_iterator const_iterator
Definition: Map.h:99
list i
Definition: ana.py:128
ICounterSvc::Counters CounterSvc::get ( const std::string &  group) const
virtual

get all counters form the given group:

Implements ICounterSvc.

Definition at line 247 of file CounterSvc.cpp.

248 {
249  ICounterSvc::Counters result ;
251  if ( m_counts.end() == i ) { return result ; } // RETURN
252  for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j )
253  { result.push_back( CountObject ( j->second, i->first , j->first ) ) ; }
254  return result ;
255 }
std::vector< CountObject > Counters
the actual type of vectors of initialized counters
Definition: ICounterSvc.h:102
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator find(const key_type &key)
Definition: Map.h:148
Stat CountObject
Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...
Definition: ICounterSvc.h:100
map_type::const_iterator const_iterator
Definition: Map.h:99
list i
Definition: ana.py:128
size_t CounterSvc::num ( ) const
inlineprivate

Definition at line 196 of file CounterSvc.cpp.

197  {
198  size_t result = 0 ;
199  {
200  for ( CountMap::const_iterator i = m_counts.begin(); i != m_counts.end(); ++i )
201  {
202  for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j )
203  { if ( 0 != j->second ) { ++result ; } ; }
204  }
205  }
206  return result ;
207  }
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
map_type::const_iterator const_iterator
Definition: Map.h:99
iterator begin()
Definition: Map.h:130
list i
Definition: ana.py:128
StatusCode CounterSvc::print ( const std::string &  group,
const std::string &  name,
Printout printer 
) const
virtual

Print counter value.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 347 of file CounterSvc.cpp.

350 {
351  const Counter* c = get( grp , nam ) ;
352  if ( 0 == c ) { return COUNTER_NOT_PRESENT ; } // RETURN
353  // create the stream and use it!
354  MsgStream log ( msgSvc() , name() ) ;
355  return printer ( log , c ) ;
356 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
tuple c
Definition: gaudirun.py:341
StatEntity Counter
the actual type of counter
Definition: ICounterSvc.h:84
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
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.

Parameters
group[IN] Hint for smart printing
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 378 of file CounterSvc.cpp.

380 {
382  if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; }
383 
384  MsgStream log(msgSvc(), name());
385  // Force printing in alphabetical order
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));
390  return StatusCode::SUCCESS; // RETURN
391 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator find(const key_type &key)
Definition: Map.h:148
map_type::const_iterator const_iterator
Definition: Map.h:99
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
list i
Definition: ana.py:128
StatusCode CounterSvc::print ( const Counter pCounter,
Printout printer 
) const
virtual

Print counter value.

Parameters
pCounter[IN] Pointer to Counter object
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 396 of file CounterSvc.cpp.

398 {
399  MsgStream log(msgSvc(), name() ) ;
400  return printer ( log , pCounter ) ;
401 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
StatusCode CounterSvc::print ( const CountObject pCounter,
Printout printer 
) const
virtual

Print counter value.

Parameters
refCounter[IN] Reference to CountObject object
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 406 of file CounterSvc.cpp.

408 { return print( refCounter.counter() , printer ) ; }
void print() const
"standard" printout a'la GaudiCommon
Definition: CounterSvc.cpp:448
StatusCode CounterSvc::print ( Printout printer) const
virtual
Parameters
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 412 of file CounterSvc.cpp.

413 {
414  MsgStream log ( msgSvc() , name() ) ;
415  // Force printing in alphabetical order
416  typedef std::map<std::pair<std::string,std::string>, Counter*> sorted_map_t;
417  sorted_map_t sorted_map;
418  for ( CountMap::const_iterator i = m_counts.begin(); i != m_counts.end(); ++i )
419  {
420  for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j )
421  {
422  sorted_map[std::make_pair(i->first, j->first)] = j->second;
423  }
424  }
425  std::for_each(sorted_map.begin(), sorted_map.end(),
426  conditionalPrint(printer, log));
427  return StatusCode::SUCCESS;
428 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
StatEntity Counter
the actual type of counter
Definition: ICounterSvc.h:84
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
map_type::const_iterator const_iterator
Definition: Map.h:99
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
iterator begin()
Definition: Map.h:130
list i
Definition: ana.py:128
void CounterSvc::print ( ) const

"standard" printout a'la GaudiCommon

Definition at line 448 of file CounterSvc.cpp.

449 {
450  MsgStream log ( msgSvc() , name() ) ;
451  // number of counters
452  const size_t _num = num() ;
453  if ( 0 != _num )
454  {
455  log << MSG::ALWAYS
456  << "Number of counters : " << _num << endmsg
457  << m_header << endmsg ;
458  }
459  {
460  // Force printing in alphabetical order
461  typedef std::map<std::pair<std::string,std::string>, Counter*> sorted_map_t;
462  sorted_map_t sorted_map;
463  for ( CountMap::const_iterator i = m_counts.begin(); i != m_counts.end(); ++i )
464  {
465  for ( NameMap::const_iterator j = i->second.begin() ; i->second.end() != j ; ++j )
466  {
467  Counter* c = j->second ;
468  if ( 0 == c ) { continue ; }
469  sorted_map[std::make_pair(i->first, j->first)] = c;
470  }
471  }
472  for (sorted_map_t::const_iterator i = sorted_map.begin(); i != sorted_map.end(); ++i )
473  log << Gaudi::Utils::formatAsTableRow( i->first.second
474  , i->first.first
475  , *i->second
477  , m_format1
478  , m_format2 )
479  << endmsg ;
480  }
481 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string m_header
the header row
Definition: CounterSvc.cpp:219
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
tuple c
Definition: gaudirun.py:341
bool m_useEffFormat
flag to use the special "efficiency" format
Definition: CounterSvc.cpp:225
std::string m_format2
format for "efficiency" statistical printout rows
Definition: CounterSvc.cpp:223
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
Definition: StatEntity.cpp:302
StatEntity Counter
the actual type of counter
Definition: ICounterSvc.h:84
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
std::string m_format1
format for regular statistical printout rows
Definition: CounterSvc.cpp:221
map_type::const_iterator const_iterator
Definition: Map.h:99
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
iterator begin()
Definition: Map.h:130
size_t num() const
Definition: CounterSvc.cpp:196
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
initial_value[IN] Initial counter value
refpCounter[OUT] Reference to store pointer to counter.
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 309 of file CounterSvc.cpp.

311 {
312  CountMap::iterator i = m_counts.find ( grp ) ;
313  if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } // RETURN
314  NameMap::iterator j = i->second.find ( nam ) ;
315  if ( i->second.end() == j ) { return COUNTER_NOT_PRESENT ; } // RETURN
316  delete j->second ;
317  i->second.erase ( j ) ;
318  return StatusCode::SUCCESS ;
319 }
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator find(const key_type &key)
Definition: Map.h:148
list i
Definition: ana.py:128
StatusCode CounterSvc::remove ( const std::string &  group)
virtual

Remove all counters of a given group.

If no such counter exists the return code is COUNTER_NOT_PRESENT

Parameters
group[IN] Hint for smart printing
Returns
StatusCode indicating failure or success.

Implements ICounterSvc.

Definition at line 323 of file CounterSvc.cpp.

324 {
325  CountMap::iterator i = m_counts.find ( grp ) ;
326  if ( m_counts.end() == i ) { return COUNTER_NOT_PRESENT ; } // RETURN
327  for ( NameMap::iterator j = i->second.begin() ; i->second.end() != j ; ++j )
328  { delete j->second ; }
329  i->second.clear() ;
330  return StatusCode::SUCCESS ;
331 }
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator find(const key_type &key)
Definition: Map.h:148
list i
Definition: ana.py:128
StatusCode CounterSvc::remove ( )
virtual

Remove all known counter objects.

Definition at line 335 of file CounterSvc.cpp.

336 {
337  // remove group by group
338  for ( CountMap::iterator i = m_counts.begin() ; m_counts.end() != i ; ++i )
339  { remove ( i->first ).ignore () ; }
340  m_counts.clear() ;
341  return StatusCode::SUCCESS;
342 }
iterator end()
Definition: Map.h:131
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:215
iterator begin()
Definition: Map.h:130
void clear()
Definition: Map.h:176
list i
Definition: ana.py:128

Member Data Documentation

CountMap CounterSvc::m_counts
private

the actual map of counters

Definition at line 215 of file CounterSvc.cpp.

std::string CounterSvc::m_format1
private

format for regular statistical printout rows

Definition at line 221 of file CounterSvc.cpp.

std::string CounterSvc::m_format2
private

format for "efficiency" statistical printout rows

Definition at line 223 of file CounterSvc.cpp.

std::string CounterSvc::m_header
private

the header row

Definition at line 219 of file CounterSvc.cpp.

bool CounterSvc::m_print
private

boolean flag to print statistics

Definition at line 217 of file CounterSvc.cpp.

bool CounterSvc::m_useEffFormat
private

flag to use the special "efficiency" format

Definition at line 225 of file CounterSvc.cpp.


The documentation for this class was generated from the following file: