| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# AlgTool Class Reference

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

`#include <GaudiKernel/AlgTool.h>`

Inheritance diagram for AlgTool:

[legend]
Collaboration diagram for AlgTool:

[legend]

List of all members.

## Public Member Functions
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown)
| Query for a given interface.
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 ()
virtual StatusCode | initialize ()
virtual StatusCode | start ()
virtual StatusCode | stop ()
virtual StatusCode | finalize ()
virtual StatusCode | terminate ()
virtual StatusCode | reinitialize ()
virtual StatusCode | restart ()
virtual Gaudi::StateMachine::State | FSMState () const
virtual Gaudi::StateMachine::State | targetFSMState () const
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)
virtual StatusCode | setProperty (const std::string &n, const std::string &v)
virtual StatusCode | getProperty (Property *p) const
virtual const Property & | getProperty (const std::string &name) const
virtual StatusCode | getProperty (const std::string &n, std::string &v) const
virtual const std::vector < Property * > & | getProperties () const
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 method 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
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.
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

## Detailed Description

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

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

Author:
  Gloria Corti

  Pere Mato

Definition at line 35 of file AlgTool.h.

## Member Typedef Documentation

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

Definition at line 313 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 184 of file AlgTool.cpp.

    00188   : m_outputLevel ( MSG::NIL )
    00189   , m_type          ( type )
    00190   , m_name          ( name )
    00191   , m_parent        ( parent )
    00192   , m_svcLocator    ( 0 )
    00193   , m_messageSvc    ( 0 )
    00194   , m_ptoolSvc      ( 0 )
    00195   , m_pMonitorSvc   ( NULL )
    00196   , m_propertyMgr   ( new PropertyMgr() )
    00197   , m_interfaceList (       )
    00198   , m_threadID      (       )
    00199   , m_pAuditorSvc   ( 0     )
    00200   , m_auditInit     ( false )
    00201   , m_state         ( Gaudi::StateMachine::CONFIGURED )
    00202   , m_targetState   ( Gaudi::StateMachine::CONFIGURED )
    00203 {
    00204   addRef(); // Initial count set to 1
    00205
    00206   declareProperty( "MonitorService", m_monitorSvcName = "MonitorSvc" );
    00207
    00208   { // get the "OutputLevel" property from parent
    00209     const Property* _p = Gaudi::Utils::getProperty ( parent , "OutputLevel") ;
    00210     if ( 0 != _p ) { m_outputLevel.assign( *_p ) ; }
    00211     declareProperty ( "OutputLevel"     , m_outputLevel ) ;
    00212      m_outputLevel.declareUpdateHandler(&AlgTool::initOutputLevel, this);
    00213   }
    00214
    00215   IInterface* _p = const_cast<IInterface*> ( parent ) ;
    00216
    00217   if      ( Algorithm* _alg = dynamic_cast<Algorithm*> ( _p ) )
    00218   {
    00219     m_svcLocator  = _alg -> serviceLocator  () ;
    00220     m_messageSvc  = _alg -> msgSvc          () ;
    00221     m_threadID    = getGaudiThreadIDfromName ( _alg -> name() ) ;
    00222   }
    00223   else if ( Service*   _svc = dynamic_cast<Service*>  ( _p ) )
    00224   {
    00225     m_svcLocator  = _svc -> serviceLocator () ;
    00226     m_messageSvc  = _svc -> msgSvc         () ;
    00227     m_threadID    = getGaudiThreadIDfromName ( _svc -> name() ) ;
    00228   }
    00229   else if ( AlgTool*   _too = dynamic_cast<AlgTool*>  ( _p ) )
    00230   {
    00231     m_svcLocator  = _too -> m_svcLocator;
    00232     m_messageSvc  = _too -> m_messageSvc;
    00233     m_threadID    = getGaudiThreadIDfromName ( _too ->m_threadID ) ;
    00234   }
    00235   else if ( Auditor*   _aud = dynamic_cast<Auditor*>  ( _p ) )
    00236   {
    00237     m_svcLocator  = _aud -> serviceLocator() ;
    00238     m_messageSvc  = _aud -> msgSvc()         ;
    00239     m_threadID    = getGaudiThreadIDfromName ( _aud -> name() )    ;
    00240   }
    00241   else
    00242   {
    00243     throw GaudiException
    00244       ( "Failure to create tool '"
    00245         + type + "/" + name + "': illegal parent type '"
    00246         + System::typeinfoName(typeid(*_p)) + "'", "AlgTool", 0 );
    00247   }
    00248
    00249
    00250   { // audit tools
    00251     SmartIF<IProperty> appMgr(m_svcLocator->service("ApplicationMgr"));
    00252     if ( !appMgr.isValid() ) {
    00253       throw GaudiException("Could not locate ApplicationMgr","AlgTool",0);
    00254     }
    00255     const Property* p = Gaudi::Utils::getProperty( appMgr , "AuditTools");
    00256     if ( 0 != p ) { m_auditInit.assign ( *p ) ; }
    00257     declareProperty ( "AuditTools", m_auditInit );
    00258     bool audit = m_auditInit.value();
    00259     // Declare common AlgTool properties with their defaults
    00260     declareProperty ( "AuditInitialize" , m_auditorInitialize = audit ) ;
    00261     declareProperty ( "AuditStart"      , m_auditorStart      = audit ) ;
    00262     declareProperty ( "AuditStop"       , m_auditorStop       = audit ) ;
    00263     declareProperty ( "AuditFinalize"   , m_auditorFinalize   = audit ) ;
    00264   }
    00265
    00266   // check thread ID and try if tool name indicates thread ID
    00267   if ( m_threadID.empty() )
    00268   { m_threadID = getGaudiThreadIDfromName ( AlgTool::name() ) ; }
    00269 }

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

