Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Stat.h
Go to the documentation of this file.
1 #ifndef __GAUDI_CHRONOSTATSVC_STAT_H__
2 #define __GAUDI_CHRONOSTATSVC_STAT_H__
3 // ============================================================================
4 // Iinclude files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <string>
9 // ============================================================================
10 // GaudiKernel
11 // ============================================================================
13 #include "GaudiKernel/StatEntity.h"
14 #include "GaudiKernel/SmartIF.h"
15 #include "GaudiKernel/IStatSvc.h"
16 // ============================================================================
47 {
48 public:
65  Stat ( StatEntity* entity = 0 ,
66  const std::string& name = "" ,
67  const std::string& group = "" )
68  : m_entity ( entity )
69  , m_tag ( name )
70  , m_group ( group )
71  , m_counter ( 0 )
72  {}
87  Stat ( StatEntity& entity ,
88  const std::string& name = "" ,
89  const std::string& group = "" )
90  : m_entity ( &entity )
91  , m_tag ( name )
92  , m_group ( group )
93  , m_counter ( 0 )
94  {}
113  Stat ( IStatSvc* svc ,
114  const std::string& tag ) ;
132  Stat ( IStatSvc* svc ,
133  const std::string& tag ,
134  const double flag ) ;
152  Stat ( ICounterSvc* svc ,
153  const std::string& group ,
154  const std::string& name ) ;
156  Stat ( const Stat& ) = default;
158  Stat& operator=( const Stat& ) = default;
160  ~Stat() = default;
161  // ==========================================================================
163  const StatEntity* entity () const { return m_entity ; }
165  const StatEntity* operator->() const { return entity() ; }
167  operator const StatEntity& () const { return *entity() ; }
169  bool operator!() const { return 0 == m_entity ; }
170  // ==========================================================================
187  Stat& operator+= ( const double f )
188  {
189  if ( m_entity ) { (*m_entity) += f ; }
190  return *this ;
191  }
205  Stat& operator++ ()
206  {
207  if ( m_entity ) { ++(*m_entity) ; }
208  return *this ;
209  }
222  Stat& operator++ (int)
223  {
224  if ( m_entity ) { (*m_entity)++ ; }
225  return *this ;
226  }
232  Stat& operator-= ( const double f )
233  {
234  if ( m_entity ) { (*m_entity) -= f ; }
235  return *this ;
236  }
238  Stat& operator-- ()
239  {
240  if ( m_entity ) { --(*m_entity) ; }
241  return *this ;
242  }
244  Stat& operator-- (int)
245  {
246  if ( m_entity ) { (*m_entity)-- ; }
247  return *this ;
248  }
250  Stat& operator+=( const StatEntity& right )
251  {
252  if ( m_entity ) { (*m_entity) += right ; }
253  return *this ;
254  }
256  Stat& operator+=( const Stat& right )
257  {
258  if ( 0 != right.entity() ) { (*this) += *right.entity() ; }
259  return *this ;
260  }
261  // ==========================================================================
263  std::string toString() const ;
268  std::ostream& print( std::ostream& o = std::cout ) const ;
273  std::ostream& fillStream ( std::ostream& o ) const { return print ( o ) ; }
274  // ==========================================================================
276  StatEntity* counter () const { return m_entity ; }
278  const std::string& name () const { return m_tag ; }
280  const std::string& group () const { return m_group ; }
281  // ==========================================================================
282 private:
283  // underlying counter
284  StatEntity* m_entity = nullptr ;
285  // unique stat tag(name)
287  // group (for ICounterSvc)
289  // Stat service
291  // Counter Svc
293 };
294 // ============================================================================
296 GAUDI_API Stat operator+( const Stat& stat , const double value ) ;
297 // ============================================================================
299 GAUDI_API Stat operator-( const Stat& stat , const double value ) ;
300 // ============================================================================
302 GAUDI_API Stat operator+( const double value , const Stat& stat ) ;
303 // ============================================================================
305 GAUDI_API Stat operator+( const Stat& stat , const Stat& value ) ;
306 // ============================================================================
308 GAUDI_API std::ostream& operator<<( std::ostream& stream , const Stat& stat ) ;
309 // ============================================================================
310 
311 // ============================================================================
312 // The END
313 // ============================================================================
314 #endif // __GAUDI_CHRONOSTATSVC_STAT_H__
315 // ============================================================================
316 
bool operator!() const
check validity
Definition: Stat.h:169
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
Definition: Stat.h:46
Create / access multi purpose counters.
Definition: ICounterSvc.h:75
SmartIF< IStatSvc > m_stat
Stat service.
Definition: Stat.h:290
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
StatEntity * counter() const
alternative access to underlying counter (for ICounterSvc::CounterObj)
Definition: Stat.h:276
const std::string & name() const
counter name
Definition: Stat.h:278
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: Stat.h:273
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Stat &stat)
external printout operator to std::ostream
Definition: Stat.cpp:181
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
std::string m_tag
unique stat tag(name)
Definition: Stat.h:286
SmartIF< ICounterSvc > m_counter
Counter Service.
Definition: Stat.h:292
Stat(StatEntity *entity=0, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
Definition: Stat.h:65
std::string m_group
Definition: Stat.h:288
Stat(StatEntity &entity, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
Definition: Stat.h:87
const StatEntity * operator->() const
dereference operaqtor
Definition: Stat.h:165
const StatEntity * entity() const
get the entity
Definition: Stat.h:163
Stat & operator+=(const StatEntity &right)
increment with StatEntity object
Definition: Stat.h:250
void print(string text)
Definition: mergesort.cpp:33
GAUDI_API Stat operator+(const Stat &stat, const double value)
external operator for addition of Stat and a number
Definition: Stat.cpp:163
GAUDI_API Stat operator-(const Stat &stat, const double value)
external operator for subtraction of Stat and a number
Definition: Stat.cpp:168
"Stat"-related part of interface IChronoStatSvc
Definition: IStatSvc.h:25
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
Stat & operator+=(const Stat &right)
increment with other stat objects
Definition: Stat.h:256
#define GAUDI_API
Definition: Kernel.h:107
STL class.
const std::string & group() const
counter group (for ICounterSvc)
Definition: Stat.h:280