| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Private Member Functions | Private Attributes

# Auditor Class Reference

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

`#include <GaudiKernel/Auditor.h>`

Inheritance diagram for Auditor:
[legend]
Collaboration diagram for Auditor:
[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::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.

## 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.

    : 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]`

Destructor.

Definition at line 29 of file Auditor.cpp.

                      {
      delete m_PropertyMgr;
    }

Auditor::Auditor | ( | const Auditor & | a ) | `[private]`

## Member Function Documentation

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]`

Reimplemented in CommonAuditor.

Definition at line 136 of file Auditor.cpp.

    {}

void Auditor::after | ( | CustomEventTypeRef | ,
|  | INamedInterface * | ,
|  | const StatusCode & |
| ) |  | `[virtual]`

Reimplemented in CommonAuditor.

Definition at line 138 of file Auditor.cpp.

    {}

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

Reimplemented in TimingAuditor, and CommonAuditor.

Definition at line 139 of file Auditor.cpp.

    {}

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]`

Reimplemented in AlgContextAuditor.

Definition at line 163 of file Auditor.cpp.

    {}

void Auditor::afterInitialize | ( | INamedInterface * | ) | `[virtual]`

Reimplemented in AlgContextAuditor.

Definition at line 143 of file Auditor.cpp.

    {}

void Auditor::afterReinitialize | ( | INamedInterface * | ) | `[virtual]`

Definition at line 147 of file Auditor.cpp.

    {}

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

Reimplemented in CommonAuditor.

Definition at line 116 of file Auditor.cpp.

    {}

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

Reimplemented in CommonAuditor.

Definition at line 118 of file Auditor.cpp.

    {}

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]`

Reimplemented in TimingAuditor, and CommonAuditor.

Definition at line 119 of file Auditor.cpp.

    {}

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]`

Reimplemented in AlgContextAuditor.

Definition at line 161 of file Auditor.cpp.

    {}

void Auditor::beforeInitialize | ( | INamedInterface * | ) | `[virtual]`

Reimplemented in AlgContextAuditor.

Definition at line 141 of file Auditor.cpp.

    {}

void Auditor::beforeReinitialize | ( | INamedInterface * | ) | `[virtual]`

Definition at line 145 of file Auditor.cpp.

    {}

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.

                                                                      {
            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;
    }

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

int Auditor::outputLevel | ( | ) | const`[inline]`

Retrieve the output level of current auditor.

Definition at line 100 of file Auditor.h.

    { return m_outputLevel; }

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.

                                                                                        {
        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 ) |

Set the output level for current auditor.

Definition at line 230 of file Auditor.cpp.

                                            {
      if( m_MS != 0) {
        m_MS->setOutputLevel( name(), 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;
    }

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.

      { 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;
    }

## Member Data Documentation

bool Auditor::m_isEnabled`[private]`

Auditor is enabled flag.

Definition at line 243 of file Auditor.h.

bool Auditor::m_isFinalized`[private]`

Auditor has been finalized flag.

Definition at line 245 of file Auditor.h.

bool Auditor::m_isInitialized`[private]`

Auditor has been initialized flag.

Definition at line 244 of file Auditor.h.

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

Message service.

Definition at line 239 of file Auditor.h.

std::string Auditor::m_name`[private]`

Auditor's name for identification.

Definition at line 237 of file Auditor.h.

int Auditor::m_outputLevel`[private]`

Auditor output level.

Definition at line 242 of file Auditor.h.

PropertyMgr* Auditor::m_PropertyMgr`[private]`

For management of properties.

Definition at line 241 of file Auditor.h.

SmartIF<ISvcLocator> Auditor::m_pSvcLocator`[mutable, private]`

Pointer to service locator service.

Definition at line 240 of file Auditor.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiKernel/GaudiKernel/Auditor.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiKernel/src/Lib/Auditor.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines