| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 | 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::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...
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 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, 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 > >
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 164 of file CounterSvc.cpp.

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

Definition at line 163 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:391
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
std::find_if
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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
GaudiUtils::Map::emplace
std::pair< iterator, bool > emplace(Args &&...args)
Definition: Map.h:166
CounterSvc::NameMap
GaudiUtils::HashMap< std::string, Counter * > NameMap
Definition: CounterSvc.cpp:163
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1465

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 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
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:226
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::runtime_error
STL class.
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1465

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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
gaudirun.c
c
Definition: gaudirun.py:391
StatusCode::FAILURE
Definition: StatusCode.h:29
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:244

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:168
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
MSG::DEBUG
Definition: IMessageSvc.h:18
CounterSvc::print
void print() const
"standard" printout a&#39;la GaudiCommon
Definition: CounterSvc.cpp:397
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
Definition: CommonMessaging.h:135

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 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiUtils::Map::find
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 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
std::vector
STL class.
std::back_inserter
T back_inserter(T...args)
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},
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 }
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
GaudiUtils::Map::value_type
std::pair< const K, T > value_type
Definition: Map.h:94
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
std::count_if
T count_if(T...args)
GaudiUtils::Map::begin
iterator begin()
Definition: Map.h:131
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 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 }
gaudirun.c
c
Definition: gaudirun.py:391
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1465
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:88

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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
std::map
STL class.
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:149
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:88
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 357 of file CounterSvc.cpp.

358 {
359 return printer( msgStream(), pCounter );
360 }
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:88

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 }
CounterSvc::print
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
374 std::map<std::pair<std::string, std::string>, Counter*> sorted_map;
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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
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:166
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1465
std::map::begin
T begin(T...args)
CommonMessagingBase::msgStream
MsgStream & msgStream() const
Return an uninitialized MsgStream.
Definition: CommonMessaging.h:88
std::for_each
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
405 std::map<std::pair<std::string, std::string>, Counter*> sorted_map;
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 }
CounterSvc::m_useEffFormat
Gaudi::Property< bool > m_useEffFormat
Definition: CounterSvc.cpp:181
CounterSvc::m_format1
Gaudi::Property< std::string > m_format1
Definition: CounterSvc.cpp:173
CounterSvc::m_header
Gaudi::Property< std::string > m_header
Definition: CounterSvc.cpp:169
std::map
STL class.
CounterSvc::m_format2
Gaudi::Property< std::string > m_format2
Definition: CounterSvc.cpp:177
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:326
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiPython.GaudiAlgs.Counter
Counter
Definition: GaudiAlgs.py:1465
CommonMessagingBase::always
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
Definition: CommonMessaging.h:108
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: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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiUtils::Map::find
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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
GaudiUtils::Map::end
iterator end()
Definition: Map.h:132
CounterSvc::m_counts
CountMap m_counts
the actual map of counters
Definition: CounterSvc.cpp:166
GaudiUtils::Map::find
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 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
CounterSvc::m_counts
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:

- GaudiCommonSvc/src/CounterSvc.cpp