Definition at line 574 of file AlgTool.cpp.

    00576 {
    00577   delete m_propertyMgr;
    00578   if( m_ptoolSvc ) m_ptoolSvc->release();
    00579   if( m_pAuditorSvc ) m_pAuditorSvc->release();
    00580   if ( m_pMonitorSvc ) { m_pMonitorSvc->undeclareAll(this); m_pMonitorSvc->release(); }
    00581 }

## Member Function Documentation

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

Query for a given interface.

Reimplemented in extends1< AlgTool, IDataStreamTool >, extends1< GaudiTool, IFuncMinimum >, extends1< AlgTool, IGslErrorHandler >, extends1< AlgTool, IFileAccess >, extends1< AlgTool, IPartitionControl >, and extends1< GaudiTool, IEqSolver >.

Definition at line 20 of file AlgTool.cpp.

    00023 {
    00024   if ( 0 == ppvi ) { return StatusCode::FAILURE ; } // RETURN
    00025   StatusCode sc = base_class::queryInterface(riid,ppvi);
    00026   if (sc.isSuccess()) {
    00027     return sc;
    00028   }
    00029   else {
    00030     for ( InterfaceList::iterator it = m_interfaceList.begin() ;
    00031           m_interfaceList.end() != it ; ++it )
    00032     {
    00033       if ( !it->first.versionMatch ( riid ) ) { continue ; }
    00034       // OK
    00035       *ppvi = it->second ;
    00036       addRef() ;
    00037       return SUCCESS ;     // RETURN
    00038     }
    00039     *ppvi = 0 ;
    00040     return NO_INTERFACE ;  // RETURN
    00041   }
    00042   // increment the reference counter
    00043   addRef() ;
    00044   //
    00045   return SUCCESS;
    00046 }

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

Retrieve full identifying name of the concrete tool object.

Definition at line 56 of file AlgTool.cpp.

    00058 {
    00059   return m_name;
    00060 }

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

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

Definition at line 63 of file AlgTool.cpp.

    00065 {
    00066   return m_type;
    00067 }

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

Retrieve parent of the sub-algtool.

