| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

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 // ============================================================================
12 #include "GaudiKernel/ICounterSvc.h"
13 #include "GaudiKernel/StatEntity.h"
14 #include "GaudiKernel/SmartIF.h"
15 #include "GaudiKernel/IStatSvc.h"
16 // ============================================================================
46 class GAUDI_API Stat
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)
286 std::string m_tag ;
287 // group (for ICounterSvc)
288 std::string m_group ;
289 // Stat service
290 SmartIF<IStatSvc> m_stat ;
291 // Counter Svc
292 SmartIF<ICounterSvc> m_counter ;
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
Gaudi::Utils::Histos::Formats::Stat
Definition: HistoTableFormat.h:94
SmartIF< IStatSvc >
Stat::operator!
bool operator!() const
check validity
Definition: Stat.h:169
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
Definition: Stat.h:46
ICounterSvc
Create / access multi purpose counters.
Definition: ICounterSvc.h:75
Stat::m_stat
SmartIF< IStatSvc > m_stat
Stat service.
Definition: Stat.h:290
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:367
Stat::counter
StatEntity * counter() const
alternative access to underlying counter (for ICounterSvc::CounterObj)
Definition: Stat.h:276
Stat::name
const std::string & name() const
counter name
Definition: Stat.h:278
Stat::fillStream
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: Stat.h:273
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Stat &stat)
external printout operator to std::ostream
Definition: Stat.cpp:181
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:286
Stat::m_counter
SmartIF< ICounterSvc > m_counter
Counter Service.
Definition: Stat.h:292
IStatSvc.h
SmartIF.h
Stat::Stat
Stat(StatEntity *entity=0, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
Definition: Stat.h:65
Stat::m_group
std::string m_group
Definition: Stat.h:288
Stat::Stat
Stat(StatEntity &entity, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
Definition: Stat.h:87
Stat::operator->
const StatEntity * operator->() const
dereference operaqtor
Definition: Stat.h:165
Stat::entity
const StatEntity * entity() const
get the entity
Definition: Stat.h:163
Stat::operator+=
Stat & operator+=(const StatEntity &right)
increment with StatEntity object
Definition: Stat.h:250
print
void print(string text)
Definition: mergesort.cpp:33
StatEntity.h
operator+
GAUDI_API Stat operator+(const Stat &stat, const double value)
external operator for addition of Stat and a number
Definition: Stat.cpp:163
operator-
GAUDI_API Stat operator-(const Stat &stat, const double value)
external operator for subtraction of Stat and a number
Definition: Stat.cpp:168
IStatSvc
"Stat"-related part of interface IChronoStatSvc
Definition: IStatSvc.h:25
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
Stat::operator+=
Stat & operator+=(const Stat &right)
increment with other stat objects
Definition: Stat.h:256
ICounterSvc.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
std::ostream
STL class.
Stat::group
const std::string & group() const
counter group (for ICounterSvc)
Definition: Stat.h:280