Gaudi Framework, version v21r8

Home   Generated: 17 Mar 2010

Auditor Class Reference

Base class from which all concrete auditor classes should be derived. More...

#include <GaudiKernel/Auditor.h>

Inheritance diagram for Auditor:

Inheritance graph
[legend]
Collaboration diagram for Auditor:

Collaboration graph
[legend]

List of all members.

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::stringname () 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 PropertygetProperty (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>
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.

Private Member Functions

 Auditor (const Auditor &a)
Auditoroperator= (const Auditor &rhs)

Private Attributes

std::string m_name
 Auditor's name for identification.
SmartIF< IMessageSvcm_MS
 Message service.
SmartIF< ISvcLocatorm_pSvcLocator
 Pointer to service locator service.
PropertyMgrm_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.


Detailed Description

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.

Author:
David Quarrie
Date:
2000
Author:
Marco Clemencic
Date:
2008-03

Definition at line 34 of file Auditor.h.


Constructor & Destructor Documentation

Auditor::Auditor ( const std::string name,
ISvcLocator svcloc 
)

Constructor.

Parameters:
name The algorithm object's name
svcloc A pointer to a service location service

Definition at line 14 of file Auditor.cpp.

00015 : m_name(name),
00016   m_pSvcLocator(pSvcLocator),
00017   m_isEnabled(true),
00018   m_isInitialized(false),
00019   m_isFinalized(false)
00020 {
00021   m_PropertyMgr = new PropertyMgr();
00022 
00023   // Declare common Auditor properties with their defaults
00024   declareProperty( "OutputLevel", m_outputLevel = MSG::NIL);
00025   declareProperty( "Enable", m_isEnabled = true);
00026 }

Auditor::~Auditor (  )  [virtual]

Destructor.

Definition at line 29 of file Auditor.cpp.

00029                   {
00030   delete m_PropertyMgr;
00031 }

Auditor::Auditor ( const Auditor a  )  [private]


Member Function Documentation

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.

00034                                   {
00035   StatusCode sc;
00036 
00037   // Bypass the initialization if the auditor is disabled or
00038   // has already been initialized.
00039   if ( isEnabled( ) && ! m_isInitialized ) {
00040 
00041     // Setup the default service ... this should be upgraded so as to be configurable.
00042     if( m_pSvcLocator == 0 )
00043       return StatusCode::FAILURE;
00044 
00045     // Set up message service
00046     m_MS = serviceLocator(); // get default message service
00047     if( !m_MS.isValid() )  return StatusCode::FAILURE;
00048 
00049     // Set the Auditor's properties
00050     sc = setProperties();
00051     if( !sc.isSuccess() )  return StatusCode::FAILURE;
00052 
00053     // Check current outputLevel to eventually inform the MessagsSvc
00054     if( m_outputLevel != MSG::NIL ) {
00055       setOutputLevel( m_outputLevel );
00056     }
00057 
00058     {
00059       try{
00060         // Invoke the initialize() method of the derived class
00061         sc = initialize();
00062         if( !sc.isSuccess() )  return StatusCode::FAILURE;
00063         m_isInitialized = true;
00064 
00065         return sc;                                               
00066       }
00067       catch ( const GaudiException& Exception )                  
00068         {
00070           MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
00071           log << MSG::FATAL << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
00073           MsgStream logEx ( msgSvc() , Exception.tag() );
00074           logEx << MSG::ERROR << Exception  << endmsg;
00075         }
00076       catch( const std::exception& Exception )                   
00077         {
00079           MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
00080           log << MSG::FATAL << " Standard std::exception is catched " << endmsg;
00082           MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
00083           logEx << MSG::ERROR << Exception.what()  << endmsg;
00084         }
00085       catch(...)
00086         {
00088           MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
00089           log << MSG::FATAL << " UNKNOWN Exception is  catched " << endmsg;
00090         }
00091     }
00092   }
00094   return StatusCode::FAILURE;
00095 }

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

Reimplemented in MemoryAuditor, and MemStatAuditor.

Definition at line 165 of file Auditor.cpp.

00165                                 {
00166   StatusCode sc = StatusCode::SUCCESS;
00167   try{
00168     //
00169     // Invoke the finalize() method of the derived class if
00170     // it has been initialized.
00171     if ( m_isInitialized && ! m_isFinalized ) {
00172       m_isFinalized = true;
00173       sc = finalize();
00174       if( !sc.isSuccess() )  return StatusCode::FAILURE;
00175     }
00176     return sc;                                               
00177     //
00178   }
00179   catch( const GaudiException& Exception )                   
00180     {
00182       MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
00183       log << MSG::FATAL
00184           << " Exception with tag=" << Exception.tag() << " is catched " << endmsg;
00187       MsgStream logEx ( msgSvc() , Exception.tag() );
00188       logEx << MSG::ERROR
00189             << Exception  << endmsg;
00190     }
00191   catch( const std::exception& Exception )                   
00192     {
00194       MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
00195       log << MSG::FATAL
00196           << " Standard std::exception is caught " << endmsg;
00198       MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
00199       logEx << MSG::ERROR
00200             << Exception.what()  << endmsg;
00201     }
00202   catch( ... )                                                
00203     {
00205       MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
00206       log << MSG::FATAL
00207           << " UNKNOWN Exception is caught " << endmsg;
00208     }
00210   return StatusCode::FAILURE ;
00211 }

void Auditor::before ( StandardEventType  evt,
INamedInterface obj 
) [virtual]

The following methods are meant to be implemented by the child class...

Reimplemented in TimingAuditor, and NameAuditor.

Definition at line 102 of file Auditor.cpp.

00102                                                                {
00103   switch (evt) {
00104   case Initialize:   beforeInitialize(obj);   break;
00105   case ReInitialize: beforeReinitialize(obj); break;
00106   case Execute:      beforeExecute(obj);      break;
00107   case BeginRun:     beforeBeginRun(obj);     break;
00108   case EndRun:       beforeEndRun(obj);       break;
00109   case Finalize:     beforeFinalize(obj);     break;
00110   case Start:        break;
00111   case Stop:         break;
00112   case ReStart:      break;
00113   default: ;// do nothing
00114   }
00115 }

void Auditor::before ( StandardEventType  ,
const std::string  
) [virtual]

Reimplemented in NameAuditor.

Definition at line 116 of file Auditor.cpp.

00116 {}

void Auditor::before ( CustomEventTypeRef  ,
INamedInterface  
) [virtual]

Reimplemented in NameAuditor.

Definition at line 118 of file Auditor.cpp.

00118 {}

void Auditor::before ( CustomEventTypeRef  ,
const std::string  
) [virtual]

Reimplemented in TimingAuditor, ChronoAuditor, MemoryAuditor, MemStatAuditor, and NameAuditor.

Definition at line 119 of file Auditor.cpp.

00119 {}

void Auditor::after ( StandardEventType  evt,
INamedInterface obj,
const StatusCode sc 
) [virtual]

Reimplemented in TimingAuditor, and NameAuditor.

Definition at line 122 of file Auditor.cpp.

00122                                                                                     {
00123   switch (evt) {
00124   case Initialize:   afterInitialize(obj);   break;
00125   case ReInitialize: afterReinitialize(obj); break;
00126   case Execute:      afterExecute(obj, sc);  break;
00127   case BeginRun:     afterBeginRun(obj);     break;
00128   case EndRun:       afterEndRun(obj);       break;
00129   case Finalize:     afterFinalize(obj);     break;
00130   case Start:        break;
00131   case Stop:         break;
00132   case ReStart:      break;
00133   default: ;// do nothing
00134   }
00135 }

void Auditor::after ( StandardEventType  ,
const std::string ,
const StatusCode  
) [virtual]

Reimplemented in NameAuditor.

Definition at line 136 of file Auditor.cpp.

00136 {}

void Auditor::after ( CustomEventTypeRef  ,
INamedInterface ,
const StatusCode  
) [virtual]

Reimplemented in NameAuditor.

Definition at line 138 of file Auditor.cpp.

00138 {}

void Auditor::after ( CustomEventTypeRef  ,
const std::string ,
const StatusCode  
) [virtual]

Reimplemented in TimingAuditor, ChronoAuditor, MemoryAuditor, MemStatAuditor, and NameAuditor.

Definition at line 139 of file Auditor.cpp.

00139 {}

void Auditor::beforeInitialize ( INamedInterface  )  [virtual]

Reimplemented in AlgContextAuditor, ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 141 of file Auditor.cpp.

00141 {}

void Auditor::afterInitialize ( INamedInterface  )  [virtual]

Reimplemented in AlgContextAuditor, ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 143 of file Auditor.cpp.

00143 {}

void Auditor::beforeReinitialize ( INamedInterface  )  [virtual]

Reimplemented in ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 145 of file Auditor.cpp.

00145 {}

void Auditor::afterReinitialize ( INamedInterface  )  [virtual]

Reimplemented in ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 147 of file Auditor.cpp.

00147 {}

void Auditor::beforeExecute ( INamedInterface  )  [virtual]

Reimplemented in AlgContextAuditor, AlgErrorAuditor, ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 149 of file Auditor.cpp.

00149 {}

void Auditor::afterExecute ( INamedInterface ,
const StatusCode  
) [virtual]

Reimplemented in AlgContextAuditor, AlgErrorAuditor, ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 151 of file Auditor.cpp.

00151 {}

void Auditor::beforeFinalize ( INamedInterface  )  [virtual]

Reimplemented in AlgContextAuditor, ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 161 of file Auditor.cpp.

00161 {}

void Auditor::afterFinalize ( INamedInterface  )  [virtual]

Reimplemented in AlgContextAuditor, ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 163 of file Auditor.cpp.

00163 {}

void Auditor::beforeBeginRun ( INamedInterface  )  [virtual]

Reimplemented in ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 153 of file Auditor.cpp.

00153 {}

void Auditor::afterBeginRun ( INamedInterface  )  [virtual]

Reimplemented in ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 155 of file Auditor.cpp.

00155 {}

void Auditor::beforeEndRun ( INamedInterface  )  [virtual]

Reimplemented in ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 157 of file Auditor.cpp.

00157 {}

void Auditor::afterEndRun ( INamedInterface  )  [virtual]

Reimplemented in ChronoAuditor, MemoryAuditor, and MemStatAuditor.

Definition at line 159 of file Auditor.cpp.

00159 {}

StatusCode Auditor::initialize (  )  [virtual]

Reimplemented in TimingAuditor, AlgContextAuditor, and AlgErrorAuditor.

Definition at line 97 of file Auditor.cpp.

00097                                {
00098   return StatusCode::SUCCESS;
00099 }

StatusCode Auditor::finalize ( void   )  [virtual]

Reimplemented in TimingAuditor, AlgContextAuditor, and AlgErrorAuditor.

Definition at line 213 of file Auditor.cpp.

00213                              {
00214   m_MS = 0; // release message service
00215   return StatusCode::SUCCESS;
00216 }

const std::string & Auditor::name (  )  const [virtual]

Definition at line 218 of file Auditor.cpp.

00218                                      {
00219   return m_name;
00220 }

bool Auditor::isEnabled (  )  const [virtual]

Definition at line 222 of file Auditor.cpp.

00222                                {
00223   return m_isEnabled;
00224 }

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.

00226                                             {
00227   return m_MS;
00228 }

int Auditor::outputLevel (  )  const [inline]

Retrieve the output level of current auditor.

Definition at line 100 of file Auditor.h.

00100 { return m_outputLevel; }

void Auditor::setOutputLevel ( int  level  ) 

Set the output level for current auditor.

Definition at line 230 of file Auditor.cpp.

00230                                         {
00231   if( m_MS != 0) {
00232     m_MS->setOutputLevel( name(), level );
00233   }
00234 }

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.

00236                                                     {
00237   return m_pSvcLocator;
00238 }

template<class T>
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.

00114                                                                                     {
00115     SmartIF<T> ptr(serviceLocator()->service(name, createIf));
00116     if (ptr.isValid()) {
00117       svc = ptr.get();
00118       svc->addRef();
00119       return StatusCode::SUCCESS;
00120     }
00121     // else
00122     svc = 0;
00123     return StatusCode::FAILURE;
00124   }

StatusCode Auditor::setProperty ( const Property p  )  [virtual]

Set a value of a property of an auditor.

Definition at line 256 of file Auditor.cpp.

00256                                                  {
00257   return m_PropertyMgr->setProperty(p);
00258 }

StatusCode Auditor::setProperty ( const std::string s  )  [virtual]

Implementation of IProperty::setProperty.

Definition at line 259 of file Auditor.cpp.

00259                                                   {
00260   return m_PropertyMgr->setProperty(s);
00261 }

StatusCode Auditor::setProperty ( const std::string n,
const std::string v 
) [virtual]

Implementation of IProperty::setProperty.

Definition at line 262 of file Auditor.cpp.

00262                                                                       {
00263   return m_PropertyMgr->setProperty(n,v);
00264 }

StatusCode Auditor::getProperty ( Property p  )  const [virtual]

Get the value of a property.

Definition at line 265 of file Auditor.cpp.

00265                                                  {
00266   return m_PropertyMgr->getProperty(p);
00267 }

const Property & Auditor::getProperty ( const std::string name  )  const [virtual]

Get the property by name.

Definition at line 268 of file Auditor.cpp.

00268                                                                 {
00269   return m_PropertyMgr->getProperty(name);
00270 }

StatusCode Auditor::getProperty ( const std::string n,
std::string v 
) const [virtual]

Implementation of IProperty::getProperty.

Definition at line 271 of file Auditor.cpp.

00271                                                                        {
00272   return m_PropertyMgr->getProperty(n,v);
00273 }

const std::vector< Property * > & Auditor::getProperties (  )  const

Get all properties.

Definition at line 274 of file Auditor.cpp.

00274                                                           {
00275   return m_PropertyMgr->getProperties();
00276 }

template<class TYPE>
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..

Parameters:
name name of the property
value value of the property
See also:
Gaudi::Utils::setProperty
Author:
Vanya BELYAEV ibelyaev@physics.syr.edu
Date:
2007-05-13

Definition at line 190 of file Auditor.h.

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.

00241                                   {
00242   if( m_pSvcLocator != 0 )    {
00243     IJobOptionsSvc* jos;
00244     StatusCode sc = service("JobOptionsSvc", jos);
00245     if( sc.isSuccess() )    {
00246       jos->setMyProperties( name(), this ).ignore();
00247       jos->release();
00248       return StatusCode::SUCCESS;
00249     }
00250   }
00251   return StatusCode::FAILURE;
00252 }

template<class T>
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 ) ;

   }

See also:
PropertyMgr

PropertyMgr::declareProperty

Parameters:
name the property name
property the property itself,
doc the documentation string
Returns:
the actual property objects

Definition at line 230 of file Auditor.h.

00231                                                                   {
00232         return m_PropertyMgr->declareProperty(name, property, doc);
00233   }

Auditor& Auditor::operator= ( const Auditor rhs  )  [private]


Member Data Documentation

Auditor's name for identification.

Definition at line 237 of file Auditor.h.

SmartIF<IMessageSvc> Auditor::m_MS [mutable, private]

Message service.

Definition at line 239 of file Auditor.h.

Pointer to service locator service.

Definition at line 240 of file Auditor.h.

For management of properties.

Definition at line 241 of file Auditor.h.

int Auditor::m_outputLevel [private]

Auditor output level.

Definition at line 242 of file Auditor.h.

Auditor is enabled flag.

Definition at line 243 of file Auditor.h.

Auditor has been initialized flag.

Definition at line 244 of file Auditor.h.

Auditor has been finalized flag.

Definition at line 245 of file Auditor.h.


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

Generated at Wed Mar 17 18:16:31 2010 for Gaudi Framework, version v21r8 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004