The Gaudi Framework  v28r2p1 (f1a77ff4)
CounterSvc Class Reference

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

Inheritance diagram for CounterSvc:
Collaboration diagram for CounterSvc:

Public Member Functions

 ~CounterSvc () override
 Standard destructor. More...
 
StatusCode finalize () override
 Finalization. More...
 
Counter * get (const std::string &group, const std::string &name) const override
 Access an existing counter object. More...
 
ICounterSvc::Counters get (const std::string &group) const override
 get all counters form the given group: More...
 
StatusCode create (const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) override
 Create a new counter object. More...
 
CountObject create (const std::string &group, const std::string &name, longlong initial_value=0) override
 Create a new counter object. More...
 
StatusCode remove (const std::string &group, const std::string &name) override
 Remove a counter object. More...
 
StatusCode remove (const std::string &group) override
 Remove all counters of a given group. More...
 
virtual StatusCode remove ()
 Remove all known counter objects. More...
 
StatusCode print (const std::string &group, const std::string &name, Printout &printer) const override
 Print counter value. More...
 
StatusCode print (const std::string &group, Printout &printer) const override
 If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access. More...
 
StatusCode print (const Counter *pCounter, Printout &printer) const override
 Print counter value. More...
 
StatusCode print (const CountObject &pCounter, Printout &printer) const override
 Print counter value. More...
 
StatusCode print (Printout &printer) const override
 
StatusCode defaultPrintout (MsgStream &log, const Counter *pCounter) const override
 Default Printout for counters. More...
 
void print () const
 "standard" printout a'la GaudiCommon More...
 
- Public Member Functions inherited from extends< Service, ICounterSvc >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 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<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, 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 >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 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...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Private Types

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

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...
 
Gaudi::Property< bool > m_print {this, "PrintStat", true, "print statistics"}
 
Gaudi::Property< std::stringm_header
 
Gaudi::Property< std::stringm_format1
 
Gaudi::Property< std::stringm_format2
 
Gaudi::Property< bool > m_useEffFormat
 

Additional Inherited Members

- Public Types inherited from extends< Service, ICounterSvc >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor 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 25 of file CounterSvc.cpp.

Member Typedef Documentation

Definition at line 164 of file CounterSvc.cpp.

Definition at line 163 of file CounterSvc.cpp.

Constructor & Destructor Documentation

CounterSvc::~CounterSvc ( )
inlineoverride

Standard destructor.

Definition at line 31 of file CounterSvc.cpp.

31 { remove().ignore(); }

Member Function Documentation

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

Definition at line 136 of file CounterSvc.cpp.

137  {
138  if ( c ) {
139  for ( const auto& i : m_counts ) {
140  auto j = std::find_if( i.second.begin(), i.second.end(),
141  [&]( const NameMap::value_type& k ) { return k.second == c; } );
142  if ( j != i.second.end() ) return {i.first, j->first};
143  }
144  }
145  return {};
146  }
std::pair< const K, T > value_type
Definition: Map.h:94
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
T find_if(T...args)
StatusCode CounterSvc::create ( const std::string group,
const std::string name,
longlong  initial_value,
Counter *&  refpCounter 
)
override

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.

Definition at line 226 of file CounterSvc.cpp.

228 {
229  // try to find existing counter:
230  refpCounter = get( grp, nam );
231  if ( refpCounter ) {
232  return COUNTER_EXISTS;
233  } // RETURN
234  // create the new counter
235  auto newc = new Counter();
236  refpCounter = newc;
237  if ( 0 != initial_value ) {
238  refpCounter->addFlag( static_cast<double>( initial_value ) ); // icc remark #2259
239  }
240  // find a proper group
241  auto i = m_counts.find( grp );
242  // (create a group if needed)
243  if ( m_counts.end() == i ) {
244  i = m_counts.emplace( grp, NameMap() ).first;
245  }
246  // insert new counter with proper name into proper group:
247  i->second.emplace( nam, newc );
248  return StatusCode::SUCCESS; // RETURN
249 }
std::pair< iterator, bool > emplace(Args &&...args)
Definition: Map.h:166
GaudiUtils::HashMap< std::string, Counter * > NameMap
Definition: CounterSvc.cpp:163
iterator end()
Definition: Map.h:132
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
iterator find(const key_type &key)
Definition: Map.h:149
CounterSvc::CountObject CounterSvc::create ( const std::string group,
const std::string name,
longlong  initial_value = 0 
)
override

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.

Definition at line 257 of file CounterSvc.cpp.