Definition at line 70 of file AlgTool.cpp.

    00072 {
    00073   return m_parent;
    00074 }

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

Definition at line 52 of file AlgTool.h.

    00052 { return StatusCode::SUCCESS; }

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

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

Definition at line 307 of file AlgTool.cpp.

    00309 {
    00310   // For the time being there is nothing to be done here.
    00311   // Setting the properties is done by the ToolSvc calling setProperties()
    00312   // explicitly.
    00313   return StatusCode::SUCCESS;
    00314 }

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

Definition at line 352 of file AlgTool.cpp.

    00354 {
    00355   // For the time being there is nothing to be done here.
    00356   return StatusCode::SUCCESS;
    00357 }

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

Definition at line 395 of file AlgTool.cpp.

    00397 {
    00398   // For the time being there is nothing to be done here.
    00399   return StatusCode::SUCCESS;
    00400 }

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

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

Definition at line 438 of file AlgTool.cpp.

    00440 {
    00441   // For the time being there is nothing to be done here.
    00442   return StatusCode::SUCCESS;
    00443 }

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

Definition at line 57 of file AlgTool.h.

    00057 { return StatusCode::SUCCESS; }

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

Definition at line 487 of file AlgTool.cpp.

    00489 {
    00490   /* @TODO
    00491    * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
    00492    *                 is causing too many problems
    00493    *
    00494   // Default implementation is finalize+initialize
    00495   StatusCode sc = finalize();
    00496   if (sc.isFailure()) {
    00497     MsgStream log ( msgSvc() , name() );
    00498     log << MSG::ERROR << "reinitialize(): cannot be finalized" << endmsg;
    00499     return sc;
    00500   }
    00501   sc = initialize();
    00502   if (sc.isFailure()) {
    00503     MsgStream log ( msgSvc() , name() );
    00504     log << MSG::ERROR << "reinitialize(): cannot be initialized" << endmsg;
    00505     return sc;
    00506   }
    00507   */
    00508   return StatusCode::SUCCESS;
    00509 }

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

Definition at line 554 of file AlgTool.cpp.

    00556 {
    00557   // Default implementation is stop+start
    00558   StatusCode sc = stop();
    00559   if (sc.isFailure()) {
    00560     MsgStream log ( msgSvc() , name() );
    00561     log << MSG::ERROR << "restart(): cannot be stopped" << endmsg;
    00562     return sc;
    00563   }
    00564   sc = start();
    00565   if (sc.isFailure()) {
    00566     MsgStream log ( msgSvc() , name() );
    00567     log << MSG::ERROR << "restart(): cannot be started" << endmsg;
    00568     return sc;
    00569   }
    00570   return StatusCode::SUCCESS;
    00571 }

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

Definition at line 60 of file AlgTool.h.

    00060 { return m_state; }

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

Definition at line 61 of file AlgTool.h.

    00061 { return m_targetState; }

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

Initialize AlgTool.

Definition at line 272 of file AlgTool.cpp.

    00272                                   {
    00273   //-----------------------------------------------------------------------------
    00274   StatusCode sc;
    00275
    00276   try {
    00277     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::INITIALIZE,m_state);
    00278     Gaudi::Guards::AuditorGuard guard(this,
    00279                                       // check if we want to audit the initialize
    00280                                       (m_auditorInitialize) ? auditorSvc() : 0,
    00281                                       IAuditor::Initialize);
    00282     sc = initialize();
    00283     if (sc.isSuccess())
    00284       m_state = m_targetState;
    00285     return sc;
    00286   }
    00287   catch( const GaudiException& Exception ) {
    00288     MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
    00289     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00290         << " is caught " << endmsg;
    00291     log << MSG::ERROR << Exception  << endmsg;
    00292   }
    00293   catch( const std::exception& Exception ) {
    00294     MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
    00295     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00296     log << MSG::ERROR << Exception.what()  << endmsg;
    00297   }
    00298   catch( ... ) {
    00299     MsgStream log ( msgSvc() , name() + ".sysInitialize()" );
    00300     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00301   }
    00302   return StatusCode::FAILURE ;
    00303
    00304 }

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

