| The Gaudi Framework v32r1 (f65d50dc)

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 <iostream>
9 #include <string>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/IStatSvc.h"
14 #include "GaudiKernel/SmartIF.h"
15 #include "GaudiKernel/StatEntity.h"
16 // ============================================================================
46 class GAUDI_API Stat {
47 public:
64 Stat( StatEntity* entity = 0, const std::string& name = "", const std::string& group = "" )
65 : m_entity( entity ), m_tag( name ), m_group( group ) {}
80 Stat( StatEntity& entity, const std::string& name = "", const std::string& group = "" )
81 : m_entity( &entity ), m_tag( name ), m_group( group ) {}
100 Stat( IStatSvc* svc, const std::string& tag );
118 Stat( IStatSvc* svc, const std::string& tag, const double flag );
120 Stat( const Stat& ) = default;
122 Stat& operator=( const Stat& ) = default;
124 ~Stat() = default;
125 // ==========================================================================
127 const StatEntity* entity() const { return m_entity; }
129 const StatEntity* operator->() const { return entity(); }
131 operator const StatEntity&() const { return *entity(); }
133 bool operator!() const { return 0 == m_entity; }
134 // ==========================================================================
151 Stat& operator+=( const double f ) {
152 if ( m_entity ) { ( *m_entity ) += f; }
153 return *this;
154 }
168 Stat& operator++() {
169 if ( m_entity ) { ++( *m_entity ); }
170 return *this;
171 }
184 Stat& operator++( int ) {
185 if ( m_entity ) { ( *m_entity )++; }
186 return *this;
187 }
193 Stat& operator-=( const double f ) {
194 if ( m_entity ) { ( *m_entity ) -= f; }
195 return *this;
196 }
198 Stat& operator--() {
199 if ( m_entity ) { --( *m_entity ); }
200 return *this;
201 }
203 Stat& operator--( int ) {
204 if ( m_entity ) { ( *m_entity )--; }
205 return *this;
206 }
208 Stat& operator+=( const StatEntity& right ) {
209 if ( m_entity ) { ( *m_entity ) += right; }
210 return *this;
211 }
213 Stat& operator+=( const Stat& right ) {
214 if ( 0 != right.entity() ) { ( *this ) += *right.entity(); }
215 return *this;
216 }
217 // ==========================================================================
219 std::string toString() const;
224 std::ostream& print( std::ostream& o = std::cout ) const;
229 std::ostream& fillStream( std::ostream& o ) const { return print( o ); }
230 // ==========================================================================
232 StatEntity* counter() const { return m_entity; }
234 const std::string& name() const { return m_tag; }
236 const std::string& group() const { return m_group; }
237 // ==========================================================================
238 private:
239 // underlying counter
240 StatEntity* m_entity = nullptr;
241 // unique stat tag(name)
242 std::string m_tag;
243 // group
244 std::string m_group;
245 // Stat service
246 SmartIF<IStatSvc> m_stat;
247 };
248 // ============================================================================
250 GAUDI_API Stat operator+( const Stat& stat, const double value );
251 // ============================================================================
253 GAUDI_API Stat operator-( const Stat& stat, const double value );
254 // ============================================================================
256 GAUDI_API Stat operator+( const double value, const Stat& stat );
257 // ============================================================================
259 GAUDI_API Stat operator+( const Stat& stat, const Stat& value );
260 // ============================================================================
262 GAUDI_API std::ostream& operator<<( std::ostream& stream, const Stat& stat );
263 // ============================================================================
264
265 // ============================================================================
266 // The END
267 // ============================================================================
268 #endif // __GAUDI_CHRONOSTATSVC_STAT_H__
Gaudi::Utils::Histos::Formats::Stat
Definition: HistoTableFormat.h:90
SmartIF< IStatSvc >
Stat::counter
StatEntity * counter() const
alternative access to underlying counter
Definition: Stat.h:232
Stat::entity
const StatEntity * entity() const
get the entity
Definition: Stat.h:127
Stat::operator-=
Stat & operator-=(const double f)
General decrement operator for the counter.
Definition: Stat.h:193
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc interface.
Definition: Stat.h:46
Stat::m_stat
SmartIF< IStatSvc > m_stat
Stat service.
Definition: Stat.h:246
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:334
Stat::fillStream
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: Stat.h:229
Stat::operator++
Stat & operator++(int)
Post-increment operator for the counter.
Definition: Stat.h:184
Stat::operator++
Stat & operator++()
Pre-increment operator for the counter.
Definition: Stat.h:168
Stat::operator+=
Stat & operator+=(const double f)
General increment for the counter.
Definition: Stat.h:151
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Stat &stat)
external printout operator to std::ostream
Definition: Stat.cpp:140
std::string
STL class.
Stat::operator--
Stat & operator--()
Pre-decrement operator for the flag.
Definition: Stat.h:198
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:242
IStatSvc.h
Stat::name
const std::string & name() const
counter name
Definition: Stat.h:234
Stat::operator->
const StatEntity * operator->() const
dereference operaqtor
Definition: Stat.h:129
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:64
Stat::m_group
std::string m_group
Definition: Stat.h:244
Stat::operator--
Stat & operator--(int)
Post-decrement operator for the flag.
Definition: Stat.h:203
Stat::Stat
Stat(StatEntity &entity, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
Definition: Stat.h:80
Stat::operator+=
Stat & operator+=(const StatEntity &right)
increment with StatEntity object
Definition: Stat.h:208
Stat::operator!
bool operator!() const
check validity
Definition: Stat.h:133
StatEntity.h
Stat::group
const std::string & group() const
counter group
Definition: Stat.h:236
operator+
GAUDI_API Stat operator+(const Stat &stat, const double value)
external operator for addition of Stat and a number
Definition: Stat.cpp:110
operator-
GAUDI_API Stat operator-(const Stat &stat, const double value)
external operator for subtraction of Stat and a number
Definition: Stat.cpp:118
IStatSvc
"Stat"-related part of interface IChronoStatSvc
Definition: IStatSvc.h:25
Stat::operator+=
Stat & operator+=(const Stat &right)
increment with other stat objects
Definition: Stat.h:213
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
std::ostream
STL class.