| 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 Attributes | List of all members
Stat Class Reference

Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface. More...

`#include <GaudiKernel/Stat.h>`

Collaboration diagram for Stat:
[legend]

## Public Member Functions
| Stat (StatEntity *entity=0, const std::string &name="", const std::string &group="")
| constructor from StatEntity, name and group : More...
| Stat (StatEntity &entity, const std::string &name="", const std::string &group="")
| constructor from StatEntity, name and group : More...
| Stat (IStatSvc *svc, const std::string &tag)
| constructor from IStatSvc, tag and value More...
| Stat (IStatSvc *svc, const std::string &tag, const double flag)
| constructor from IStatSvc, tag and value More...
| Stat (ICounterSvc *svc, const std::string &group, const std::string &name)
| constructor from ICounterSvc, group and name More...
| Stat (const Stat &)=default
| copy constructor More...
Stat & | operator= (const Stat &)=default
| Assignement operator. More...
| ~Stat ()=default
| destructor More...
const StatEntity * | entity () const
| get the entity More...
const StatEntity * | operator-> () const
| dereference operaqtor More...
| operator const StatEntity & () const
| cast to StatEntity More...
bool | operator! () const
| check validity More...
Stat & | operator+= (const double f)
| General increment for the counter. More...
Stat & | operator++ ()
| Pre-increment operator for the counter. More...
Stat & | operator++ (int)
| Post-increment operator for the counter. More...
Stat & | operator-= (const double f)
| General decrement operator for the counter. More...
Stat & | operator-- ()
| Pre-decrement operator for the flag. More...
Stat & | operator-- (int)
| Post-decrement operator for the flag. More...
Stat & | operator+= (const StatEntity &right)
| increment with StatEntity object More...
Stat & | operator+= (const Stat &right)
| increment with other stat objects More...
std::string | toString () const
| representation as string More...
std::ostream & | print (std::ostream &o=std::cout) const
| printout to std::ostream More...
std::ostream & | fillStream (std::ostream &o) const
| printout to std::ostream More...
StatEntity * | counter () const
| alternative access to underlying counter (for ICounterSvc::CounterObj) More...
const std::string & | name () const
| counter name More...
const std::string & | group () const
| counter group (for ICounterSvc) More...

## Private Attributes
StatEntity * | m_entity = nullptr
| underlying counter More...
std::string | m_tag
| unique stat tag(name) More...
std::string | m_group
SmartIF< IStatSvc > | m_stat
| Stat service. More...
SmartIF< ICounterSvc > | m_counter
| Counter Service. More...

## Detailed Description

Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface.

It acts as "smart pointer" fro StatEntity objects, and allows manipulation with StatEntity objects, owned by GaudiCommon<TYPE> base class and/or IStatSvc/ICounterSvc

long nTracks = ... ;
Stat stat( chronoSvc() , "#tracks" , nTracks ) ;

Alternatively one can use operator methods:

long nTracks = ... ;
Stat stat( chronoSvc() , "#tracks" ) ;
stat += nTracks ;

Author
  Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr

Date
  2007-08-02

Definition at line 46 of file Stat.h.

## Constructor & Destructor Documentation

Stat::Stat | ( | StatEntity * | entity = `0`,
|  | const std::string & | name = `""`,
|  | const std::string & | group = `""`
| ) |  |
| inline

constructor from StatEntity, name and group :

StatEntity* entity = ... ;
// make helper object:
Stat stat ( entity ) ;

See also
  StatEntity

Parameters

  entity | pointer to entity object
  name | (optional) name of the object, for printout
  group | (optional) group of the object, for printout

Definition at line 65 of file Stat.h.

68 : m_entity ( entity )
69 , m_tag ( name )
70 , m_group ( group )
71 , m_counter ( 0 )
72 {}
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284
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
Stat::m_group
std::string m_group
Definition: Stat.h:288

Stat::Stat | ( | StatEntity & | entity,
|  | const std::string & | name = `""`,
|  | const std::string & | group = `""`
| ) |  |
| inline

constructor from StatEntity, name and group :

// make helper object:
Stat stat = Stat( countter("Name") , "Name" ) ;

See also
  StatEntity
  GaudiCommon::counter

Parameters

  entity | reference to entity object
  name | (optional) name of the object, for printout
  group | (optional) group of the object, for printout

Definition at line 87 of file Stat.h.

90 : m_entity ( &entity )
91 , m_tag ( name )
92 , m_group ( group )
93 , m_counter ( 0 )
94 {}
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284
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
Stat::m_group
std::string m_group
Definition: Stat.h:288

Stat::Stat | ( | IStatSvc * | svc,
|  | const std::string & | tag
| ) |  |

constructor from IStatSvc, tag and value

IStatSvc* svc = ... ;
double eTotal = .... ;
// get/create the counter from Stat Service
Stat eTot ( svc , "total energy" ) ;
eTot += eTotal ;

See also
  IStatSvc

Parameters

  svc | pointer to Chrono&Stat Service tag unique tag for the entry

Definition at line 43 of file Stat.cpp.

