Small wrapper class for easy manipulation with generic counters and IStatSvc interface.
More...
#include <GaudiKernel/Stat.h>
|
| Stat (StatEntity *entity=0, const std::string &name="", const std::string &group="") |
| constructor from StatEntity, name and group :
|
|
| Stat (StatEntity &entity, const std::string &name="", const std::string &group="") |
| constructor from StatEntity, name and group :
|
|
| Stat (IStatSvc *svc, const std::string &tag) |
| constructor from IStatSvc, tag and value
|
|
| Stat (IStatSvc *svc, const std::string &tag, const double flag) |
| constructor from IStatSvc, tag and value
|
|
| Stat (const Stat &)=default |
| copy constructor
|
|
Stat & | operator= (const Stat &)=default |
| Assignement operator.
|
|
| ~Stat ()=default |
| destructor
|
|
const StatEntity * | entity () const |
| get the entity
|
|
const StatEntity * | operator-> () const |
| dereference operaqtor
|
|
| operator const StatEntity & () const |
| cast to StatEntity
|
|
bool | operator! () const |
| check validity
|
|
Stat & | operator+= (const double f) |
| General increment for the counter.
|
|
Stat & | operator++ () |
| Pre-increment operator for the counter.
|
|
Stat & | operator++ (int) |
| Post-increment operator for the counter.
|
|
Stat & | operator-= (const double f) |
| General decrement operator for the counter.
|
|
Stat & | operator-- () |
| Pre-decrement operator for the flag.
|
|
Stat & | operator-- (int) |
| Post-decrement operator for the flag.
|
|
Stat & | operator+= (const StatEntity &right) |
| increment with StatEntity object
|
|
Stat & | operator+= (const Stat &right) |
| increment with other stat objects
|
|
std::string | toString () const |
| representation as string
|
|
std::ostream & | print (std::ostream &o=std::cout) const |
| printout to std::ostream
|
|
std::ostream & | fillStream (std::ostream &o) const |
| printout to std::ostream
|
|
StatEntity * | counter () const |
| alternative access to underlying counter
|
|
const std::string & | name () const |
| counter name
|
|
const std::string & | group () const |
| counter group
|
|
Small wrapper class for easy manipulation with generic counters and IStatSvc interface.
It acts as "smart pointer" fro StatEntity objects, and allows manipulation with StatEntity objects, owned by GaudiCommon<TYPE> base class and/or IStatSvc
long nTracks = ... ;
Stat stat( chronoSvc() ,
"#tracks" , nTracks ) ;
Stat(StatEntity *entity=0, const std::string &name="", const std::string &group="")
constructor from StatEntity, name and group :
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 48 of file Stat.h.
◆ Stat() [1/5]
Stat::Stat |
( |
StatEntity * | entity = 0, |
|
|
const std::string & | name = "", |
|
|
const std::string & | group = "" ) |
|
inline |
constructor from StatEntity, name and group :
backward compatible StatEntity class.
const StatEntity * entity() const
get the 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 66 of file Stat.h.
std::string m_tag
unique stat tag(name)
StatEntity * m_entity
underlying counter
const std::string & name() const
counter name
const std::string & group() const
counter group
◆ Stat() [2/5]
Stat::Stat |
( |
StatEntity & | entity, |
|
|
const std::string & | name = "", |
|
|
const std::string & | group = "" ) |
|
inline |
constructor from StatEntity, name and group :
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 82 of file Stat.h.
◆ Stat() [3/5]
Stat::Stat |
( |
IStatSvc * | svc, |
|
|
const std::string & | tag ) |
constructor from IStatSvc, tag and value
double eTotal = .... ;
Stat eTot ( svc ,
"total energy" ) ;
eTot += eTotal ;
"Stat"-related part of interface IChronoStatSvc
- See also
- IStatSvc
- Parameters
-
Definition at line 28 of file Stat.cpp.
30
31 StatEntity* tmp =
m_stat->stat( tag );
32 if ( !tmp ) {
33
37 }
39 }
40}
friend void reset(StatEntity &s)
SmartIF< IStatSvc > m_stat
Stat service.
◆ Stat() [4/5]
Stat::Stat |
( |
IStatSvc * | svc, |
|
|
const std::string & | tag, |
|
|
const double | flag ) |
constructor from IStatSvc, tag and value
double eTotal = .... ;
Stat stat( svc ,
"total energy" , eTotal ) ;
- See also
- IStatSvc
- Parameters
-
svc | pointer to Chrono&Stat Service @paran tag unique tag for the entry |
flag | "flag"(additive quantity) to be used |
Definition at line 42 of file Stat.cpp.
◆ Stat() [5/5]
Stat::Stat |
( |
const Stat & | | ) |
|
|
default |
◆ ~Stat()
◆ counter()
alternative access to underlying counter
Definition at line 230 of file Stat.h.
◆ entity()
get the entity
Definition at line 128 of file Stat.h.
◆ fillStream()
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 228 of file Stat.h.
228{
return print( o ); }
std::ostream & print(std::ostream &o=std::cout) const
printout to std::ostream
◆ group()
const std::string & Stat::group |
( |
| ) |
const |
|
inline |
counter group
Definition at line 234 of file Stat.h.
◆ name()
const std::string & Stat::name |
( |
| ) |
const |
|
inline |
counter name
Definition at line 232 of file Stat.h.
◆ operator const StatEntity &()
◆ operator!()
bool Stat::operator! |
( |
| ) |
const |
|
inline |
check validity
Definition at line 134 of file Stat.h.
◆ operator++() [1/2]
Stat & Stat::operator++ |
( |
| ) |
|
|
inline |
Pre-increment operator for the counter.
- See also
- StatEntity
- Returns
- selfreference
Definition at line 168 of file Stat.h.
168 {
169 if (
m_entity ) { ++( *m_entity ); }
170 return *this;
171 }
◆ operator++() [2/2]
Stat & Stat::operator++ |
( |
int | | ) |
|
|
inline |
Post-increment operator for the counter.
- See also
- StatEntity
- Returns
- self-reference
Definition at line 184 of file Stat.h.
184 {
185 if (
m_entity ) { ( *m_entity )++; }
186 return *this;
187 }
◆ operator+=() [1/3]
Stat & Stat::operator+= |
( |
const double | f | ) |
|
|
inline |
General increment for the counter.
const long nTracks = ... ;
stat += nTracks ;
- See also
- StatEntity
- Parameters
-
f | value to be added to the counter |
- Returns
- selfreference
Definition at line 151 of file Stat.h.
151 {
152 if (
m_entity ) { ( *m_entity ) += f; }
153 return *this;
154 }
◆ operator+=() [2/3]
Stat & Stat::operator+= |
( |
const Stat & | right | ) |
|
|
inline |
increment with other stat objects
Definition at line 213 of file Stat.h.
213 {
214 if ( 0 != right.
entity() ) { ( *this ) += *right.
entity(); }
215 return *this;
216 }
◆ operator+=() [3/3]
increment with StatEntity object
Definition at line 208 of file Stat.h.
208 {
209 if (
m_entity ) { ( *m_entity ) += right; }
210 return *this;
211 }
◆ operator--() [1/2]
Stat & Stat::operator-- |
( |
| ) |
|
|
inline |
Pre-decrement operator for the flag.
Definition at line 198 of file Stat.h.
198 {
199 if (
m_entity ) { --( *m_entity ); }
200 return *this;
201 }
◆ operator--() [2/2]
Stat & Stat::operator-- |
( |
int | | ) |
|
|
inline |
Post-decrement operator for the flag.
Definition at line 203 of file Stat.h.
203 {
204 if (
m_entity ) { ( *m_entity )--; }
205 return *this;
206 }
◆ operator-=()
Stat & Stat::operator-= |
( |
const double | f | ) |
|
|
inline |
General decrement operator for the counter.
- See also
- StatEntity
- Returns
- self-reference
- Parameters
-
Definition at line 193 of file Stat.h.
193 {
194 if (
m_entity ) { ( *m_entity ) -= f; }
195 return *this;
196 }
◆ operator->()
dereference operaqtor
Definition at line 130 of file Stat.h.
◆ operator=()
◆ print()
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 56 of file Stat.cpp.
56 {
58 std::string tag;
59 if ( !
m_tag.empty() ) {
62 } else {
63 tag = fmt::format(
"\"{}\"",
m_tag );
64 }
65 }
66 return o << fmt::format(
" {:^30} {}", tag,
entity );
67}
◆ toString()
std::string Stat::toString |
( |
| ) |
const |
representation as string
Definition at line 50 of file Stat.cpp.
50 {
51 std::ostringstream ost;
53 return ost.str();
54}
◆ m_entity
underlying counter
Definition at line 238 of file Stat.h.
◆ m_group
std::string Stat::m_group |
|
private |
◆ m_stat
◆ m_tag
unique stat tag(name)
Definition at line 240 of file Stat.h.
The documentation for this class was generated from the following files: