| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# AlgTool Class Reference

`#include <GaudiKernel/AlgTool.h>`

Inheritance diagram for AlgTool:

[legend]
Collaboration diagram for AlgTool:

[legend]

List of all members.

## Detailed Description

Base class from which all the concrete tool classes should be derived.

Specific methods for doing something usefull should be implemented in the concrete tools. Sub-types of this class could implement an additional interface for behaviour common to sets of concrete tools (for example vertexers).

Author:
  Gloria Corti

  Pere Mato

Definition at line 35 of file AlgTool.h.

## Public Member Functions
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown)
| Query for a given interface.
virtual unsigned long | addRef ()
| Reference Interface instance.
virtual unsigned long | release ()
| Release Interface instance.
virtual const std::string & | name () const
| Retrieve full identifying name of the concrete tool object.
virtual const std::string & | type () const
| Retrieve type (concrete class) of the sub-algtool.
virtual const IInterface * | parent () const
| Retrieve parent of the sub-algtool.
virtual StatusCode | configure ()
| Configuration (from OFFLINE to CONFIGURED).
virtual StatusCode | initialize ()
| Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode | start ()
| Start (from INITIALIZED to RUNNING).
virtual StatusCode | stop ()
| Stop (from RUNNING to INITIALIZED).
virtual StatusCode | finalize ()
| Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode | terminate ()
| Initialization (from CONFIGURED to OFFLINE).
virtual StatusCode | reinitialize ()
| Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual StatusCode | restart ()
| Initialization (from RUNNING to RUNNING, via INITIALIZED).
virtual Gaudi::StateMachine::State | FSMState () const
| Get the current state.
virtual Gaudi::StateMachine::State | targetFSMState () const
| When we are in the middle of a transition, get the state where the transition is leading us.
virtual StatusCode | sysInitialize ()
| Initialize AlgTool.
virtual StatusCode | sysStart ()
| Start AlgTool.
virtual StatusCode | sysStop ()
| Stop AlgTool.
virtual StatusCode | sysFinalize ()
| Finalize AlgTool.
virtual StatusCode | sysReinitialize ()
| Initialize AlgTool.
virtual StatusCode | sysRestart ()
| Start AlgTool.
virtual StatusCode | setProperty (const Property &p)
| Default implementations for IProperty interface.
virtual StatusCode | setProperty (const std::string &s)
| Set the property by string.
virtual StatusCode | setProperty (const std::string &n, const std::string &v)
| Set the property by std::string.
virtual StatusCode | getProperty (Property *p) const
| Get the property by 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
| Get the property by std::string.
virtual const std::vector < Property * > & | getProperties () const
| Get list of properties.
PropertyMgr * | getPropertyMgr ()
template<class TYPE>
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value
| AlgTool (const std::string &type, const std::string &name, const IInterface *parent)
| Standard Constructor.
ISvcLocator * | serviceLocator () const
| Retrieve pointer to service locator.
ISvcLocator * | svcLoc () const
| shortcut for the methos service locator
IMessageSvc * | msgSvc () const
| Retrieve pointer to message service.
IToolSvc * | toolSvc () const
| The standard ToolSvc service, Return a pointer to the service if present.
StatusCode | setProperties ()
| Method for setting declared properties to the values specified in the jobOptions via the job option service.
template<class T>
StatusCode | service (const std::string &name, T *&svc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist.
template<class T>
StatusCode | service (const std::string &type, const std::string &name, T *&svc) const
| Access a service by name, type creating it if it doesn't already exist.
void | declInterface (const InterfaceID &, void *)
| declare interface
template<class T>
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties.
IAuditorSvc * | auditorSvc () const
| Access the auditor service.
IMonitorSvc * | monitorSvc () const
| Access the monitor service.
template<class T>
void | declareInfo (const std::string &name, const T &var, const std::string &desc) const
| Declare monitoring information.
void | declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
| Declare monitoring information (special case).
## Protected Member Functions
int | outputLevel () const
| get tool's output level
virtual unsigned long | refCount () const
| Current number of refCounts.
IntegerProperty & | outputLevelProperty ()
| Accessor for the Message level property.
void | initOutputLevel (Property &prop)
| callback for output level property
virtual | ~AlgTool ()
## Private Types
typedef std::list< std::pair < InterfaceID, void * > > | InterfaceList
## Private Member Functions
StatusCode | service_i (const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
| implementation of service method
StatusCode | service_i (const std::string &svcType, const std::string &svcName, const InterfaceID &iid, void **ppS) const
## Private Attributes
IntegerProperty | m_outputLevel
| AlgTool output level.
std::string | m_type
| AlgTool type (concrete class name).
const std::string | m_name
| AlgTool full name.
const IInterface * | m_parent
| AlgTool parent.
unsigned long | m_refCount
| Reference counter.
ISvcLocator * | m_svcLocator
| Pointer to Service Locator service.
IMessageSvc * | m_messageSvc
| Message service.
IToolSvc * | m_ptoolSvc
| Tool service.
IMonitorSvc * | m_pMonitorSvc
| Online Monitoring Service.
std::string | m_monitorSvcName
| Name to use for Monitor Service.
PropertyMgr * | m_propertyMgr
| Property Manager.
InterfaceList | m_interfaceList
| Interface list.
std::string | m_threadID
| Thread Id for Alg Tool.
IAuditorSvc * | m_pAuditorSvc
| Auditor Service.
BooleanProperty | m_auditInit
bool | m_auditorInitialize
| flag for auditors in "initialize()"
bool | m_auditorStart
| flag for auditors in "start()"
bool | m_auditorStop
| flag for auditors in "stop()"
bool | m_auditorFinalize
| flag for auditors in "finalize()"
bool | m_auditorReinitialize
| flag for auditors in "reinitialize()"
bool | m_auditorRestart
| flag for auditors in "restart()"
Gaudi::StateMachine::State | m_state
| state of the Tool
Gaudi::StateMachine::State | m_targetState
| state of the Tool
## Friends
class | ToolSvc
## Classes
class | declareInterface

## Member Typedef Documentation

typedef std::list<std::pair<InterfaceID,void*> > AlgTool::InterfaceList`[private]`

Definition at line 327 of file AlgTool.h.

## Constructor & Destructor Documentation

AlgTool::AlgTool | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent |
| ) |  |  |

Standard Constructor.

Parameters:

  | type | the concrete class of the sub-algtool
  | name | the full name of the concrete sub-algtool
  | parent | the parent of the concrete sub-algtool

Definition at line 215 of file AlgTool.cpp.

    00219   : m_outputLevel ( MSG::NIL )
    00220   , m_type          ( type )
    00221   , m_name          ( name )
    00222   , m_parent        ( parent )
    00223   , m_refCount      ( 1 )
    00224   , m_svcLocator    ( 0 )
    00225   , m_messageSvc    ( 0 )
    00226   , m_ptoolSvc      ( 0 )
    00227   , m_pMonitorSvc   ( NULL )
    00228   , m_propertyMgr   ( new PropertyMgr() )
    00229   , m_interfaceList (       )
    00230   , m_threadID      (       )
    00231   , m_pAuditorSvc   ( 0     )
    00232   , m_auditInit     ( false )
    00233   , m_state         ( Gaudi::StateMachine::CONFIGURED )
    00234   , m_targetState   ( Gaudi::StateMachine::CONFIGURED )
    00235 {
    00236   declareProperty( "MonitorService", m_monitorSvcName = "MonitorSvc" );
    00237
    00238   { // get the "OutputLevel" property from parent
    00239     const Property* _p = Gaudi::Utils::getProperty ( parent , "OutputLevel") ;
    00240     if ( 0 != _p ) { m_outputLevel.assign( *_p ) ; }
    00241     declareProperty ( "OutputLevel"     , m_outputLevel ) ;
    00242      m_outputLevel.declareUpdateHandler(&AlgTool::initOutputLevel, this);
    00243   }
    00244
    00245   IInterface* _p = const_cast<IInterface*> ( parent ) ;
    00246
    00247   if      ( Algorithm* _alg = dynamic_cast<Algorithm*> ( _p ) )
    00248   {
    00249     m_svcLocator  = _alg -> serviceLocator  () ;
    00250     m_messageSvc  = _alg -> msgSvc          () ;
    00251     m_threadID    = getGaudiThreadIDfromName ( _alg -> name() ) ;
    00252   }
    00253   else if ( Service*   _svc = dynamic_cast<Service*>  ( _p ) )
    00254   {
    00255     m_svcLocator  = _svc -> serviceLocator () ;
    00256     m_messageSvc  = _svc -> msgSvc         () ;
    00257     m_threadID    = getGaudiThreadIDfromName ( _svc -> name() ) ;
    00258   }
    00259   else if ( AlgTool*   _too = dynamic_cast<AlgTool*>  ( _p ) )
    00260   {
    00261     m_svcLocator  = _too -> m_svcLocator;
    00262     m_messageSvc  = _too -> m_messageSvc;
    00263     m_threadID    = getGaudiThreadIDfromName ( _too ->m_threadID ) ;
    00264   }
    00265   else if ( Auditor*   _aud = dynamic_cast<Auditor*>  ( _p ) )
    00266   {
    00267     m_svcLocator  = _aud -> serviceLocator() ;
    00268     m_messageSvc  = _aud -> msgSvc()         ;
    00269     m_threadID    = getGaudiThreadIDfromName ( _aud -> name() )    ;
    00270   }
    00271   else
    00272   {
    00273     throw GaudiException
    00274       ( "Failure to create tool '"
    00275         + type + "/" + name + "': illegal parent type '"
    00276         + System::typeinfoName(typeid(*_p)) + "'", "AlgTool", 0 );
    00277   }
    00278
    00279
    00280   { // audit tools
    00281     IProperty *appMgr = 0 ;
    00282     StatusCode sc = m_svcLocator->service("ApplicationMgr", appMgr) ;
    00283     if  (sc.isFailure() || 0 == appMgr )
    00284     { throw GaudiException("Could not locate ApplicationMgr","AlgTool",0); }
    00285     const Property* p = Gaudi::Utils::getProperty( appMgr , "AuditTools");
    00286     if ( 0 != p ) { m_auditInit.assign ( *p ) ; }
    00287     declareProperty ( "AuditTools", m_auditInit );
    00288     bool audit = m_auditInit.value();
    00289     // Declare common AlgTool properties with their defaults
    00290     declareProperty ( "AuditInitialize" , m_auditorInitialize = audit ) ;
    00291     declareProperty ( "AuditStart"      , m_auditorStart      = audit ) ;
    00292     declareProperty ( "AuditStop"       , m_auditorStop       = audit ) ;
    00293     declareProperty ( "AuditFinalize"   , m_auditorFinalize   = audit ) ;
    00294   }
    00295
    00296   // check thread ID and try if tool name indicates thread ID
    00297   if ( m_threadID.empty() )
    00298   { m_threadID = getGaudiThreadIDfromName ( AlgTool::name() ) ; }
    00299 }

AlgTool::~AlgTool | ( |  | ) | `[protected, virtual]`

Definition at line 604 of file AlgTool.cpp.

    00606 {
    00607   delete m_propertyMgr;
    00608   if( m_ptoolSvc ) m_ptoolSvc->release();
    00609   if( m_pAuditorSvc ) m_pAuditorSvc->release();
    00610   if ( m_pMonitorSvc ) { m_pMonitorSvc->undeclareAll(this); m_pMonitorSvc->release(); }
    00611 }

## Member Function Documentation

StatusCode AlgTool::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvUnknown |
| ) |  |  | `[virtual]`