Start AlgTool.

Definition at line 317 of file AlgTool.cpp.

    00317                              {
    00318   //-----------------------------------------------------------------------------
    00319   StatusCode sc;
    00320
    00321   try {
    00322     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
    00323     Gaudi::Guards::AuditorGuard guard(this,
    00324                                       // check if we want to audit the initialize
    00325                                       (m_auditorStart) ? auditorSvc() : 0,
    00326                                       IAuditor::Start);
    00327     sc = start();
    00328     if (sc.isSuccess())
    00329       m_state = m_targetState;
    00330     return sc;
    00331   }
    00332   catch( const GaudiException& Exception ) {
    00333     MsgStream log ( msgSvc() , name() + ".sysStart()" );
    00334     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00335         << " is caught " << endmsg;
    00336     log << MSG::ERROR << Exception  << endmsg;
    00337   }
    00338   catch( const std::exception& Exception ) {
    00339     MsgStream log ( msgSvc() , name() + ".sysStart()" );
    00340     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00341     log << MSG::ERROR << Exception.what()  << endmsg;
    00342   }
    00343   catch( ... ) {
    00344     MsgStream log ( msgSvc() , name() + ".sysStart()" );
    00345     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00346   }
    00347   return StatusCode::FAILURE ;
    00348
    00349 }

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

Stop AlgTool.

Definition at line 360 of file AlgTool.cpp.

    00360                             {
    00361   //-----------------------------------------------------------------------------
    00362   StatusCode sc;
    00363
    00364   try {
    00365     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
    00366     Gaudi::Guards::AuditorGuard guard(this,
    00367                                       // check if we want to audit the initialize
    00368                                       (m_auditorStop) ? auditorSvc() : 0,
    00369                                       IAuditor::Stop);
    00370     sc = stop();
    00371     if (sc.isSuccess())
    00372       m_state = m_targetState;
    00373     return sc;
    00374   }
    00375   catch( const GaudiException& Exception ) {
    00376     MsgStream log ( msgSvc() , name() + ".sysStop()" );
    00377     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00378         << " is caught " << endmsg;
    00379     log << MSG::ERROR << Exception  << endmsg;
    00380   }
    00381   catch( const std::exception& Exception ) {
    00382     MsgStream log ( msgSvc() , name() + ".sysStop()" );
    00383     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00384     log << MSG::ERROR << Exception.what()  << endmsg;
    00385   }
    00386   catch( ... ) {
    00387     MsgStream log ( msgSvc() , name() + ".sysStop()" );
    00388     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00389   }
    00390   return StatusCode::FAILURE ;
    00391
    00392 }

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

Finalize AlgTool.

Definition at line 403 of file AlgTool.cpp.

    00403                                 {
    00404   //-----------------------------------------------------------------------------
    00405
    00406   StatusCode sc;
    00407
    00408   try {
    00409     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::FINALIZE,m_state);
    00410     Gaudi::Guards::AuditorGuard guard(this,
    00411                                       // check if we want to audit the initialize
    00412                                       (m_auditorFinalize) ? auditorSvc() : 0,
    00413                                       IAuditor::Finalize);
    00414     sc = finalize();
    00415     if (sc.isSuccess())
    00416       m_state = m_targetState;
    00417     return sc;
    00418   }
    00419   catch( const GaudiException& Exception ) {
    00420     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
    00421     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00422         << " is caught " << endmsg;
    00423     log << MSG::ERROR << Exception  << endmsg;
    00424   }
    00425   catch( const std::exception& Exception ) {
    00426     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
    00427     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00428     log << MSG::ERROR << Exception.what()  << endmsg;
    00429   }
    00430   catch( ... ) {
    00431     MsgStream log ( msgSvc() , name() + ".sysFinalize()" );
    00432     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00433   }
    00434   return StatusCode::FAILURE;
    00435
    00436 }

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