258 {
259  Counter* p = nullptr;
260  StatusCode sc = create( group, name, initial_value, p );
261  if ( sc.isSuccess() && p ) {
262  return CountObject( p, group, name );
263  }
264  throw std::runtime_error( "CounterSvc::Counter('" + group + "::" + name + "') exists already!" );
265 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
StatusCode create(const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) override
Create a new counter object.
Definition: CounterSvc.cpp:226
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode CounterSvc::defaultPrintout ( MsgStream log,
const Counter *  pCounter 
) const
override

Default Printout for counters.

Definition at line 383 of file CounterSvc.cpp.

384 {
385  if ( !c ) {
386  return StatusCode::FAILURE;
387  }
388  auto p = _find( c );
389 
390  log << MSG::ALWAYS << CountObject( const_cast<Counter*>( c ), p.first, p.second ) << endmsg;
391 
392  return StatusCode::SUCCESS;
393 }
std::pair< std::string, std::string > _find(const Counter *c) const
Definition: CounterSvc.cpp:136
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode CounterSvc::finalize ( )
inlineoverride

Finalization.

< finalize the base class

Definition at line 33 of file CounterSvc.cpp.

34  {
35  if ( msgLevel( MSG::DEBUG ) || m_print ) {
36  print();
37  }
38  remove().ignore();
39  // finalize the base class
40  return Service::finalize();
41  }
Gaudi::Property< bool > m_print
Definition: CounterSvc.cpp:168
StatusCode finalize() override
Definition: Service.cpp:174
void print() const
"standard" printout a&#39;la GaudiCommon
Definition: CounterSvc.cpp:397
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
CounterSvc::Counter * CounterSvc::get ( const std::string group,
const std::string name 
) const
override

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).

Definition at line 191 of file CounterSvc.cpp.

192 {
193  auto i = m_counts.find( grp );
194  if ( m_counts.end() == i ) {
195  return nullptr;
196  } // RETURN
197  auto j = i->second.find( nam );
198  if ( i->second.end() == j ) {
199  return nullptr;
200  } // RETURN
201  return j->second; // RETURN
202 }
iterator end()
Definition: Map.h:132
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
iterator find(const key_type &key)
Definition: Map.h:149
ICounterSvc::Counters CounterSvc::get ( const std::string group) const
override

get all counters form the given group:

Definition at line 206 of file CounterSvc.cpp.

207 {
208  ICounterSvc::Counters result;
209  auto i = m_counts.find( group );
210  if ( i != m_counts.end() ) {
211  std::transform( i->second.begin(), i->second.end(), std::back_inserter( result ),
212  [&]( const NameMap::value_type& j ) {
213  return CountObject{j.second, i->first, j.first};
214  } );
215  }
216  return result;
217 }
iterator end()
Definition: Map.h:132
std::pair< const K, T > value_type
Definition: Map.h:94
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
iterator find(const key_type &key)
Definition: Map.h:149
STL class.
T back_inserter(T...args)
T transform(T...args)
size_t CounterSvc::num ( ) const
inlineprivate

Definition at line 148 of file CounterSvc.cpp.

149  {
150  return std::accumulate( m_counts.begin(), m_counts.end(), size_t{0},
151  []( size_t r, const CountMap::value_type& i ) {
152  return r +
153  std::count_if( i.second.begin(), i.second.end(),
154  []( const NameMap::value_type& j ) -> bool { return j.second; } );
155  } );
156  }
iterator end()
Definition: Map.h:132
std::pair< const K, T > value_type
Definition: Map.h:94
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
T count_if(T...args)
iterator begin()
Definition: Map.h:131
T accumulate(T...args)
StatusCode CounterSvc::print ( const std::string group,
const std::string name,
Printout &  printer 
) const
override

Print counter value.

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

Definition at line 309 of file CounterSvc.cpp.

310 {
311  const Counter* c = get( grp, nam );
312  if ( !c ) {
313  return COUNTER_NOT_PRESENT;
314  } // RETURN
315  // create the stream and use it!
316  return printer( msgStream(), c );
317 }
MsgStream & msgStream() const
Return an uninitialized MsgStream.
StatusCode CounterSvc::print ( const std::string group,
Printout &  printer 
) const
override

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.

Definition at line 342 of file CounterSvc.cpp.

343 {
344  auto i = m_counts.find( grp );
345  if ( m_counts.end() == i ) {
346  return COUNTER_NOT_PRESENT;
347  }
348 
349  // Force printing in alphabetical order
350  std::map<std::string, Counter*> sorted_map( i->second.begin(), i->second.end() );
351  std::for_each( sorted_map.begin(), sorted_map.end(), conditionalPrint( printer, msgStream() ) );
352  return StatusCode::SUCCESS; // RETURN
353 }
STL class.
iterator end()
Definition: Map.h:132
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
iterator find(const key_type &key)
Definition: Map.h:149
MsgStream & msgStream() const
Return an uninitialized MsgStream.
T for_each(T...args)
StatusCode CounterSvc::print ( const Counter *  pCounter,
Printout &  printer 
) const
override

Print counter value.

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

Definition at line 357 of file CounterSvc.cpp.

358 {
359  return printer( msgStream(), pCounter );
360 }
MsgStream & msgStream() const
Return an uninitialized MsgStream.
StatusCode CounterSvc::print ( const CountObject &  pCounter,
Printout &  printer 
) const
override

Print counter value.

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

Definition at line 364 of file CounterSvc.cpp.