Query for a given interface.

Implements IInterface.

Reimplemented in PartitionSwitchTool.

Definition at line 40 of file AlgTool.cpp.

    00043 {
    00044   if ( 0 == ppvi ) { return StatusCode::FAILURE ; } // RETURN
    00045   //
    00046   if      ( IAlgTool        ::interfaceID() .versionMatch ( riid ) )
    00047   { *ppvi = static_cast<IAlgTool*>        ( this ) ; }
    00048   else if ( IProperty       ::interfaceID() .versionMatch ( riid ) )
    00049   { *ppvi = static_cast<IProperty*>       ( this ) ; }
    00050   else if ( IStateful       ::interfaceID() . versionMatch ( riid ) )
    00051   { *ppvi = static_cast<IStateful*>       ( this ) ; }
    00052   else if ( INamedInterface ::interfaceID() .versionMatch ( riid ) )
    00053   { *ppvi = static_cast<INamedInterface*> ( this ) ; }
    00054   else if ( IInterface      ::interfaceID() .versionMatch ( riid ) )
    00055   { *ppvi = static_cast<IInterface*>      ( this ) ; }
    00056   else
    00057   {
    00058     for ( InterfaceList::iterator it = m_interfaceList.begin() ;
    00059           m_interfaceList.end() != it ; ++it )
    00060     {
    00061       if ( !it->first.versionMatch ( riid ) ) { continue ; }
    00062       // OK
    00063       *ppvi = it->second ;
    00064       addRef() ;
    00065       return SUCCESS ;     // RETURN
    00066     }
    00067     *ppvi = 0 ;
    00068     return NO_INTERFACE ;  // RETURN
    00069   }
    00070   // increment the reference counter
    00071   addRef() ;
    00072   //
    00073   return SUCCESS;
    00074 }