Initialize AlgTool.

Definition at line 446 of file AlgTool.cpp.

    00446                                     {
    00447   //-----------------------------------------------------------------------------
    00448   StatusCode sc;
    00449
    00450   // Check that the current status is the correct one.
    00451   if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
    00452     MsgStream log ( msgSvc() , name() );
    00453     log << MSG::ERROR
    00454         << "sysReinitialize(): cannot reinitialize tool not initialized"
    00455         << endmsg;
    00456     return StatusCode::FAILURE;
    00457   }
    00458
    00459   try {
    00460     Gaudi::Guards::AuditorGuard guard(this,
    00461                                       // check if we want to audit the initialize
    00462                                       (m_auditorReinitialize) ? auditorSvc() : 0,
    00463                                       IAuditor::ReInitialize);
    00464     sc = reinitialize();
    00465     return sc;
    00466   }
    00467   catch( const GaudiException& Exception ) {
    00468     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
    00469     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00470         << " is caught" << endmsg;
    00471     log << MSG::ERROR << Exception  << endmsg;
    00472   }
    00473   catch( const std::exception& Exception ) {
    00474     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
    00475     log << MSG::FATAL << " Standard std::exception is caught" << endmsg;
    00476     log << MSG::ERROR << Exception.what()  << endmsg;
    00477   }
    00478   catch( ... ) {
    00479     MsgStream log ( msgSvc() , name() + ".sysReinitialize()" );
    00480     log << MSG::FATAL << "UNKNOWN Exception is caught" << endmsg;
    00481   }
    00482   return StatusCode::FAILURE ;
    00483
    00484 }

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

Start AlgTool.

Definition at line 512 of file AlgTool.cpp.

    00512                                {
    00513   //-----------------------------------------------------------------------------
    00514   StatusCode sc;
    00515
    00516   // Check that the current status is the correct one.
    00517   if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
    00518     MsgStream log ( msgSvc() , name() );
    00519     log << MSG::ERROR
    00520         << "sysRestart(): cannot reinitialize tool not started"
    00521         << endmsg;
    00522     return StatusCode::FAILURE;
    00523   }
    00524
    00525   try {
    00526     m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
    00527     Gaudi::Guards::AuditorGuard guard(this,
    00528                                       // check if we want to audit the initialize
    00529                                       (m_auditorRestart) ? auditorSvc() : 0,
    00530                                       IAuditor::ReStart);
    00531     sc = restart();
    00532     return sc;
    00533   }
    00534   catch( const GaudiException& Exception ) {
    00535     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
    00536     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00537         << " is caught" << endmsg;
    00538     log << MSG::ERROR << Exception  << endmsg;
    00539   }
    00540   catch( const std::exception& Exception ) {
    00541     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
    00542     log << MSG::FATAL << " Standard std::exception is caught" << endmsg;
    00543     log << MSG::ERROR << Exception.what()  << endmsg;
    00544   }
    00545   catch( ... ) {
    00546     MsgStream log ( msgSvc() , name() + ".sysRestart()" );
    00547     log << MSG::FATAL << "UNKNOWN Exception is caught" << endmsg;
    00548   }
    00549   return StatusCode::FAILURE ;
    00550
    00551 }

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

Default implementations for IProperty interface.

Definition at line 104 of file AlgTool.cpp.

    00106 {
    00107   return m_propertyMgr->setProperty(p);
    00108 }

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

Definition at line 111 of file AlgTool.cpp.

    00113 {
    00114   return m_propertyMgr->setProperty(s);
    00115 }

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

Definition at line 118 of file AlgTool.cpp.

    00120 {
    00121   return m_propertyMgr->setProperty(n,v);
    00122 }

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

Definition at line 125 of file AlgTool.cpp.

    00127 {
    00128   return m_propertyMgr->getProperty(p);
    00129 }

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