365 {
366  return print( refCounter.counter(), printer );
367 }
void print() const
"standard" printout a&#39;la GaudiCommon
Definition: CounterSvc.cpp:397
StatusCode CounterSvc::print ( Printout &  printer) const
override
Parameters
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Definition at line 371 of file CounterSvc.cpp.

372 {
373  // Force printing in alphabetical order
375  for ( const auto& i : m_counts )
376  for ( const auto& j : i.second ) sorted_map[{i.first, j.first}] = j.second;
377  std::for_each( sorted_map.begin(), sorted_map.end(), conditionalPrint( printer, msgStream() ) );
378  return StatusCode::SUCCESS;
379 }
T end(T...args)
STL class.
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
T begin(T...args)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
T for_each(T...args)
void CounterSvc::print ( ) const

"standard" printout a'la GaudiCommon

Definition at line 397 of file CounterSvc.cpp.

398 {
399  // number of counters
400  const auto _num = num();
401  if ( 0 != _num ) {
402  always() << "Number of counters : " << _num << endmsg << m_header.value() << endmsg;
403  }
404  // Force printing in alphabetical order
406  for ( const auto& i : m_counts ) {
407  for ( const auto& j : i.second ) {
408  if ( j.second ) sorted_map[{i.first, j.first}] = j.second;
409  }
410  }
411  for ( const auto& i : sorted_map ) {
412  always() << Gaudi::Utils::formatAsTableRow( i.first.second, i.first.first, *i.second, m_useEffFormat, m_format1,
413  m_format2 )
414  << endmsg;
415  }
416 }
Gaudi::Property< bool > m_useEffFormat
Definition: CounterSvc.cpp:181
Gaudi::Property< std::string > m_format1
Definition: CounterSvc.cpp:173
Gaudi::Property< std::string > m_header
Definition: CounterSvc.cpp:169
STL class.
Gaudi::Property< std::string > m_format2
Definition: CounterSvc.cpp:177
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:326
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
size_t num() const
Definition: CounterSvc.cpp:148
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 
)
override

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.

Definition at line 269 of file CounterSvc.cpp.

270 {
271  auto i = m_counts.find( grp );
272  if ( m_counts.end() == i ) {
273  return COUNTER_NOT_PRESENT;
274  } // RETURN
275  auto j = i->second.find( nam );
276  if ( i->second.end() == j ) {
277  return COUNTER_NOT_PRESENT;
278  } // RETURN
279  delete j->second;
280  i->second.erase( j );
281  return StatusCode::SUCCESS;
282 }
iterator end()
Definition: Map.h:132
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
iterator find(const key_type &key)
Definition: Map.h:149
StatusCode CounterSvc::remove ( const std::string group)
override

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.

Definition at line 286 of file CounterSvc.cpp.

287 {
288  auto i = m_counts.find( grp );
289  if ( m_counts.end() == i ) {
290  return COUNTER_NOT_PRESENT;
291  } // RETURN
292  for ( auto& j : i->second ) delete j.second;
293  i->second.clear();
294  return StatusCode::SUCCESS;
295 }
iterator end()
Definition: Map.h:132
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
iterator find(const key_type &key)
Definition: Map.h:149
StatusCode CounterSvc::remove ( )
virtual

Remove all known counter objects.

Definition at line 299 of file CounterSvc.cpp.

300 {
301  // remove group by group
302  for ( auto& i : m_counts ) remove( i.first ).ignore();
303  m_counts.clear();
304  return StatusCode::SUCCESS;
305 }
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166

Member Data Documentation

CountMap CounterSvc::m_counts
private

the actual map of counters

Definition at line 166 of file CounterSvc.cpp.

Gaudi::Property<std::string> CounterSvc::m_format1
private
Initial value:
{
this, "RegularRowFormat",
" %|15.15s|%|-15.15s|%|32t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |",
"the format for the regular row in the output Stat-table"}

Definition at line 173 of file CounterSvc.cpp.

Gaudi::Property<std::string> CounterSvc::m_format2
private
Initial value:
{
this, "EfficiencyRowFormat",
"*%|15.15s|%|-15.15s|%|32t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |",
"the format for the regular row in the outptu Stat-table"}

Definition at line 177 of file CounterSvc.cpp.

Gaudi::Property<std::string> CounterSvc::m_header
private
Initial value:
{this, "StatTableHeader",
" Counter :: Group | # | sum | "
"mean/eff^* | rms/err^* | min | max |",
"the header row for the output Stat-table"}

Definition at line 169 of file CounterSvc.cpp.

Gaudi::Property<bool> CounterSvc::m_print {this, "PrintStat", true, "print statistics"}
private

Definition at line 168 of file CounterSvc.cpp.

Gaudi::Property<bool> CounterSvc::m_useEffFormat
private
Initial value:
{this, "UseEfficiencyRowFormat", true,
"use the special format for printout of efficiency counters"}

Definition at line 181 of file CounterSvc.cpp.


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