unsigned long AlgTool::addRef | ( |  | ) | `[virtual]`

Reference Interface instance.

Implements IInterface.

Definition at line 20 of file AlgTool.cpp.

    00022 {
    00023   m_refCount++;
    00024   return m_refCount;
    00025 }

unsigned long AlgTool::release | ( |  | ) | `[virtual]`

Release Interface instance.

Implements IInterface.

Definition at line 28 of file AlgTool.cpp.

    00030 {
    00031   unsigned long count = --m_refCount;
    00032   if( count <= 0) {
    00033     delete this;
    00034   }
    00035   return count;
    00036 }

const std::string & AlgTool::name | ( |  | ) | const`[virtual]`

Retrieve full identifying name of the concrete tool object.

Implements INamedInterface.

Definition at line 84 of file AlgTool.cpp.

    00086 {
    00087   return m_name;
    00088 }

const std::string & AlgTool::type | ( |  | ) | const`[virtual]`

Retrieve type (concrete class) of the sub-algtool.

Implements IAlgTool.

Definition at line 91 of file AlgTool.cpp.

    00093 {
    00094   return m_type;
    00095 }

const IInterface * AlgTool::parent | ( |  | ) | const`[virtual]`

Retrieve parent of the sub-algtool.

Implements IAlgTool.

Definition at line 98 of file AlgTool.cpp.

    00100 {
    00101   return m_parent;
    00102 }

virtual StatusCode AlgTool::configure | ( |  | ) | `[inline, virtual]`

Configuration (from OFFLINE to CONFIGURED).

Implements IAlgTool.

Definition at line 60 of file AlgTool.h.

    00060 { return StatusCode::SUCCESS; }

StatusCode AlgTool::initialize | ( |  | ) | `[virtual]`

Initialization (from CONFIGURED to INITIALIZED).

Implements IAlgTool.

Reimplemented in GaudiHistoTool, GaudiTool, GaudiTupleTool, SequencerTimerTool, GFALDataStreamTool, EqSolver, FuncMinimum, DataStreamTool, PartitionSwitchTool, GaudiCommon< AlgTool >, GaudiHistos< GaudiTool >, and GaudiTuples< GaudiHistoTool >.

Definition at line 337 of file AlgTool.cpp.

    00339 {
    00340   // For the time being there is nothing to be done here.
    00341   // Setting the properties is done by the ToolSvc calling setProperties()
    00342   // explicitly.
    00343   return StatusCode::SUCCESS;
    00344 }

StatusCode AlgTool::start | ( |  | ) | `[virtual]`

Start (from INITIALIZED to RUNNING).

Implements IAlgTool.

Definition at line 382 of file AlgTool.cpp.

    00384 {
    00385   // For the time being there is nothing to be done here.
    00386   return StatusCode::SUCCESS;
    00387 }

StatusCode AlgTool::stop | ( |  | ) | `[virtual]`

Stop (from RUNNING to INITIALIZED).

Implements IAlgTool.