45 : m_tag ( tag )
46 , m_group ( )
47 , m_stat ( svc )
48 {
49 if ( m_stat )
50 {
51 // get from the service
52 const StatEntity* tmp = m_stat->stat ( tag ) ;
53 if ( !tmp )
54 {
55 // create if needed
56 m_stat->stat ( tag , 0 ) ;
57 tmp = m_stat->stat ( tag ) ;
58 StatEntity* aux = const_cast<StatEntity*>( tmp );
59 aux->reset () ;
60 }
61 m_entity = const_cast<StatEntity*> ( tmp ) ;
62 }
63 }
Stat::m_stat
SmartIF< IStatSvc > m_stat
Stat service.
Definition: Stat.h:290
IStatSvc::stat
virtual void stat(const StatTag &t, const StatFlag &f)=0
add statistical information to the entity , tagged by its name
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284
StatEntity::reset
void reset()
reset the counters
Definition: StatEntity.cpp:232
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:286
Stat::m_group
std::string m_group
Definition: Stat.h:288
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65

Stat::Stat | ( | IStatSvc * | svc,
|  | const std::string & | tag,
|  | const double | flag
| ) |  |

constructor from IStatSvc, tag and value

IStatSvc* svc = ... ;
double eTotal = .... ;
// get/create the counter from Stat Service
Stat stat( svc , "total energy" , eTotal ) ;

See also
  IStatSvc

Parameters

  svc | pointer to Chrono&Stat Service tag unique tag for the entry
  flag | "flag"(additive quantity) to be used

Definition at line 82 of file Stat.cpp.

85 : m_tag ( tag )
86 , m_group ( )
87 , m_stat ( svc )
88 {
89 if ( m_stat )
90 {
91 m_stat -> stat( tag , flag ) ;
92 // get from the service
93 m_entity = const_cast<StatEntity*>( m_stat -> stat ( tag ) ) ;
94 }
95 }
Stat::m_stat
SmartIF< IStatSvc > m_stat
Stat service.
Definition: Stat.h:290
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:286
Stat::m_group
std::string m_group
Definition: Stat.h:288
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65

Stat::Stat | ( | ICounterSvc * | svc,
|  | const std::string & | group,
|  | const std::string & | name
| ) |  |

constructor from ICounterSvc, group and name

ICounterSvc* svc = ... ;
// get/create the counter from Counter Service
Stat stat( svc , "ECAL" , "TotalEnergy" ) ;

See also
  ICounterSvc::get
  ICounterSvc::create

Parameters

  svc | pointer to Counter Service
  group | group name
  name | counter name

Definition at line 105 of file Stat.cpp.

