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:
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:
nameThe algorithm object's name
svclocA 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:
namethe property name
propertythe property itself,
docthe 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.

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:
namename of the property
valuevalue 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::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

Auditor is enabled flag.

Definition at line 243 of file Auditor.h.

Auditor has been finalized flag.

Definition at line 245 of file Auditor.h.

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.

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.

For management of properties.

Definition at line 241 of file Auditor.h.

Pointer to service locator service.

Definition at line 240 of file Auditor.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Fri Sep 2 2011 16:25:15 for Gaudi Framework, version v22r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004