Definition at line 132 of file AlgTool.cpp.

    00133 {
    00134   return m_propertyMgr->getProperty(n);
    00135 }

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

Definition at line 138 of file AlgTool.cpp.

    00140 {
    00141   return m_propertyMgr->getProperty(n,v);
    00142 }

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

Definition at line 145 of file AlgTool.cpp.

    00147 {
    00148   return m_propertyMgr->getProperties();
    00149 }

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

Definition at line 90 of file AlgTool.h.

    00090 { 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 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 136 of file AlgTool.h.

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

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

Retrieve pointer to service locator.

Definition at line 77 of file AlgTool.cpp.

    00079 {
    00080   return m_svcLocator;
    00081 }

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

shortcut for the method service locator

Definition at line 154 of file AlgTool.h.

    00154 { return serviceLocator() ; }

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

Retrieve pointer to message service.

Definition at line 84 of file AlgTool.cpp.

    00086 {
    00087   return m_messageSvc;
    00088 }

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

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

Definition at line 91 of file AlgTool.cpp.

    00093 {
    00094   if ( 0 == m_ptoolSvc ) {
    00095     StatusCode sc = service( "ToolSvc", m_ptoolSvc, true );
    00096     if( sc.isFailure() ) {
    00097       throw GaudiException("Service [ToolSvc] not found", name(), sc);
    00098     }
    00099   }
    00100   return m_ptoolSvc;
    00101 }

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 152 of file AlgTool.cpp.

    00154 {
    00155   if( m_svcLocator == 0) {
    00156     return StatusCode::FAILURE;
    00157   }
    00158   SmartIF<IJobOptionsSvc> jos(m_svcLocator->service("JobOptionsSvc"));
    00159   if( !jos.isValid() )  return StatusCode::FAILURE;
    00160
    00161   // set first generic Properties
    00162   StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
    00163   if( sc.isFailure() ) return StatusCode::FAILURE;
    00164
    00165   // set specific Properties
    00166   if (isGaudiThreaded(name())) {
    00167     if(jos->setMyProperties( name(), this ).isFailure()) {
    00168       return StatusCode::FAILURE;
    00169     }
    00170   }
    00171
    00172   // Change my own outputlevel
    00173   if ( 0 != m_messageSvc )
    00174   {
    00175     if ( MSG::NIL != m_outputLevel )
    00176     { m_messageSvc -> setOutputLevel ( name () , m_outputLevel ) ; }
    00177     m_outputLevel = m_messageSvc -> outputLevel ( name () ) ;
    00178   }
    00179
    00180   return StatusCode::SUCCESS;
    00181 }

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 174 of file AlgTool.h.

    00174                                                                  {
    00175     return service_i(name, createIf, T::interfaceID(), (void**)&svc);
    00176   }

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 181 of file AlgTool.h.

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

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

declare interface

Definition at line 48 of file AlgTool.cpp.

    00050 {
    00051   m_interfaceList.push_back(std::make_pair(iid, ii));
    00052 }

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 226 of file AlgTool.h.

    00229   {
    00230     return m_propertyMgr -> declareProperty ( name , property , doc ) ;
    00231   }

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

Declare remote named properties.

Definition at line 234 of file AlgTool.h.

    00237   {
    00238     return m_propertyMgr-> declareRemoteProperty ( name , rsvc , rname ) ;
    00239   }

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

Access the auditor service.

Definition at line 605 of file AlgTool.cpp.

    00605                                        {
    00606 //---------------------------------------------------------------------------
    00607   if ( 0 == m_pAuditorSvc ) {
    00608     StatusCode sc = service( "AuditorSvc", m_pAuditorSvc, true );
    00609     if( sc.isFailure() ) {
    00610       throw GaudiException("Service [AuditorSvc] not found", name(), sc);
    00611     }
    00612   }
    00613   return m_pAuditorSvc;
    00614 }

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 253 of file AlgTool.h.

    00254   {
    00255     // If not already located try to locate it without forcing a creation
    00256     if ( !m_pMonitorSvc ){
    00257       service_i( m_monitorSvcName, false,
    00258                  IMonitorSvc::interfaceID(), pp_cast<void>(&m_pMonitorSvc) ).ignore();
    00259     }
    00260     return m_pMonitorSvc;
    00261   }

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 269 of file AlgTool.h.

    00272   {
    00273     IMonitorSvc* mS = monitorSvc();
    00274     if ( mS ) mS->declareInfo(name, var, desc, this);
    00275   }

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 284 of file AlgTool.h.

    00289   {
    00290     IMonitorSvc* mS = monitorSvc();
    00291     if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
    00292   }

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

get tool's output level

Definition at line 297 of file AlgTool.h.

    00297 { return (int)m_outputLevel ; }

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

Accessor for the Message level property.

Definition at line 300 of file AlgTool.h.

    00300 { return m_outputLevel; }

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

callback for output level property

Definition at line 618 of file AlgTool.cpp.

    00618                                                  {
    00619 //-----------------------------------------------------------------------------
    00620    // do nothing... yet ?
    00621 }

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

implementation of service method

Definition at line 586 of file AlgTool.cpp.

    00589                                        {
    00590   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    00591   return helper.getService(svcName, createIf, iid, ppSvc);
    00592 }

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

Definition at line 596 of file AlgTool.cpp.

    00599                                        {
    00600   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    00601   return  helper.createService(svcType, svcName, iid, ppSvc);
    00602 }

## Friends And Related Function Documentation

friend class ToolSvc`[friend]`

Definition at line 36 of file AlgTool.h.

## Member Data Documentation

IntegerProperty AlgTool::m_outputLevel`[private]`

AlgTool output level.

Definition at line 314 of file AlgTool.h.

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

AlgTool type (concrete class name).

Reimplemented in EqSolver, and FuncMinimum.

Definition at line 315 of file AlgTool.h.

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

AlgTool full name.

Definition at line 316 of file AlgTool.h.

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

AlgTool parent.

Definition at line 317 of file AlgTool.h.

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

Pointer to Service Locator service.

Definition at line 318 of file AlgTool.h.

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

Message service.

Definition at line 319 of file AlgTool.h.

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

Tool service.

Definition at line 320 of file AlgTool.h.

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

Online Monitoring Service.

Definition at line 321 of file AlgTool.h.

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

Name to use for Monitor Service.

Definition at line 322 of file AlgTool.h.

PropertyMgr* AlgTool::m_propertyMgr`[private]`

Property Manager.

Definition at line 323 of file AlgTool.h.

InterfaceList AlgTool::m_interfaceList`[private]`

Interface list.

Definition at line 324 of file AlgTool.h.

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

Thread Id for Alg Tool.

Definition at line 325 of file AlgTool.h.

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

Auditor Service.

Definition at line 337 of file AlgTool.h.

BooleanProperty AlgTool::m_auditInit`[private]`

Definition at line 339 of file AlgTool.h.

bool AlgTool::m_auditorInitialize`[private]`

flag for auditors in "initialize()"

Definition at line 340 of file AlgTool.h.

bool AlgTool::m_auditorStart`[private]`

flag for auditors in "start()"

Definition at line 341 of file AlgTool.h.

bool AlgTool::m_auditorStop`[private]`

flag for auditors in "stop()"

Definition at line 342 of file AlgTool.h.

bool AlgTool::m_auditorFinalize`[private]`

flag for auditors in "finalize()"

Definition at line 343 of file AlgTool.h.

bool AlgTool::m_auditorReinitialize`[private]`

flag for auditors in "reinitialize()"

Definition at line 344 of file AlgTool.h.

bool AlgTool::m_auditorRestart`[private]`

flag for auditors in "restart()"

Definition at line 345 of file AlgTool.h.

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

state of the Tool

Definition at line 347 of file AlgTool.h.

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

state of the Tool

Definition at line 348 of file AlgTool.h.

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

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