![]() |
|
|
Generated: 18 Jul 2008 |
#include <GaudiKernel/Stat.h>
Collaboration diagram for Stat:

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 ;
Definition at line 50 of file Stat.h.
Public Member Functions | |
| 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 (ICounterSvc *svc, const std::string &group, const std::string &name) | |
| constructor from ICounterSvc, group and name | |
| Stat (const Stat &right) | |
| copy constructor | |
| Stat & | operator= (const Stat &right) |
| Assignement operator. | |
| ~Stat () | |
| 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 (for ICounterSvc::CounterObj) | |
| const std::string & | name () const |
| counter name | |
| const std::string & | group () const |
| counter group (for ICounterSvc) | |
Private Attributes | |
| StatEntity * | m_entity |
| underlying counter | |
| std::string | m_tag |
| unique stat tag(name) | |
| std::string | m_group |
| IStatSvc * | m_stat |
| Stat service. | |
| ICounterSvc * | m_counter |
| Counter Service. | |
| 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 ) ;
| entity | pointer to entity object | |
| name | (optional) name of the object, for printout | |
| group | (optional) group of the object, for printout |
Definition at line 69 of file Stat.h.
00072 : m_entity ( entity ) 00073 , m_tag ( name ) 00074 , m_group ( group ) 00075 , m_stat ( 0 ) 00076 , m_counter ( 0 ) 00077 {}
| Stat::Stat | ( | StatEntity & | entity, | |
| const std::string & | name = "", |
|||
| const std::string & | group = "" | |||
| ) | [inline] |
constructor from StatEntity, name and group :
| entity | reference to entity object | |
| name | (optional) name of the object, for printout | |
| group | (optional) group of the object, for printout |
Definition at line 92 of file Stat.h.
00095 : m_entity ( &entity ) 00096 , m_tag ( name ) 00097 , m_group ( group ) 00098 , m_stat ( 0 ) 00099 , m_counter ( 0 ) 00100 {}
| 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 ;
Definition at line 44 of file Stat.cpp.
References m_entity, m_stat, StatEntity::reset(), and IStatSvc::stat().
00046 : m_entity ( 0 ) 00047 , m_tag ( tag ) 00048 , m_group ( ) 00049 , m_stat ( svc ) 00050 , m_counter ( 0 ) 00051 { 00052 if ( 0 != m_stat ) 00053 { 00054 m_stat -> addRef() ; 00055 // get from the service 00056 const StatEntity* tmp = m_stat->stat ( tag ) ; 00057 if ( 0 == tmp ) 00058 { 00059 // create if needed 00060 m_stat->stat ( tag , 0 ) ; 00061 tmp = m_stat->stat ( tag ) ; 00062 StatEntity* aux = const_cast<StatEntity*>( tmp ); 00063 aux->reset () ; 00064 } 00065 m_entity = const_cast<StatEntity*> ( tmp ) ; 00066 } 00067 }
| 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 ) ;
| svc | pointer to Chrono&Stat Service tag unique tag for the entry | |
| flag | "flag"(additive quantity) to be used |
Definition at line 86 of file Stat.cpp.
References m_entity, and m_stat.
00089 : m_entity ( 0 ) 00090 , m_tag ( tag ) 00091 , m_group ( ) 00092 , m_stat ( svc ) 00093 , m_counter ( 0 ) 00094 { 00095 if ( 0 != m_stat ) 00096 { 00097 m_stat -> addRef() ; 00098 m_stat -> stat( tag , flag ) ; 00099 // get from the service 00100 m_entity = const_cast<StatEntity*>( m_stat -> stat ( tag ) ) ; 00101 } 00102 }
| 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" ) ;
| svc | pointer to Counter Service | |
| group | group name | |
| name | counter name |
Definition at line 112 of file Stat.cpp.
References get(), group(), m_counter, m_entity, and name().
00115 : m_entity ( 0 ) 00116 , m_tag ( name ) 00117 , m_group ( group ) 00118 , m_stat ( 0 ) 00119 , m_counter ( svc ) 00120 { 00121 if ( 0 != m_counter ) 00122 { 00123 m_counter -> addRef() ; 00124 // get from the service 00125 m_entity = m_counter -> get ( group , name ) ; 00126 // create if needed: 00127 if ( 0 == m_entity ) { m_counter -> create( group , name , 0 , m_entity ) ; } 00128 } 00129 }
| Stat::Stat | ( | const Stat & | right | ) |
copy constructor
Definition at line 133 of file Stat.cpp.
References m_counter, and m_stat.
00134 : m_entity ( right.m_entity ) 00135 , m_tag ( right.m_tag ) 00136 , m_group ( right.m_group ) 00137 , m_stat ( right.m_stat ) 00138 , m_counter ( right.m_counter ) 00139 { 00140 if ( 0 != m_stat ) { m_stat -> addRef () ; } 00141 if ( 0 != m_counter ) { m_counter -> addRef () ; } 00142 }
| Stat::~Stat | ( | ) |
Assignement operator.
Definition at line 146 of file Stat.cpp.
References counter(), m_counter, m_entity, m_group, m_stat, and m_tag.
00147 { 00148 if ( this == &right ) { return *this ; } 00149 m_entity = right.m_entity ; 00150 m_tag = right.m_tag ; 00151 m_group = right.m_group ; 00152 { 00153 IStatSvc* stat= right.m_stat ; 00154 if ( 0 != stat ) { stat -> addRef() ; } 00155 if ( 0 != m_stat ) { m_stat -> release() ; m_stat = 0 ; } 00156 m_stat = stat ; 00157 } 00158 { 00159 ICounterSvc* counter= right.m_counter ; 00160 if ( 0 != counter ) { counter -> addRef() ; } 00161 if ( 0 != m_counter ) { m_counter -> release() ; m_counter = 0 ; } 00162 m_counter = counter ; 00163 } 00164 return *this ; 00165 }
| const StatEntity* Stat::entity | ( | ) | const [inline] |
get the entity
Definition at line 169 of file Stat.h.
References m_entity.
Referenced by operator const StatEntity &(), operator+=(), and operator->().
00169 { return m_entity ; }
| const StatEntity* Stat::operator-> | ( | ) | const [inline] |
| Stat::operator const StatEntity & | ( | ) | const [inline] |
cast to StatEntity
Definition at line 173 of file Stat.h.
References entity().
00173 { return *entity() ; }
| bool Stat::operator! | ( | ) | const [inline] |
| Stat& Stat::operator+= | ( | const double | f | ) | [inline] |
General increment for the counter.
Stat stat = ... ; const long nTracks = ... ; stat += nTracks ;
| f | value to be added to the counter |
Definition at line 193 of file Stat.h.
References m_entity.
00194 { 00195 if ( 0 != m_entity ) { (*m_entity) += f ; } 00196 return *this ; 00197 }
| Stat& Stat::operator++ | ( | ) | [inline] |
| Stat& Stat::operator++ | ( | int | ) | [inline] |
| Stat& Stat::operator-= | ( | const double | f | ) | [inline] |
General decrement operator for the counter.
| f | counter decrement |
Definition at line 238 of file Stat.h.
References m_entity.
00239 { 00240 if ( 0 != m_entity ) { (*m_entity) -= f ; } 00241 return *this ; 00242 }
| Stat& Stat::operator-- | ( | ) | [inline] |
| Stat& Stat::operator-- | ( | int | ) | [inline] |
| Stat& Stat::operator+= | ( | const StatEntity & | right | ) | [inline] |
increment with StatEntity object
Definition at line 256 of file Stat.h.
References m_entity.
00257 { 00258 if ( 0 != m_entity ) { (*m_entity) += right ; } 00259 return *this ; 00260 }
| std::string Stat::toString | ( | ) | const |
representation as string
Definition at line 178 of file Stat.cpp.
References print(), and std::basic_ostringstream< _CharT, _Traits, _Alloc >::str().
00179 { 00180 std::ostringstream ost ; 00181 print ( ost ) ; 00182 return ost.str () ; 00183 }
| std::ostream & Stat::print | ( | std::ostream & | o = std::cout |
) | const |
printout to std::ostream
| s | the reference to the output stream |
Definition at line 189 of file Stat.cpp.
References std::basic_string< _CharT, _Traits, _Alloc >::empty(), format(), m_entity, m_group, and m_tag.
Referenced by fillStream(), operator<<(), and toString().
00190 { 00191 if ( m_group.empty() && m_tag.empty() ) 00192 { return 0 == m_entity ? ( o << "NULL" ) : ( o << m_entity ) ; } 00193 if ( !m_group.empty() ) 00194 { 00195 if ( 0 != m_entity ) 00196 { 00197 return o << boost::format(" %|1$15s|::%|2$-15s| %|32t|%3%") 00198 % ( "\"" + m_group ) % ( m_tag + "\"") % (*m_entity) ; 00199 } 00200 else 00201 { 00202 return o << boost::format(" %|1$15s|::%|2$-15s| %|32t|%NULL%") 00203 % ( "\"" + m_group ) % ( m_tag + "\"") ; 00204 } 00205 } 00206 if ( 0 != m_entity ) 00207 { 00208 return o << boost::format(" %|1$=30s| %|32t|%2%") 00209 % ("\"" + m_tag + "\"" ) % (*m_entity) ; 00210 } 00211 return o << boost::format(" %|1$=30s| %|32t|%NULL%") 00212 % ( "\"" + m_tag + "\"" ) ; 00213 }
| std::ostream& Stat::fillStream | ( | std::ostream & | o | ) | const [inline] |
printout to std::ostream
| s | the reference to the output stream |
Definition at line 279 of file Stat.h.
References print().
00279 { return print ( o ) ; }
| StatEntity* Stat::counter | ( | ) | const [inline] |
alternative access to underlying counter (for ICounterSvc::CounterObj)
Definition at line 282 of file Stat.h.
References m_entity.
Referenced by operator=(), and CounterSvc::print().
00282 { return m_entity ; }
| const std::string& Stat::name | ( | ) | const [inline] |
| const std::string& Stat::group | ( | ) | const [inline] |
StatEntity* Stat::m_entity [private] |
underlying counter
Definition at line 290 of file Stat.h.
Referenced by counter(), entity(), operator!(), operator++(), operator+=(), operator--(), operator-=(), operator=(), print(), Stat(), and ~Stat().
std::string Stat::m_tag [private] |
unique stat tag(name)
Definition at line 292 of file Stat.h.
Referenced by name(), operator=(), and print().
std::string Stat::m_group [private] |
IStatSvc* Stat::m_stat [private] |
ICounterSvc* Stat::m_counter [private] |