All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ICounterSvc Class Referenceabstract

Create / access multi purpose counters. More...

#include <GaudiKernel/ICounterSvc.h>

Inheritance diagram for ICounterSvc:
Collaboration diagram for ICounterSvc:

Classes

class  Printout
 Print counters for each element in the range [first, last) e.g. More...
 

Public Types

enum  { COUNTER_NOT_PRESENT = 2, COUNTER_EXISTS = 4, COUNTER_REMOVED = 3 }
 
typedef StatEntity Counter
 the actual type of counter More...
 
typedef Stat CountObject
 Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...; ++(*cnt);. More...
 
typedef std::vector< CountObjectCounters
 the actual type of vectors of initialized counters More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 

Public Member Functions

 DeclareInterfaceID (ICounterSvc, 4, 0)
 InterfaceID. More...
 
virtual Counterget (const std::string &group, const std::string &name) const =0
 Access an existing counter object. More...
 
virtual Counters get (const std::string &group) const =0
 get all counters form the given group: More...
 
virtual StatusCode create (const std::string &group, const std::string &name, longlong initial_value, Counter *&refpCounter)=0
 Create a new counter object. More...
 
virtual CountObject create (const std::string &group, const std::string &name, longlong initial_value=0)=0
 If the counter object exists already, a std::runtime_error exception is thrown. More...
 
virtual StatusCode remove (const std::string &group, const std::string &name)=0
 Remove a counter object. More...
 
virtual StatusCode remove (const std::string &group)=0
 Remove all counters of a given group. More...
 
virtual StatusCode print (const std::string &group, const std::string &name, Printout &printer) const =0
 Print counter value. More...
 
virtual StatusCode print (const std::string &group, Printout &printer) const =0
 If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access. More...
 
virtual StatusCode print (const Counter *pCounter, Printout &printer) const =0
 Print counter value. More...
 
virtual StatusCode print (const CountObject &pCounter, Printout &printer) const =0
 Print counter value. More...
 
virtual StatusCode print (Printout &printer) const =0
 
virtual StatusCode defaultPrintout (MsgStream &log, const Counter *pCounter) const =0
 Default Printout for counters. More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 

Protected Member Functions

virtual ~ICounterSvc ()
 protected virtual destructor More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 

Detailed Description

Create / access multi purpose counters.

Counter Creation:

// counter creation:
ICounterSvc::CountObject obj = svc->create("AlgName","NumExecuted",0);
obj++;
obj += 10;
ICounterSvc::Counter* m_counter = obj.counter();
// ICounterSvc::Counter* m_counter = obj ; ///< the same
ICounterSvc::Counter* m_counter = 0;
if ( svc->create("AlgName","NumExecuted",0, m_counter).isSuccess() )
{
CountObject obj(m_counter);
obj++;
}

Counter access:

ICounterSvc::Counter* m_counter = svc->get("AlgName","NumExecuted");
if ( m_counter ) {....}
// or:
try {
ICounterSvc::CountObject obj(svc->get("AlgName","NumExecuted"));
obj++;
}
catch(std::invalid_argument e) {
...handle exception ...
}
Author
Markus Frank
modified by Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Version
3.0

Definition at line 78 of file ICounterSvc.h.

Member Typedef Documentation

the actual type of counter

See also
StatEntity

Definition at line 84 of file ICounterSvc.h.

typedef std::vector<CountObject> ICounterSvc::Counters

the actual type of vectors of initialized counters

Definition at line 102 of file ICounterSvc.h.

Ease the manipulation of counters in a way, that they behave like objects: Avoid: Counter* cnt = ...; ++(*cnt);.

Instead: Counter* cnt = ...; CountObject obj(cnt); ++cnt;

Note: No inheritance! This class has no virtual destructor

Author
Markus Frank
Version
1.0

Definition at line 100 of file ICounterSvc.h.

Member Enumeration Documentation

anonymous enum
Enumerator
COUNTER_NOT_PRESENT 
COUNTER_EXISTS 
COUNTER_REMOVED 