Definition at line 425 of file AlgTool.cpp.

    00427 {
    00428   // For the time being there is nothing to be done here.
    00429   return StatusCode::SUCCESS;
    00430 }

StatusCode AlgTool::finalize | ( |  | ) | `[virtual]`

Finalize (from INITIALIZED to CONFIGURED).

Implements IAlgTool.

Reimplemented in GaudiHistoTool, GaudiTool, GaudiTupleTool, SequencerTimerTool, GFALDataStreamTool, EqSolver, FuncMinimum, GslErrorCount, DataStreamTool, PartitionSwitchTool, GaudiCommon< AlgTool >, GaudiHistos< GaudiTool >, and GaudiTuples< GaudiHistoTool >.

Definition at line 468 of file AlgTool.cpp.

    00470 {
    00471   // For the time being there is nothing to be done here.
    00472   return StatusCode::SUCCESS;
    00473 }

virtual StatusCode AlgTool::terminate | ( |  | ) | `[inline, virtual]`

Initialization (from CONFIGURED to OFFLINE).

Implements IAlgTool.

Definition at line 65 of file AlgTool.h.

    00065 { return StatusCode::SUCCESS; }

StatusCode AlgTool::reinitialize | ( |  | ) | `[virtual]`

Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).

Implements IAlgTool.

Definition at line 517 of file AlgTool.cpp.

    00519 {
    00520   /* @TODO
    00521    * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
    00522    *                 is causing too many problems
    00523    *
    00524   // Default implementation is finalize+initialize
    00525   StatusCode sc = finalize();
    00526   if (sc.isFailure()) {
    00527     MsgStream log ( msgSvc() , name() );
    00528     log << MSG::ERROR << "reinitialize(): cannot be finalized" << endreq;
    00529     return sc;
    00530   }
    00531   sc = initialize();
    00532   if (sc.isFailure()) {
    00533     MsgStream log ( msgSvc() , name() );
    00534     log << MSG::ERROR << "reinitialize(): cannot be initialized" << endreq;
    00535     return sc;
    00536   }
    00537   */
    00538   return StatusCode::SUCCESS;
    00539 }

StatusCode AlgTool::restart | ( |  | ) | `[virtual]`

Initialization (from RUNNING to RUNNING, via INITIALIZED).

Implements IAlgTool.

Definition at line 584 of file AlgTool.cpp.

    00586 {
    00587   // Default implementation is stop+start
    00588   StatusCode sc = stop();
    00589   if (sc.isFailure()) {
    00590     MsgStream log ( msgSvc() , name() );
    00591     log << MSG::ERROR << "restart(): cannot be stopped" << endreq;
    00592     return sc;
    00593   }
    00594   sc = start();
    00595   if (sc.isFailure()) {
    00596     MsgStream log ( msgSvc() , name() );
    00597     log << MSG::ERROR << "restart(): cannot be started" << endreq;
    00598     return sc;
    00599   }
    00600   return StatusCode::SUCCESS;
    00601 }

virtual Gaudi::StateMachine::State AlgTool::FSMState | ( |  | ) | const`[inline, virtual]`

Get the current state.

Implements IAlgTool.

Definition at line 68 of file AlgTool.h.

    00068 { return m_state; }

virtual Gaudi::StateMachine::State AlgTool::targetFSMState | ( |  | ) | const`[inline, virtual]`

When we are in the middle of a transition, get the state where the transition is leading us.

Otherwise it returns the same state as state().

Implements IStateful.

Definition at line 69 of file AlgTool.h.

    00069 { return m_targetState; }

StatusCode AlgTool::sysInitialize | ( |  | ) | `[virtual]`

Initialize AlgTool.

Implements IAlgTool.

Definition at line 302 of file AlgTool.cpp.

    00302                                   {
    00303   //-----------------------------------------------------------------------------
    00304   StatusCode sc;
    00305
    00306   try {
    00307     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::INITIALIZE,m_state);
    00308     Gaudi::Guards::AuditorGuard guard(this,
    00309                                       // check if we want to audit the initialize
    00310                                       (m_auditorInitialize) ? auditorSvc() : 0,
    00311                                       IAuditor::Initialize);
    00312     sc = initialize();
    00313     if (sc.isSuccess())
    00314       m_state = m_targetState;
    00315     return sc;
    00316   }
    00317   catch( const GaudiException& Exception ) {
    00318     MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
    00319     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00320         << " is caught " << endreq;
    00321     log << MSG::ERROR << Exception  << endreq;
    00322   }
    00323   catch( const std::exception& Exception ) {
    00324     MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
    00325     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
    00326     log << MSG::ERROR << Exception.what()  << endreq;
    00327   }
    00328   catch( ... ) {
    00329     MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
    00330     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
    00331   }
    00332   return StatusCode::FAILURE ;
    00333
    00334 }

StatusCode AlgTool::sysStart | ( |  | ) | `[virtual]`

Start AlgTool.

Implements IAlgTool.

