| The Gaudi Framework v29r1 (5cd95fa2)

- 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/IStatSvc.h"
14 #include "GaudiKernel/SmartIF.h"
15 #include "GaudiKernel/StatEntity.h"
16 // ============================================================================
46 class GAUDI_API Stat
47 {
48 public:
65 Stat( StatEntity* entity = 0, const std::string& name = "", const std::string& group = "" )
66 : m_entity( entity ), m_tag( name ), m_group( group ), m_counter( 0 )
67 {
68 }
83 Stat( StatEntity& entity, const std::string& name = "", const std::string& group = "" )
84 : m_entity( &entity ), m_tag( name ), m_group( group ), m_counter( 0 )
85 {
86 }
105 Stat( IStatSvc* svc, const std::string& tag );
123 Stat( IStatSvc* svc, const std::string& tag, const double flag );
141 Stat( ICounterSvc* svc, const std::string& group, const std::string& name );
143 Stat( const Stat& ) = default;
145 Stat& operator=( const Stat& ) = default;
147 ~Stat() = default;
148 // ==========================================================================
150 const StatEntity* entity() const { return m_entity; }
152 const StatEntity* operator->() const { return entity(); }
154 operator const StatEntity&() const { return *entity(); }
156 bool operator!() const { return 0 == m_entity; }
157 // ==========================================================================
174 Stat& operator+=( const double f )
175 {
176 if ( m_entity ) {
177 ( *m_entity ) += f;
178 }
179 return *this;
180 }
194 Stat& operator++()
195 {
196 if ( m_entity ) {
197 ++( *m_entity );
198 }
199 return *this;
200 }
213 Stat& operator++( int )
214 {
215 if ( m_entity ) {
216 ( *m_entity )++;
217 }
218 return *this;
219 }
225 Stat& operator-=( const double f )
226 {
227 if ( m_entity ) {
228 ( *m_entity ) -= f;
229 }
230 return *this;
231 }
233 Stat& operator--()
234 {
235 if ( m_entity ) {
236 --( *m_entity );
237 }
238 return *this;
239 }
241 Stat& operator--( int )
242 {
243 if ( m_entity ) {
244 ( *m_entity )--;
245 }
246 return *this;
247 }
249 Stat& operator+=( const StatEntity& right )
250 {
251 if ( m_entity ) {
252 ( *m_entity ) += right;
253 }
254 return *this;
255 }
257 Stat& operator+=( const Stat& right )
258 {
259 if ( 0 != right.entity() ) {
260 ( *this ) += *right.entity();
261 }
262 return *this;
263 }
264 // ==========================================================================
266 std::string toString() const;
271 std::ostream& print( std::ostream& o = std::cout ) const;
276 std::ostream& fillStream( std::ostream& o ) const { return print( o ); }
277 // ==========================================================================
279 StatEntity* counter() const { return m_entity; }
281 const std::string& name() const { return m_tag; }
283 const std::string& group() const { return m_group; }
284 // ==========================================================================
285 private:
286 // underlying counter
287 StatEntity* m_entity = nullptr;
288 // unique stat tag(name)
289 std::string m_tag;
290 // group (for ICounterSvc)
291 std::string m_group;
292 // Stat service
293 SmartIF<IStatSvc> m_stat;
294 // Counter Svc
295 SmartIF<ICounterSvc> m_counter;
296 };
297 // ============================================================================
299 GAUDI_API Stat operator+( const Stat& stat, const double value );
300 // ============================================================================
302 GAUDI_API Stat operator-( const Stat& stat, const double value );
303 // ============================================================================
305 GAUDI_API Stat operator+( const double value, const Stat& stat );
306 // ============================================================================
308 GAUDI_API Stat operator+( const Stat& stat, const Stat& value );
309 // ============================================================================
311 GAUDI_API std::ostream& operator<<( std::ostream& stream, const Stat& stat );
312 // ============================================================================
313
314 // ============================================================================
315 // The END
316 // ============================================================================
317 #endif // __GAUDI_CHRONOSTATSVC_STAT_H__
318 // ============================================================================
Gaudi::Utils::Histos::Formats::Stat
Definition: HistoTableFormat.h:94
SmartIF< IStatSvc >
Stat::operator-=
Stat & operator-=(const double f)
General decrement operator for the counter.
Definition: Stat.h:225
Stat::operator!
bool operator!() const
check validity
Definition: Stat.h:156
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
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:293
Stat::counter
StatEntity * counter() const
alternative access to underlying counter (for ICounterSvc::CounterObj)
Definition: Stat.h:279
Stat::name
const std::string & name() const
counter name
Definition: Stat.h:281
Stat::operator++
Stat & operator++(int)
Post-increment operator for the counter.
Definition: Stat.h:213
Stat::fillStream
std::ostream & fillStream(std::ostream &o) const
printout to std::ostream
Definition: Stat.h:276
Stat::operator++
Stat & operator++()
Pre-increment operator for the counter.
Definition: Stat.h:194
Stat::operator+=
Stat & operator+=(const double f)
General increment for the counter.
Definition: Stat.h:174
operator<<
GAUDI_API std::ostream & operator<<(std::ostream &stream, const Stat &stat)
external printout operator to std::ostream
Definition: Stat.cpp:175
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
std::string
STL class.
Stat::operator--
Stat & operator--()
Pre-decrement operator for the flag.
Definition: Stat.h:233
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:289
Stat::m_counter
SmartIF< ICounterSvc > m_counter
Counter Service.
Definition: Stat.h:295
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:291
Stat::operator--
Stat & operator--(int)
Post-decrement operator for the flag.
Definition: Stat.h:241
Stat::Stat
Stat(StatEntity &entity, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
Definition: Stat.h:83
Stat::operator->
const StatEntity * operator->() const
dereference operaqtor
Definition: Stat.h:152
Stat::entity
const StatEntity * entity() const
get the entity
Definition: Stat.h:150
Stat::operator+=
Stat & operator+=(const StatEntity &right)
increment with StatEntity object
Definition: Stat.h:249
print
void print(string text)
Definition: mergesort.cpp:30
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:141
operator-
GAUDI_API Stat operator-(const Stat &stat, const double value)
external operator for subtraction of Stat and a number
Definition: Stat.cpp:150
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:257
ICounterSvc.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
std::ostream
STL class.
GaudiMath::Interpolation::toString
std::string toString(const Type &)
Definition: Interpolation.cpp:42
Stat::group
const std::string & group() const
counter group (for ICounterSvc)
Definition: Stat.h:283