|
Gaudi Framework, version v22r4 |
| Home | Generated: Fri Sep 2 2011 |
Base class from which all concrete auditor classes should be derived. More...
#include <GaudiKernel/Auditor.h>


Public Member Functions | |
| Auditor (const std::string &name, ISvcLocator *svcloc) | |
| Constructor. | |
| virtual | ~Auditor () |
| Destructor. | |
| StatusCode | sysInitialize () |
| Initialization method invoked by the framework. | |
| StatusCode | sysFinalize () |
| Finalization method invoked by the framework. | |
| virtual void | before (StandardEventType, INamedInterface *) |
| The following methods are meant to be implemented by the child class... | |
| virtual void | before (StandardEventType, const std::string &) |
| virtual void | before (CustomEventTypeRef, INamedInterface *) |
| virtual void | before (CustomEventTypeRef, const std::string &) |
| virtual void | after (StandardEventType, INamedInterface *, const StatusCode &) |
| virtual void | after (StandardEventType, const std::string &, const StatusCode &) |
| virtual void | after (CustomEventTypeRef, INamedInterface *, const StatusCode &) |
| virtual void | after (CustomEventTypeRef, const std::string &, const StatusCode &) |
| virtual void | beforeInitialize (INamedInterface *) |
| virtual void | afterInitialize (INamedInterface *) |
| virtual void | beforeReinitialize (INamedInterface *) |
| virtual void | afterReinitialize (INamedInterface *) |
| virtual void | beforeExecute (INamedInterface *) |
| virtual void | afterExecute (INamedInterface *, const StatusCode &) |
| virtual void | beforeFinalize (INamedInterface *) |
| virtual void | afterFinalize (INamedInterface *) |
| virtual void | beforeBeginRun (INamedInterface *) |
| virtual void | afterBeginRun (INamedInterface *) |
| virtual void | beforeEndRun (INamedInterface *) |
| virtual void | afterEndRun (INamedInterface *) |
| virtual StatusCode | initialize () |
| virtual StatusCode | finalize () |
| virtual const std::string & | name () const |
| virtual bool | isEnabled () const |
| SmartIF< IMessageSvc > & | msgSvc () const |
| The standard message service. | |
| int | outputLevel () const |
| Retrieve the output level of current auditor. | |
| void | setOutputLevel (int level) |
| Set the output level for current auditor. | |
| SmartIF< ISvcLocator > & | serviceLocator () const |
| The standard service locator. | |
| template<class T > | |
| StatusCode | service (const std::string &name, T *&svc, bool createIf=false) const |
| Access a service by name, creating it if it doesn't already exist. | |
| virtual StatusCode | setProperty (const Property &p) |
| Set a value of a property of an auditor. | |
| virtual StatusCode | setProperty (const std::string &s) |
| Implementation of IProperty::setProperty. | |
| virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
| Implementation of IProperty::setProperty. | |
| virtual StatusCode | getProperty (Property *p) const |
| Get the value of a property. | |
| virtual const Property & | getProperty (const std::string &name) const |
| Get the property by name. | |
| virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
| Implementation of IProperty::getProperty. | |
| const std::vector< Property * > & | getProperties () const |
| Get all properties. | |
| template<class TYPE > | |
| StatusCode | setProperty (const std::string &name, const TYPE &value) |
| set the property form the value | |
| StatusCode | setProperties () |
| Set the auditor's properties. | |
| template<class T > | |
| Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
| Declare the named property. | |
Private Member Functions | |
| Auditor (const Auditor &a) | |
| Auditor & | operator= (const Auditor &rhs) |
Private Attributes | |
| std::string | m_name |
| Auditor's name for identification. | |
| SmartIF< IMessageSvc > | m_MS |
| Message service. | |
| SmartIF< ISvcLocator > | m_pSvcLocator |
| Pointer to service locator service. | |
| PropertyMgr * | m_PropertyMgr |
| For management of properties. | |
| int | m_outputLevel |
| Auditor output level. | |
| bool | m_isEnabled |
| Auditor is enabled flag. | |
| bool | m_isInitialized |
| Auditor has been initialized flag. | |
| bool | m_isFinalized |
| Auditor has been finalized flag. | |
Base class from which all concrete auditor classes should be derived.
The only base class functionality which may be used in the constructor of a concrete auditor is the declaration of member variables as properties. All other functionality, i.e. the use of services, may be used only in initialize() and afterwards.
Definition at line 34 of file Auditor.h.
| Auditor::Auditor | ( | const std::string & | name, |
| ISvcLocator * | svcloc | ||
| ) |
Constructor.
| name | The algorithm object's name |
| svcloc | A pointer to a service location service |
Definition at line 14 of file Auditor.cpp.
: m_name(name), m_pSvcLocator(pSvcLocator), m_isEnabled(true), m_isInitialized(false), m_isFinalized(false) { m_PropertyMgr = new PropertyMgr(); // Declare common Auditor properties with their defaults declareProperty( "OutputLevel", m_outputLevel = MSG::NIL); declareProperty( "Enable", m_isEnabled = true); }
| Auditor::~Auditor | ( | ) | [virtual] |
| Auditor::Auditor | ( | const Auditor & | a ) | [private] |
| void Auditor::after | ( | StandardEventType | evt, |
| INamedInterface * | obj, | ||
| const StatusCode & | sc | ||
| ) | [virtual] |
Reimplemented in TimingAuditor, CommonAuditor, and PerfMonAuditor.
Definition at line 122 of file Auditor.cpp.
{
switch (evt) {
case Initialize: afterInitialize(obj); break;
case ReInitialize: afterReinitialize(obj); break;
case Execute: afterExecute(obj, sc); break;
case BeginRun: afterBeginRun(obj); break;
case EndRun: afterEndRun(obj); break;
case Finalize: afterFinalize(obj); break;
case Start: break;
case Stop: break;
case ReStart: break;
default: break ;// do nothing
}
}
| void Auditor::after | ( | StandardEventType | , |
| const std::string & | , | ||
| const StatusCode & | |||
| ) | [virtual] |
| void Auditor::after | ( | CustomEventTypeRef | , |
| INamedInterface * | , | ||
| const StatusCode & | |||
| ) | [virtual] |
| void Auditor::after | ( | CustomEventTypeRef | , |
| const std::string & | , | ||
| const StatusCode & | |||
| ) | [virtual] |
| void Auditor::afterBeginRun | ( | INamedInterface * | ) | [virtual] |
Definition at line 155 of file Auditor.cpp.
{}
| void Auditor::afterEndRun | ( | INamedInterface * | ) | [virtual] |
Definition at line 159 of file Auditor.cpp.
{}
| void Auditor::afterExecute | ( | INamedInterface * | , |
| const StatusCode & | |||
| ) | [virtual] |
Reimplemented in AlgContextAuditor, and AlgErrorAuditor.
Definition at line 151 of file Auditor.cpp.
{}
| void Auditor::afterFinalize | ( | INamedInterface * | ) | [virtual] |
| void Auditor::afterInitialize | ( | INamedInterface * | ) | [virtual] |
| void Auditor::afterReinitialize | ( | INamedInterface * | ) | [virtual] |
Definition at line 147 of file Auditor.cpp.
{}
| void Auditor::before | ( | StandardEventType | , |
| const std::string & | |||
| ) | [virtual] |
| void Auditor::before | ( | CustomEventTypeRef | , |
| INamedInterface * | |||
| ) | [virtual] |
| void Auditor::before | ( | StandardEventType | evt, |
| INamedInterface * | obj | ||
| ) | [virtual] |
The following methods are meant to be implemented by the child class...
Reimplemented in TimingAuditor, CommonAuditor, and PerfMonAuditor.
Definition at line 102 of file Auditor.cpp.
{
switch (evt) {
case Initialize: beforeInitialize(obj); break;
case ReInitialize: beforeReinitialize(obj); break;
case Execute: beforeExecute(obj); break;
case BeginRun: beforeBeginRun(obj); break;
case EndRun: beforeEndRun(obj); break;
case Finalize: beforeFinalize(obj); break;
case Start: break;
case Stop: break;
case ReStart: break;
default: break ;// do nothing
}
}
| void Auditor::before | ( | CustomEventTypeRef | , |
| const std::string & | |||
| ) | [virtual] |
| void Auditor::beforeBeginRun | ( | INamedInterface * | ) | [virtual] |
Definition at line 153 of file Auditor.cpp.
{}
| void Auditor::beforeEndRun | ( | INamedInterface * | ) | [virtual] |
Definition at line 157 of file Auditor.cpp.
{}
| void Auditor::beforeExecute | ( | INamedInterface * | ) | [virtual] |
Reimplemented in AlgContextAuditor, and AlgErrorAuditor.
Definition at line 149 of file Auditor.cpp.
{}
| void Auditor::beforeFinalize | ( | INamedInterface * | ) | [virtual] |
| void Auditor::beforeInitialize | ( | INamedInterface * | ) | [virtual] |
| void Auditor::beforeReinitialize | ( | INamedInterface * | ) | [virtual] |
Definition at line 145 of file Auditor.cpp.
{}
| Property* Auditor::declareProperty | ( | const std::string & | name, |
| T & | property, | ||
| const std::string & | doc = "none" |
||
| ) | const [inline] |
Declare the named property.
MyAuditor( ... )
: Auditor ( ... )
, m_property1 ( ... )
, m_property2 ( ... )
{
// declare the property
declareProperty( "Property1" , m_property1 , "Doc fro property #1" ) ;
// declare the property and attach the handler to it
declareProperty( "Property2" , m_property2 , "Doc for property #2" )
-> declareUpdateHandler( &MyAlg::handler_2 ) ;
}
| name | the property name |
| property | the property itself, |
| doc | the documentation string |
Definition at line 230 of file Auditor.h.
{
return m_PropertyMgr->declareProperty(name, property, doc);
}
| StatusCode Auditor::finalize | ( | void | ) | [virtual] |
Reimplemented in TimingAuditor, AlgContextAuditor, AlgErrorAuditor, and PerfMonAuditor.
Definition at line 213 of file Auditor.cpp.
{
m_MS = 0; // release message service
return StatusCode::SUCCESS;
}
| const std::vector< Property * > & Auditor::getProperties | ( | ) | const |
Get all properties.
Definition at line 274 of file Auditor.cpp.
{
return m_PropertyMgr->getProperties();
}
| StatusCode Auditor::getProperty | ( | Property * | p ) | const [virtual] |
Get the value of a property.
Definition at line 265 of file Auditor.cpp.
{
return m_PropertyMgr->getProperty(p);
}
| const Property & Auditor::getProperty | ( | const std::string & | name ) | const [virtual] |
Get the property by name.
Definition at line 268 of file Auditor.cpp.
{
return m_PropertyMgr->getProperty(name);
}
| StatusCode Auditor::getProperty | ( | const std::string & | n, |
| std::string & | v | ||
| ) | const [virtual] |
Implementation of IProperty::getProperty.
Definition at line 271 of file Auditor.cpp.
{
return m_PropertyMgr->getProperty(n,v);
}
| StatusCode Auditor::initialize | ( | void | ) | [virtual] |
Reimplemented in TimingAuditor, AlgContextAuditor, AlgErrorAuditor, and PerfMonAuditor.
Definition at line 97 of file Auditor.cpp.
{
return StatusCode::SUCCESS;
}
| bool Auditor::isEnabled | ( | ) | const [virtual] |
Definition at line 222 of file Auditor.cpp.
{
return m_isEnabled;
}
| SmartIF< IMessageSvc > & Auditor::msgSvc | ( | ) | const |
The standard message service.
Returns a pointer to the standard message service. May not be invoked before sysInitialize() has been invoked.
Definition at line 226 of file Auditor.cpp.
{
return m_MS;
}
| const std::string & Auditor::name | ( | ) | const [virtual] |
Definition at line 218 of file Auditor.cpp.
{
return m_name;
}
| int Auditor::outputLevel | ( | ) | const [inline] |
Retrieve the output level of current auditor.
Definition at line 100 of file Auditor.h.
{ return m_outputLevel; }
| StatusCode Auditor::service | ( | const std::string & | name, |
| T *& | svc, | ||
| bool | createIf = false |
||
| ) | const [inline] |
Access a service by name, creating it if it doesn't already exist.
Definition at line 114 of file Auditor.h.
{
SmartIF<T> ptr(serviceLocator()->service(name, createIf));
if (ptr.isValid()) {
svc = ptr.get();
svc->addRef();
return StatusCode::SUCCESS;
}
// else
svc = 0;
return StatusCode::FAILURE;
}
| SmartIF< ISvcLocator > & Auditor::serviceLocator | ( | ) | const |
The standard service locator.
Returns a pointer to the service locator service. This service may be used by an auditor to request any services it requires in addition to those provided by default.
Definition at line 236 of file Auditor.cpp.
{
return m_pSvcLocator;
}
| void Auditor::setOutputLevel | ( | int | level ) |
| StatusCode Auditor::setProperties | ( | ) |
Set the auditor's properties.
This method requests the job options service to set the values of any declared properties. The method is invoked from within sysInitialize() by the framework and does not need to be explicitly called by a concrete auditor.
Definition at line 241 of file Auditor.cpp.
{
if( m_pSvcLocator != 0 ) {
IJobOptionsSvc* jos;
StatusCode sc = service("JobOptionsSvc", jos);
if( sc.isSuccess() ) {
jos->setMyProperties( name(), this ).ignore();
jos->release();
return StatusCode::SUCCESS;
}
}
return StatusCode::FAILURE;
}
| StatusCode Auditor::setProperty | ( | const std::string & | name, |
| const TYPE & | value | ||
| ) | [inline] |
set the property form the value
std::vector<double> data = ... ; setProperty( "Data" , data ) ; std::map<std::string,double> cuts = ... ; setProperty( "Cuts" , cuts ) ; std::map<std::string,std::string> dict = ... ; setProperty( "Dictionary" , dict ) ;
Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only
This is very convenient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty
setProperty ( "OutputLevel" , "1" ) ; setProperty ( "Enable" , "True" ) ; setProperty ( "ErrorMax" , "10" ) ;
For simple cases it is more or less ok, but for complicated properties it is just ugly..
| name | name of the property |
| value | value of the property |
Definition at line 190 of file Auditor.h.
{ return Gaudi::Utils::setProperty ( m_PropertyMgr , name , value ) ; }
| StatusCode Auditor::setProperty | ( | const std::string & | s ) | [virtual] |
Implementation of IProperty::setProperty.
Definition at line 259 of file Auditor.cpp.
{
return m_PropertyMgr->setProperty(s);
}
| StatusCode Auditor::setProperty | ( | const std::string & | n, |
| const std::string & | v | ||
| ) | [virtual] |
Implementation of IProperty::setProperty.
Definition at line 262 of file Auditor.cpp.
{
return m_PropertyMgr->setProperty(n,v);
}
| StatusCode Auditor::setProperty | ( | const Property & | p ) | [virtual] |
Set a value of a property of an auditor.
Definition at line 256 of file Auditor.cpp.
{
return m_PropertyMgr->setProperty(p);
}
| StatusCode Auditor::sysFinalize | ( | ) |
Finalization method invoked by the framework.
This method is responsible for any bookkeeping of initialization required by the framework itself.
RETURN !!!
catch GaudiExeption
(1) perform the printout of message
(2) print the exception itself (NB! - GaudiException is a linked list of all "previous exceptions")
catch std::exception
(1) perform the printout of message
(2) print the exception itself
catch unknown exception
(1) perform the printout
Definition at line 165 of file Auditor.cpp.
{
StatusCode sc = StatusCode::SUCCESS;
try{
//
// Invoke the finalize() method of the derived class if
// it has been initialized.
if ( m_isInitialized && ! m_isFinalized ) {
m_isFinalized = true;
sc = finalize();
if( !sc.isSuccess() ) return StatusCode::FAILURE;
}
return sc;
//
}
catch( const GaudiException& Exception )
{
MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
log << MSG::FATAL
<< " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
MsgStream logEx ( msgSvc() , Exception.tag() );
logEx << MSG::ERROR
<< Exception << endmsg;
}
catch( const std::exception& Exception )
{
MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
log << MSG::FATAL
<< " Standard std::exception is caught " << endmsg;
MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
logEx << MSG::ERROR
<< Exception.what() << endmsg;
}
catch( ... )
{
MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
log << MSG::FATAL
<< " UNKNOWN Exception is caught " << endmsg;
}
return StatusCode::FAILURE ;
}
| StatusCode Auditor::sysInitialize | ( | ) |
Initialization method invoked by the framework.
This method is responsible for any bookkeeping of initialization required by the framework itself.
RETURN !!!
catch Gaudi Exception
(1) perform the printout of message
(2) print the exception itself (NB! - GaudiException is a linked list of all "previous exceptions")
catch std::exception
(1) perform the printout of message
(2) print the exception itself (NB! - GaudiException is a linked list of all "previous exceptions")
(1) perform the printout
Definition at line 34 of file Auditor.cpp.
{
StatusCode sc;
// Bypass the initialization if the auditor is disabled or
// has already been initialized.
if ( isEnabled( ) && ! m_isInitialized ) {
// Setup the default service ... this should be upgraded so as to be configurable.
if( m_pSvcLocator == 0 )
return StatusCode::FAILURE;
// Set up message service
m_MS = serviceLocator(); // get default message service
if( !m_MS.isValid() ) return StatusCode::FAILURE;
// Set the Auditor's properties
sc = setProperties();
if( !sc.isSuccess() ) return StatusCode::FAILURE;
// Check current outputLevel to eventually inform the MessagsSvc
if( m_outputLevel != MSG::NIL ) {
setOutputLevel( m_outputLevel );
}
{
try{
// Invoke the initialize() method of the derived class
sc = initialize();
if( !sc.isSuccess() ) return StatusCode::FAILURE;
m_isInitialized = true;
return sc;
}
catch ( const GaudiException& Exception )
{
MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
MsgStream logEx ( msgSvc() , Exception.tag() );
logEx << MSG::ERROR << Exception << endmsg;
}
catch( const std::exception& Exception )
{
MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
log << MSG::FATAL << " Standard std::exception is catched " << endmsg;
MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
logEx << MSG::ERROR << Exception.what() << endmsg;
}
catch(...)
{
MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
log << MSG::FATAL << " UNKNOWN Exception is catched " << endmsg;
}
}
}
return StatusCode::FAILURE;
}
bool Auditor::m_isEnabled [private] |
bool Auditor::m_isFinalized [private] |
bool Auditor::m_isInitialized [private] |
SmartIF<IMessageSvc> Auditor::m_MS [mutable, private] |
std::string Auditor::m_name [private] |
int Auditor::m_outputLevel [private] |
PropertyMgr* Auditor::m_PropertyMgr [private] |
SmartIF<ISvcLocator> Auditor::m_pSvcLocator [mutable, private] |