Definition at line 347 of file AlgTool.cpp.

    00347                              {
    00348   //-----------------------------------------------------------------------------
    00349   StatusCode sc;
    00350
    00351   try {
    00352     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
    00353     Gaudi::Guards::AuditorGuard guard(this,
    00354                                       // check if we want to audit the initialize
    00355                                       (m_auditorStart) ? auditorSvc() : 0,
    00356                                       IAuditor::Start);
    00357     sc = start();
    00358     if (sc.isSuccess())
    00359       m_state = m_targetState;
    00360     return sc;
    00361   }
    00362   catch( const GaudiException& Exception ) {
    00363     MsgStream log ( msgSvc() , name() + ".sysStart()" );
    00364     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00365         << " is caught " << endreq;
    00366     log << MSG::ERROR << Exception  << endreq;
    00367   }
    00368   catch( const std::exception& Exception ) {
    00369     MsgStream log ( msgSvc() , name() + ".sysStart()" );
    00370     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
    00371     log << MSG::ERROR << Exception.what()  << endreq;
    00372   }
    00373   catch( ... ) {
    00374     MsgStream log ( msgSvc() , name() + ".sysStart()" );
    00375     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
    00376   }
    00377   return StatusCode::FAILURE ;
    00378
    00379 }

StatusCode AlgTool::sysStop | ( |  | ) | `[virtual]`

Stop AlgTool.

Implements IAlgTool.

Definition at line 390 of file AlgTool.cpp.

    00390                             {
    00391   //-----------------------------------------------------------------------------
    00392   StatusCode sc;
    00393
    00394   try {
    00395     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
    00396     Gaudi::Guards::AuditorGuard guard(this,
    00397                                       // check if we want to audit the initialize
    00398                                       (m_auditorStop) ? auditorSvc() : 0,
    00399                                       IAuditor::Stop);
    00400     sc = stop();
    00401     if (sc.isSuccess())
    00402       m_state = m_targetState;
    00403     return sc;
    00404   }
    00405   catch( const GaudiException& Exception ) {
    00406     MsgStream log ( msgSvc() , name() + ".sysStop()" );
    00407     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00408         << " is caught " << endreq;
    00409     log << MSG::ERROR << Exception  << endreq;
    00410   }
    00411   catch( const std::exception& Exception ) {
    00412     MsgStream log ( msgSvc() , name() + ".sysStop()" );
    00413     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
    00414     log << MSG::ERROR << Exception.what()  << endreq;
    00415   }
    00416   catch( ... ) {
    00417     MsgStream log ( msgSvc() , name() + ".sysStop()" );
    00418     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
    00419   }
    00420   return StatusCode::FAILURE ;
    00421
    00422 }

StatusCode AlgTool::sysFinalize | ( |  | ) | `[virtual]`

Finalize AlgTool.

Implements IAlgTool.

Definition at line 433 of file AlgTool.cpp.

    00433                                 {
    00434   //-----------------------------------------------------------------------------
    00435
    00436   StatusCode sc;
    00437
    00438   try {
    00439     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::FINALIZE,m_state);
    00440     Gaudi::Guards::AuditorGuard guard(this,
    00441                                       // check if we want to audit the initialize
    00442                                       (m_auditorFinalize) ? auditorSvc() : 0,
    00443                                       IAuditor::Finalize);
    00444     sc = finalize();
    00445     if (sc.isSuccess())
    00446       m_state = m_targetState;
    00447     return sc;
    00448   }
    00449   catch( const GaudiException& Exception ) {
    00450     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
    00451     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00452         << " is caught " << endreq;
    00453     log << MSG::ERROR << Exception  << endreq;
    00454   }
    00455   catch( const std::exception& Exception ) {
    00456     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
    00457     log << MSG::FATAL << " Standard std::exception is caught " << endreq;
    00458     log << MSG::ERROR << Exception.what()  << endreq;
    00459   }
    00460   catch( ... ) {
    00461     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
    00462     log << MSG::FATAL << "UNKNOWN Exception is caught " << endreq;
    00463   }
    00464   return StatusCode::FAILURE;
    00465
    00466 }

StatusCode AlgTool::sysReinitialize | ( |  | ) | `[virtual]`

Initialize AlgTool.

Implements IAlgTool.

Definition at line 476 of file AlgTool.cpp.

    00476                                     {
    00477   //-----------------------------------------------------------------------------
    00478   StatusCode sc;
    00479
    00480   // Check that the current status is the correct one.
    00481   if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
    00482     MsgStream log ( msgSvc() , name() );
    00483     log << MSG::ERROR
    00484         << "sysReinitialize(): cannot reinitialize tool not initialized"
    00485         << endreq;
    00486     return StatusCode::FAILURE;
    00487   }
    00488
    00489   try {
    00490     Gaudi::Guards::AuditorGuard guard(this,
    00491                                       // check if we want to audit the initialize
    00492                                       (m_auditorReinitialize) ? auditorSvc() : 0,
    00493                                       IAuditor::ReInitialize);
    00494     sc = reinitialize();
    00495     return sc;
    00496   }
    00497   catch( const GaudiException& Exception ) {
    00498     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
    00499     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00500         << " is caught" << endreq;
    00501     log << MSG::ERROR << Exception  << endreq;
    00502   }
    00503   catch( const std::exception& Exception ) {
    00504     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
    00505     log << MSG::FATAL << " Standard std::exception is caught" << endreq;
    00506     log << MSG::ERROR << Exception.what()  << endreq;
    00507   }
    00508   catch( ... ) {
    00509     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
    00510     log << MSG::FATAL << "UNKNOWN Exception is caught" << endreq;
    00511   }
    00512   return StatusCode::FAILURE ;
    00513
    00514 }

StatusCode AlgTool::sysRestart | ( |  | ) | `[virtual]`

Start AlgTool.

Implements IAlgTool.