108 : m_tag ( name )
109 , m_group ( group )
110 , m_counter ( svc )
111 {
112 if ( m_counter )
113 {
114 // get from the service
115 m_entity = m_counter -> get ( group , name ) ;
116 // create if needed:
117 if ( ! m_entity ) { m_counter -> create( group , name , 0 , m_entity ) ; }
118 }
119 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284
Stat::name
const std::string & name() const
counter name
Definition: Stat.h:278
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
Stat::m_group
std::string m_group
Definition: Stat.h:288
Stat::group
const std::string & group() const
counter group (for ICounterSvc)
Definition: Stat.h:280

Stat::Stat | ( | const Stat & |  | ) |
| default

copy constructor

Stat::~Stat | ( |  | ) |
| default

destructor

## Member Function Documentation

StatEntity* Stat::counter | ( |  | ) | const
| inline

alternative access to underlying counter (for ICounterSvc::CounterObj)

Definition at line 276 of file Stat.h.

276 { return m_entity ; }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

const StatEntity* Stat::entity | ( |  | ) | const
| inline

get the entity

Definition at line 163 of file Stat.h.

163 { return m_entity ; }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

std::ostream& Stat::fillStream | ( | std::ostream & | o | ) | const
| inline

printout to std::ostream

Parameters

  s | the reference to the output stream

Returns
  the reference to the output stream

Definition at line 273 of file Stat.h.

273 { return print ( o ) ; }
Stat::print
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
Definition: Stat.cpp:135

const std::string& Stat::group | ( |  | ) | const
| inline

counter group (for ICounterSvc)

Definition at line 280 of file Stat.h.

280 { return m_group ; }
Stat::m_group
std::string m_group
Definition: Stat.h:288

const std::string& Stat::name | ( |  | ) | const
| inline

counter name

Definition at line 278 of file Stat.h.

278 { return m_tag ; }
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:286

Stat::operator const StatEntity & | ( |  | ) | const
| inline

cast to StatEntity

Definition at line 167 of file Stat.h.

167 { return *entity() ; }
Stat::entity
const StatEntity * entity() const
get the entity
Definition: Stat.h:163

bool Stat::operator! | ( |  | ) | const
| inline

check validity

Definition at line 169 of file Stat.h.

169 { return 0 == m_entity ; }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator++ | ( |  | ) |
| inline

Pre-increment operator for the counter.

Stat stat = ... ;
++stat ;

See also
  StatEntity

Returns
  selfreference

Definition at line 205 of file Stat.h.

206 {
207 if ( m_entity ) { ++(*m_entity) ; }
208 return *this ;
209 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator++ | ( | int |  | ) |
| inline

Post-increment operator for the counter.

Stat stat = ... ;
stat++ ;

See also
  StatEntity

Returns
  self-reference

Definition at line 222 of file Stat.h.

223 {
224 if ( m_entity ) { (*m_entity)++ ; }
225 return *this ;
226 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator+= | ( | const double | f | ) |
| inline

General increment for the counter.

Stat stat = ... ;
const long nTracks = ... ;
stat += nTracks ;

See also
  StatEntity

Parameters

  f | value to be added to the counter

Returns
  selfreference

Definition at line 187 of file Stat.h.

188 {
189 if ( m_entity ) { (*m_entity) += f ; }
190 return *this ;
191 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator+= | ( | const StatEntity & | right | ) |
| inline

increment with StatEntity object

Definition at line 250 of file Stat.h.

251 {
252 if ( m_entity ) { (*m_entity) += right ; }
253 return *this ;
254 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator+= | ( | const Stat & | right | ) |
| inline

increment with other stat objects

Definition at line 256 of file Stat.h.

257 {
258 if ( 0 != right.entity() ) { (*this) += *right.entity() ; }
259 return *this ;
260 }
Stat::entity
const StatEntity * entity() const
get the entity
Definition: Stat.h:163

Stat& Stat::operator-- | ( |  | ) |
| inline

Pre-decrement operator for the flag.

Definition at line 238 of file Stat.h.

239 {
240 if ( m_entity ) { --(*m_entity) ; }
241 return *this ;
242 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator-- | ( | int |  | ) |
| inline

Post-decrement operator for the flag.

Definition at line 244 of file Stat.h.

245 {
246 if ( m_entity ) { (*m_entity)-- ; }
247 return *this ;
248 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

Stat& Stat::operator-= | ( | const double | f | ) |
| inline

General decrement operator for the counter.

See also
  StatEntity

Returns
  self-reference

Parameters

  f | counter decrement

Definition at line 232 of file Stat.h.

233 {
234 if ( m_entity ) { (*m_entity) -= f ; }
235 return *this ;
236 }
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284

const StatEntity* Stat::operator-> | ( |  | ) | const
| inline

dereference operaqtor

Definition at line 165 of file Stat.h.

165 { return entity() ; }
Stat::entity
const StatEntity * entity() const
get the entity
Definition: Stat.h:163

Stat& Stat::operator= | ( | const Stat & |  | ) |
| default

Assignement operator.

std::ostream & Stat::print | ( | std::ostream & | o = `std::cout` | ) | const

printout to std::ostream

Parameters

  s | the reference to the output stream

Returns
  the reference to the output stream

Definition at line 135 of file Stat.cpp.

136 {
137 if ( m_group.empty() && m_tag.empty() )
138 { return !m_entity ? ( o << "NULL" ) : ( o << m_entity ) ; }
139 if ( !m_group.empty() )
140 {
141 if ( m_entity )
142 {
143 return o << boost::format(" %|1$15s|::%|2$-15s| %|32t|%3%")
144 % ( "\"" + m_group ) % ( m_tag + "\"") % (*m_entity) ;
145 }
146 else
147 {
148 return o << boost::format(" %|1$15s|::%|2$-15s| %|32t|%NULL%")
149 % ( "\"" + m_group ) % ( m_tag + "\"") ;
150 }
151 }
152 if ( m_entity )
153 {
154 return o << boost::format(" %|1$=30s| %|32t|%2%")
155 % ("\"" + m_tag + "\"" ) % (*m_entity) ;
156 }
157 return o << boost::format(" %|1$=30s| %|32t|%NULL%")
158 % ( "\"" + m_tag + "\"" ) ;
159 }
std::string::empty
T empty(T...args)
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
Stat::m_entity
StatEntity * m_entity
underlying counter
Definition: Stat.h:284
Stat::m_tag
std::string m_tag
unique stat tag(name)
Definition: Stat.h:286
Stat::m_group
std::string m_group
Definition: Stat.h:288

std::string Stat::toString | ( |  | ) | const

representation as string

Definition at line 124 of file Stat.cpp.

125 {
126 std::ostringstream ost ;
127 print ( ost ) ;
128 return ost.str () ;
129 }
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
Stat::print
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
Definition: Stat.cpp:135

## Member Data Documentation

SmartIF<ICounterSvc> Stat::m_counter
| private

Counter Service.

Definition at line 292 of file Stat.h.

StatEntity* Stat::m_entity = nullptr
| private

underlying counter

Definition at line 284 of file Stat.h.

std::string Stat::m_group
| private

Definition at line 288 of file Stat.h.

SmartIF<IStatSvc> Stat::m_stat
| private

Stat service.

Definition at line 290 of file Stat.h.

std::string Stat::m_tag
| private

unique stat tag(name)

Definition at line 286 of file Stat.h.

The documentation for this class was generated from the following files:

- GaudiKernel/GaudiKernel/Stat.h
- GaudiKernel/src/Lib/Stat.cpp