| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CounterSvc Class Reference

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

Inheritance diagram for CounterSvc:
[legend]
Collaboration diagram for CounterSvc:
[legend]

## 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::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () 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 | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used 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::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (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::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (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::PropertyBase * | declareRemoteProperty (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::PropertyBase & | getProperty (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
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the cached level (originally extracted 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, 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...
Gaudi::Property< bool > | m_print {this, "PrintStat", true, "print statistics"}
Gaudi::Property< std::string > | m_header
Gaudi::Property< std::string > | m_format1
Gaudi::Property< std::string > | m_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::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | setUpMessaging ()
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
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< IAuditorSvc > | m_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

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

Definition at line 162 of file CounterSvc.cpp.

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

Definition at line 161 of file CounterSvc.cpp.

## Constructor & Destructor Documentation

CounterSvc::~CounterSvc | ( |  | ) |
| inline override

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
| inline private

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 }
gaudirun.c
c
Definition: gaudirun.py:407
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
std::find_if
T find_if(T...args)
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94

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 224 of file CounterSvc.cpp.

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

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 255 of file CounterSvc.cpp.

256 {
257 Counter* p = nullptr;
258 StatusCode sc = create( group, name, initial_value, p );
259 if ( sc.isSuccess() && p ) {
260 return CountObject( p, group, name );
261 }
262 throw std::runtime_error( "CounterSvc::Counter('" + group + "::" + name + "') exists already!" );
263 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
CounterSvc::create
StatusCode create(const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter) override
Create a new counter object.
Definition: CounterSvc.cpp:224
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
std::runtime_error
STL class.
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1620

StatusCode CounterSvc::defaultPrintout | ( | MsgStream & | log,
|  | const Counter * | pCounter
| ) |  | const
| override

Default Printout for counters.

Definition at line 381 of file CounterSvc.cpp.

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

StatusCode CounterSvc::finalize | ( |  | ) |
| inline override

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 }
CounterSvc::m_print
Gaudi::Property< bool > m_print
Definition: CounterSvc.cpp:166
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
MSG::DEBUG
Definition: IMessageSvc.h:16
CounterSvc::print
void print() const
"standard" printout a&#39;la GaudiCommon
Definition: CounterSvc.cpp:395
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124

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 189 of file CounterSvc.cpp.