Definition at line 542 of file AlgTool.cpp.

    00542                                {
    00543   //-----------------------------------------------------------------------------
    00544   StatusCode sc;
    00545
    00546   // Check that the current status is the correct one.
    00547   if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
    00548     MsgStream log ( msgSvc() , name() );
    00549     log << MSG::ERROR
    00550         << "sysRestart(): cannot reinitialize tool not started"
    00551         << endreq;
    00552     return StatusCode::FAILURE;
    00553   }
    00554
    00555   try {
    00556     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
    00557     Gaudi::Guards::AuditorGuard guard(this,
    00558                                       // check if we want to audit the initialize
    00559                                       (m_auditorRestart) ? auditorSvc() : 0,
    00560                                       IAuditor::ReStart);
    00561     sc = restart();
    00562     return sc;
    00563   }
    00564   catch( const GaudiException& Exception ) {
    00565     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
    00566     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00567         << " is caught" << endreq;
    00568     log << MSG::ERROR << Exception  << endreq;
    00569   }
    00570   catch( const std::exception& Exception ) {
    00571     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
    00572     log << MSG::FATAL << " Standard std::exception is caught" << endreq;
    00573     log << MSG::ERROR << Exception.what()  << endreq;
    00574   }
    00575   catch( ... ) {
    00576     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
    00577     log << MSG::FATAL << "UNKNOWN Exception is caught" << endreq;
    00578   }
    00579   return StatusCode::FAILURE ;
    00580
    00581 }

StatusCode AlgTool::setProperty | ( | const Property & | p | ) | `[virtual]`

Default implementations for IProperty interface.

Implements IProperty.

Definition at line 132 of file AlgTool.cpp.

    00134 {
    00135   return m_propertyMgr->setProperty(p);
    00136 }

StatusCode AlgTool::setProperty | ( | const std::string & | s | ) | `[virtual]`

Set the property by string.

Implements IProperty.

Definition at line 139 of file AlgTool.cpp.

    00141 {
    00142   return m_propertyMgr->setProperty(s);
    00143 }

StatusCode AlgTool::setProperty | ( | const std::string & | n,
|  | const std::string & | v |
| ) |  |  | `[virtual]`

Set the property by std::string.

Implements IProperty.

Definition at line 146 of file AlgTool.cpp.

    00148 {
    00149   return m_propertyMgr->setProperty(n,v);
    00150 }

StatusCode AlgTool::getProperty | ( | Property * | p | ) | const`[virtual]`

Get the property by property.

Implements IProperty.

Definition at line 153 of file AlgTool.cpp.

    00155 {
    00156   return m_propertyMgr->getProperty(p);
    00157 }

const Property & AlgTool::getProperty | ( | const std::string & | name | ) | const`[virtual]`

Get the property by name.

Implements IProperty.

Definition at line 160 of file AlgTool.cpp.

    00161 {
    00162   return m_propertyMgr->getProperty(n);
    00163 }

StatusCode AlgTool::getProperty | ( | const std::string & | n,
|  | std::string & | v |
| ) |  |  | const`[virtual]`

Get the property by std::string.

Implements IProperty.

Definition at line 166 of file AlgTool.cpp.

    00168 {
    00169   return m_propertyMgr->getProperty(n,v);
    00170 }

const std::vector< Property * > & AlgTool::getProperties | ( |  | ) | const`[virtual]`

Get list of properties.

Implements IProperty.

Definition at line 173 of file AlgTool.cpp.

    00175 {
    00176   return m_propertyMgr->getProperties();
    00177 }

PropertyMgr* AlgTool::getPropertyMgr | ( |  | ) | `[inline]`

Definition at line 98 of file AlgTool.h.

    00098 { return m_propertyMgr; }

template<class TYPE>

StatusCode AlgTool::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 convinient 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 144 of file AlgTool.h.

    00146   { return Gaudi::Utils::setProperty ( m_propertyMgr , name , value ) ; }

ISvcLocator * AlgTool::serviceLocator | ( |  | ) | const

Retrieve pointer to service locator.

Definition at line 105 of file AlgTool.cpp.

    00107 {
    00108   return m_svcLocator;
    00109 }

ISvcLocator* AlgTool::svcLoc | ( |  | ) | const`[inline]`

shortcut for the methos service locator

Definition at line 162 of file AlgTool.h.

    00162 { return serviceLocator() ; }

IMessageSvc * AlgTool::msgSvc | ( |  | ) | const

Retrieve pointer to message service.

Definition at line 112 of file AlgTool.cpp.

    00114 {
    00115   return m_messageSvc;
    00116 }

IToolSvc * AlgTool::toolSvc | ( |  | ) | const

The standard ToolSvc service, Return a pointer to the service if present.

Definition at line 119 of file AlgTool.cpp.

    00121 {
    00122   if ( 0 == m_ptoolSvc ) {
    00123     StatusCode sc = service( "ToolSvc", m_ptoolSvc, true );
    00124     if( sc.isFailure() ) {
    00125       throw GaudiException("Service [ToolSvc] not found", name(), sc);
    00126     }
    00127   }
    00128   return m_ptoolSvc;
    00129 }

StatusCode AlgTool::setProperties | ( |  | ) |

Method for setting declared properties to the values specified in the jobOptions via the job option service.

This method is called by the ToolSvc after creating the concrete tool, before passing it to the requesting parent and does not need to be called explicitly.