Definition at line 256 of file ICounterSvc.h.

256  { COUNTER_NOT_PRESENT = 2, // Error
257  COUNTER_EXISTS = 4, // Error ?
258  COUNTER_REMOVED = 3 // Type of success. Low bit set
259  } ;

Constructor & Destructor Documentation

ICounterSvc::~ICounterSvc ( )
protectedvirtual

protected virtual destructor

protected virtual destructor

Definition at line 30 of file ICounterSvc.cpp.

30 {}

Member Function Documentation

virtual StatusCode ICounterSvc::create ( const std::string &  group,
const std::string &  name,
longlong  initial_value,
Counter *&  refpCounter 
)
pure virtual

Create a new counter object.

If the counter object exists already the existing object is returned. In this event the return code is COUNTER_EXISTS. The ownership of the actual counter stays with the service.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
initial_value[IN] Initial counter value
refpCounter[OUT] Reference to store pointer to counter.
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual CountObject ICounterSvc::create ( const std::string &  group,
const std::string &  name,
longlong  initial_value = 0 
)
pure virtual

If the counter object exists already, a std::runtime_error exception is thrown.

The ownership of the actual counter stays with the service.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
initial_value[IN] Initial counter value
refpCounter[OUT] Reference to store pointer to counter.
Returns
Fully initialized CountObject.

Implemented in CounterSvc.

ICounterSvc::DeclareInterfaceID ( ICounterSvc  ,
,
 
)
virtual StatusCode ICounterSvc::defaultPrintout ( MsgStream log,
const Counter pCounter 
) const
pure virtual

Default Printout for counters.

Implemented in CounterSvc.

virtual Counter* ICounterSvc::get ( const std::string &  group,
const std::string &  name 
) const
pure virtual

Access an existing counter object.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
createIf[IN] flag to indicate the creation if not counter found
Returns
Pointer to existing counter object (NULL if non existing).

Implemented in CounterSvc.

virtual Counters ICounterSvc::get ( const std::string &  group) const
pure virtual

get all counters form the given group:

ICounterSvc::Counters cnts = svc->get("Efficiency") ;
MsgStream& stream = ... ;
for ( ICounterSvc::Counters::const_iterator ic = cnts.begin() ;
cnts.end() != ic ; ++ic )
{
stream << (*ic) << endmsg ;
}
See also
ICounterSvc::Counters
Parameters
gorupthe gorup name
Returns
vector of the properly initialized counters

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::print ( const std::string &  group,
const std::string &  name,
Printout printer 
) const
pure virtual

Print counter value.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::print ( const std::string &  group,
Printout printer 
) const
pure virtual

If no such counter exists the return code is COUNTER_NOT_PRESENT Note: This call is not direct access.

Parameters
group[IN] Hint for smart printing
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::print ( const Counter pCounter,
Printout printer 
) const
pure virtual

Print counter value.

Parameters
pCounter[IN] Pointer to Counter object
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::print ( const CountObject pCounter,
Printout printer 
) const
pure virtual

Print counter value.

Parameters
refCounter[IN] Reference to CountObject object
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::print ( Printout printer) const
pure virtual
Parameters
printer[IN] Print actor
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::remove ( const std::string &  group,
const std::string &  name 
)
pure virtual

Remove a counter object.

If the counter object does not exists, the return code is COUNTER_NOT_PRESENT. The counter may not be used anymore after this call.

Parameters
group[IN] Hint for smart printing
name[IN] Counter name
initial_value[IN] Initial counter value
refpCounter[OUT] Reference to store pointer to counter.
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.

virtual StatusCode ICounterSvc::remove ( const std::string &  group)
pure virtual

Remove all counters of a given group.

If no such counter exists the return code is COUNTER_NOT_PRESENT

Parameters
group[IN] Hint for smart printing
Returns
StatusCode indicating failure or success.

Implemented in CounterSvc.


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