190 {
191 auto i = m_counts.find( grp );
192 if ( m_counts.end() == i ) {
193 return nullptr;
194 } // RETURN
195 auto j = i->second.find( nam );
196 if ( i->second.end() == j ) {
197 return nullptr;
198 } // RETURN
199 return j->second; // RETURN
200 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151

ICounterSvc::Counters CounterSvc::get | ( | const std::string & | group | ) | const
| override

get all counters form the given group:

Definition at line 204 of file CounterSvc.cpp.

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

size_t CounterSvc::num | ( |  | ) | const
| inline private

Definition at line 148 of file CounterSvc.cpp.

149 {
150 return std::accumulate( m_counts.begin(), m_counts.end(), size_t{0}, []( size_t r, const CountMap::value_type& i ) {
151 return r + std::count_if( i.second.begin(), i.second.end(),
152 []( const NameMap::value_type& j ) -> bool { return j.second; } );
153 } );
154 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
std::count_if
T count_if(T...args)
GaudiUtils::Map::begin
iterator begin()
Definition: Map.h:133
GaudiUtils::Map< std::string, NameMap, std::unordered_map< std::string, NameMap, Hash< std::string > > >::value_type
std::pair< const std::string, NameMap > value_type
Definition: Map.h:94
std::accumulate
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 307 of file CounterSvc.cpp.

308 {
309 const Counter* c = get( grp, nam );
310 if ( !c ) {
311 return COUNTER_NOT_PRESENT;
312 } // RETURN
313 // create the stream and use it!
314 return printer( msgStream(), c );
315 }
gaudirun.c
c
Definition: gaudirun.py:407
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1620
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:78

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 340 of file CounterSvc.cpp.

341 {
342 auto i = m_counts.find( grp );
343 if ( m_counts.end() == i ) {
344 return COUNTER_NOT_PRESENT;
345 }
346
347 // Force printing in alphabetical order
348 std::map<std::string, Counter*> sorted_map( i->second.begin(), i->second.end() );
349 std::for_each( sorted_map.begin(), sorted_map.end(), conditionalPrint( printer, msgStream() ) );
350 return StatusCode::SUCCESS; // RETURN
351 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::map
STL class.
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:78
std::for_each
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 355 of file CounterSvc.cpp.

356 {
357 return printer( msgStream(), pCounter );
358 }
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:78

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 362 of file CounterSvc.cpp.

363 {
364 return print( refCounter.counter(), printer );
365 }
CounterSvc::print
void print() const
"standard" printout a&#39;la GaudiCommon
Definition: CounterSvc.cpp:395

StatusCode CounterSvc::print | ( | Printout & | printer | ) | const
| override

Parameters

  printer | [IN] Print actor

Returns
  StatusCode indicating failure or success.

Definition at line 369 of file CounterSvc.cpp.

370 {
371 // Force printing in alphabetical order
372 std::map<std::pair<std::string, std::string>, Counter*> sorted_map;
373 for ( const auto& i : m_counts )
374 for ( const auto& j : i.second ) sorted_map[{i.first, j.first}] = j.second;
375 std::for_each( sorted_map.begin(), sorted_map.end(), conditionalPrint( printer, msgStream() ) );
376 return StatusCode::SUCCESS;
377 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::map::end
T end(T...args)
std::map
STL class.
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1620
std::map::begin
T begin(T...args)
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:78
std::for_each
T for_each(T...args)

void CounterSvc::print | ( |  | ) | const

"standard" printout a'la GaudiCommon

Definition at line 395 of file CounterSvc.cpp.

396 {
397 // number of counters
398 const auto _num = num();
399 if ( 0 != _num ) {
400 always() << "Number of counters : " << _num << endmsg << m_header.value() << endmsg;
401 }
402 // Force printing in alphabetical order
403 std::map<std::pair<std::string, std::string>, Counter*> sorted_map;
404 for ( const auto& i : m_counts ) {
405 for ( const auto& j : i.second ) {
406 if ( j.second ) sorted_map[{i.first, j.first}] = j.second;
407 }
408 }
409 for ( const auto& i : sorted_map ) {
410 always() << Gaudi::Utils::formatAsTableRow( i.first.second, i.first.first, *i.second, m_useEffFormat, m_format1,
411 m_format2 )
412 << endmsg;
413 }
414 }
CounterSvc::m_useEffFormat
Gaudi::Property< bool > m_useEffFormat
Definition: CounterSvc.cpp:179
CounterSvc::m_format1
Gaudi::Property< std::string > m_format1
Definition: CounterSvc.cpp:171
CounterSvc::m_header
Gaudi::Property< std::string > m_header
Definition: CounterSvc.cpp:167
std::map
STL class.
CounterSvc::m_format2
Gaudi::Property< std::string > m_format2
Definition: CounterSvc.cpp:175
Gaudi::Utils::formatAsTableRow
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:305
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1620
CommonMessagingBase::always
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
Definition: CommonMessaging.h:97
CounterSvc::num
size_t num() const
Definition: CounterSvc.cpp:148
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

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 267 of file CounterSvc.cpp.

268 {
269 auto i = m_counts.find( grp );
270 if ( m_counts.end() == i ) {
271 return COUNTER_NOT_PRESENT;
272 } // RETURN
273 auto j = i->second.find( nam );
274 if ( i->second.end() == j ) {
275 return COUNTER_NOT_PRESENT;
276 } // RETURN
277 delete j->second;
278 i->second.erase( j );
279 return StatusCode::SUCCESS;
280 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151

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 284 of file CounterSvc.cpp.

285 {
286 auto i = m_counts.find( grp );
287 if ( m_counts.end() == i ) {
288 return COUNTER_NOT_PRESENT;
289 } // RETURN
290 for ( auto& j : i->second ) delete j.second;
291 i->second.clear();
292 return StatusCode::SUCCESS;
293 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:164
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151

StatusCode CounterSvc::remove | ( |  | ) |
| virtual

Remove all known counter objects.

Definition at line 297 of file CounterSvc.cpp.

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

## Member Data Documentation

CountMap CounterSvc::m_counts
| private

the actual map of counters

Definition at line 164 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 171 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 175 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 167 of file CounterSvc.cpp.

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

Definition at line 166 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 179 of file CounterSvc.cpp.

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

- GaudiCommonSvc/src/CounterSvc.cpp