Definition at line 180 of file AlgTool.cpp.

    00182 {
    00183   IJobOptionsSvc* jos;
    00184   if( m_svcLocator == 0) {
    00185     return StatusCode::FAILURE;
    00186   }
    00187   StatusCode sc = m_svcLocator->service("JobOptionsSvc", jos);
    00188   if( !sc.isSuccess() )  return StatusCode::FAILURE;
    00189
    00190   // set first generic Properties
    00191   sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
    00192   if( sc.isFailure() ) return StatusCode::FAILURE;
    00193
    00194   // set specific Properties
    00195   if (isGaudiThreaded(name())) {
    00196     if(jos->setMyProperties( name(), this ).isFailure()) {
    00197       return StatusCode::FAILURE;
    00198     }
    00199   }
    00200   jos->release();
    00201
    00202
    00203   // Change my own outputlevel
    00204   if ( 0 != m_messageSvc )
    00205   {
    00206     if ( MSG::NIL != m_outputLevel )
    00207     { m_messageSvc -> setOutputLevel ( name () , m_outputLevel ) ; }
    00208     m_outputLevel = m_messageSvc -> outputLevel ( name () ) ;
    00209   }
    00210
    00211   return StatusCode::SUCCESS;
    00212 }

template<class T>

StatusCode AlgTool::service | ( | const std::string & | name,
|  | T *& | svc,
|  | bool | createIf = `true` |
| ) |  |  | const`[inline]`

Access a service by name, creating it if it doesn't already exist.

Definition at line 182 of file AlgTool.h.

    00182                                                                  {
    00183     return service_i(name, createIf, T::interfaceID(), (void**)&svc);
    00184   }

template<class T>

StatusCode AlgTool::service | ( | const std::string & | type,
|  | const std::string & | name,
|  | T *& | svc |
| ) |  |  | const`[inline]`

Access a service by name, type creating it if it doesn't already exist.

Definition at line 189 of file AlgTool.h.

    00189                                                                                    {
    00190     return service_i(type, name, T::interfaceID(), (void**)&svc);
    00191   }

void AlgTool::declInterface | ( | const InterfaceID & | iid,
|  | void * | ii |
| ) |  |  |

declare interface

Definition at line 76 of file AlgTool.cpp.

    00078 {
    00079   m_interfaceList.push_back(std::make_pair(iid, ii));
    00080 }

template<class T>

Property* AlgTool::declareProperty | ( | const std::string & | name,
|  | T & | property,
|  | const std::string & | doc = `"none"` |
| ) |  |  | const`[inline]`

Declare the named property.

      MyTool ( const std::string& type   ,
               const std::string& name   ,
               const IInterface*  parent )
         : AlgTool  ( type , name , pSvc )
         , 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 234 of file AlgTool.h.

    00237   {
    00238     return m_propertyMgr -> declareProperty ( name , property , doc ) ;
    00239   }

Property* AlgTool::declareRemoteProperty | ( | const std::string & | name,
|  | IProperty * | rsvc,
|  | const std::string & | rname = `""` |
| ) |  |  | const`[inline]`

Declare remote named properties.

Definition at line 242 of file AlgTool.h.

    00245   {
    00246     return m_propertyMgr-> declareRemoteProperty ( name , rsvc , rname ) ;
    00247   }

IAuditorSvc * AlgTool::auditorSvc | ( |  | ) | const

Access the auditor service.

Definition at line 638 of file AlgTool.cpp.

    00638                                        {
    00639 //---------------------------------------------------------------------------
    00640   if ( 0 == m_pAuditorSvc ) {
    00641     StatusCode sc = service( "AuditorSvc", m_pAuditorSvc, true );
    00642     if( sc.isFailure() ) {
    00643       throw GaudiException("Service [AuditorSvc] not found", name(), sc);
    00644     }
    00645   }
    00646   return m_pAuditorSvc;
    00647 }

IMonitorSvc* AlgTool::monitorSvc | ( |  | ) | const`[inline]`

Access the monitor service.

Attention:
  Note that this method will return a NULL pointer if no monitor service is configured to be present. You must take this possibility into account when using the pointer

Returns:
  Pointer to the Monitor service

Return values:

  | NULL | No monitor service is present
  | non-NULL | A monitor service is present and available to be used

Definition at line 261 of file AlgTool.h.

    00262   {
    00263     // If not already located try to locate it without forcing a creation
    00264     if ( !m_pMonitorSvc ){
    00265       service_i( m_monitorSvcName, false,
    00266                  IMonitorSvc::interfaceID(), pp_cast<void>(&m_pMonitorSvc) );
    00267     }
    00268     return m_pMonitorSvc;
    00269   }

template<class T>

void AlgTool::declareInfo | ( | const std::string & | name,
|  | const T & | var,
|  | const std::string & | desc |
| ) |  |  | const`[inline]`

Declare monitoring information.

Parameters:

  | name | Monitoring information name known to the external system
  | var | Monitoring Listener address (the item to monitor...)
  | desc | Textual description of the information being monitored

Definition at line 277 of file AlgTool.h.

    00280   {
    00281     IMonitorSvc* mS = monitorSvc();
    00282     if ( mS ) mS->declareInfo(name, var, desc, this);
    00283   }

void AlgTool::declareInfo | ( | const std::string & | name,
|  | const std::string & | format,
|  | const void * | var,
|  | int | size,
|  | const std::string & | desc |
| ) |  |  | const`[inline]`

Declare monitoring information (special case).

Parameters:

  | name | Monitoring information name known to the external system
  | format | Format information
  | var | Monitoring Listener address
  | size | Monitoring Listener address size
  | desc | Textual description of the information being monitored

Definition at line 292 of file AlgTool.h.

    00297   {
    00298     IMonitorSvc* mS = monitorSvc();
    00299     if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
    00300   }

int AlgTool::outputLevel | ( |  | ) | const`[inline, protected]`

get tool's output level

Definition at line 305 of file AlgTool.h.

    00305 { return (int)m_outputLevel ; }

virtual unsigned long AlgTool::refCount | ( |  | ) | const`[inline, protected, virtual]`

Current number of refCounts.

Avoids having to call addRef() + release() to get current refCount. Used in ToolSvc.

Implements IAlgTool.

Definition at line 311 of file AlgTool.h.

    00311 { return m_refCount; }

IntegerProperty& AlgTool::outputLevelProperty | ( |  | ) | `[inline, protected]`

Accessor for the Message level property.

Definition at line 314 of file AlgTool.h.

    00314 { return m_outputLevel; }

void AlgTool::initOutputLevel | ( | Property & | prop | ) | `[protected]`

callback for output level property

Definition at line 651 of file AlgTool.cpp.

    00651                                                  {
    00652 //-----------------------------------------------------------------------------
    00653    // do nothing... yet ?
    00654 }

StatusCode AlgTool::service_i | ( | const std::string & | algName,
|  | bool | createIf,
|  | const InterfaceID & | iid,
|  | void ** | ppSvc |
| ) |  |  | const`[private]`

implementation of service method

Definition at line 616 of file AlgTool.cpp.

    00619                                        {
    00620   MsgStream log(msgSvc(), name());
    00621   ServiceLocatorHelper helper(*serviceLocator(), log, name());
    00622   return helper.getService(svcName, createIf, iid, ppSvc);
    00623 }

StatusCode AlgTool::service_i | ( | const std::string & | svcType,
|  | const std::string & | svcName,
|  | const InterfaceID & | iid,
|  | void ** | ppS |
| ) |  |  | const`[private]`

Definition at line 627 of file AlgTool.cpp.

    00630                                        {
    00631
    00632   MsgStream log(msgSvc(), name());
    00633   ServiceLocatorHelper helper(*serviceLocator(), log, name());
    00634   return  helper.createService(svcType, svcName, iid, ppSvc);
    00635 }

## Friends And Related Function Documentation

friend class ToolSvc`[friend]`

Definition at line 38 of file AlgTool.h.

## Member Data Documentation

IntegerProperty AlgTool::m_outputLevel`[private]`

AlgTool output level.

Definition at line 328 of file AlgTool.h.

std::string AlgTool::m_type`[private]`

AlgTool type (concrete class name).

Reimplemented in EqSolver, and FuncMinimum.

Definition at line 329 of file AlgTool.h.

const std::string AlgTool::m_name`[private]`

AlgTool full name.

Definition at line 330 of file AlgTool.h.

const IInterface* AlgTool::m_parent`[private]`

AlgTool parent.

Definition at line 331 of file AlgTool.h.

unsigned long AlgTool::m_refCount`[private]`

Reference counter.

Definition at line 332 of file AlgTool.h.

ISvcLocator* AlgTool::m_svcLocator`[mutable, private]`

Pointer to Service Locator service.

Definition at line 333 of file AlgTool.h.

IMessageSvc* AlgTool::m_messageSvc`[mutable, private]`

Message service.

Definition at line 334 of file AlgTool.h.

IToolSvc* AlgTool::m_ptoolSvc`[mutable, private]`

Tool service.

Definition at line 335 of file AlgTool.h.

IMonitorSvc* AlgTool::m_pMonitorSvc`[mutable, private]`

Online Monitoring Service.

Definition at line 336 of file AlgTool.h.

std::string AlgTool::m_monitorSvcName`[private]`

Name to use for Monitor Service.

Definition at line 337 of file AlgTool.h.

PropertyMgr* AlgTool::m_propertyMgr`[private]`

Property Manager.

Definition at line 338 of file AlgTool.h.

InterfaceList AlgTool::m_interfaceList`[private]`

Interface list.

Definition at line 339 of file AlgTool.h.

std::string AlgTool::m_threadID`[private]`

Thread Id for Alg Tool.

Definition at line 340 of file AlgTool.h.

IAuditorSvc* AlgTool::m_pAuditorSvc`[mutable, private]`

Auditor Service.

Definition at line 352 of file AlgTool.h.

BooleanProperty AlgTool::m_auditInit`[private]`

Definition at line 354 of file AlgTool.h.

bool AlgTool::m_auditorInitialize`[private]`

flag for auditors in "initialize()"

Definition at line 355 of file AlgTool.h.

bool AlgTool::m_auditorStart`[private]`

flag for auditors in "start()"

Definition at line 356 of file AlgTool.h.

bool AlgTool::m_auditorStop`[private]`

flag for auditors in "stop()"

Definition at line 357 of file AlgTool.h.

bool AlgTool::m_auditorFinalize`[private]`

flag for auditors in "finalize()"

Definition at line 358 of file AlgTool.h.

bool AlgTool::m_auditorReinitialize`[private]`

flag for auditors in "reinitialize()"

Definition at line 359 of file AlgTool.h.

bool AlgTool::m_auditorRestart`[private]`

flag for auditors in "restart()"

Definition at line 360 of file AlgTool.h.

Gaudi::StateMachine::State AlgTool::m_state`[private]`

state of the Tool

Definition at line 362 of file AlgTool.h.

Gaudi::StateMachine::State AlgTool::m_targetState`[private]`

state of the Tool

Definition at line 363 of file AlgTool.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiKernel/GaudiKernel/AlgTool.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiKernel/src/Lib/AlgTool.cpp