| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 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 181 of file AlgTool.cpp.

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

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

Definition at line 571 of file AlgTool.cpp.

    00573 {
    00574   delete m_propertyMgr;
    00575   if( m_ptoolSvc ) m_ptoolSvc->release();
    00576   if( m_pAuditorSvc ) m_pAuditorSvc->release();
    00577   if ( m_pMonitorSvc ) { m_pMonitorSvc->undeclareAll(this); m_pMonitorSvc->release(); }
    00578 }

## 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   // cannot reach this point
    00043 }

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

Retrieve full identifying name of the concrete tool object.

Definition at line 53 of file AlgTool.cpp.

    00055 {
    00056   return m_name;
    00057 }

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

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

Definition at line 60 of file AlgTool.cpp.

    00062 {
    00063   return m_type;
    00064 }

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

Retrieve parent of the sub-algtool.

Definition at line 67 of file AlgTool.cpp.

    00069 {
    00070   return m_parent;
    00071 }

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

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

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

Definition at line 349 of file AlgTool.cpp.

    00351 {
    00352   // For the time being there is nothing to be done here.
    00353   return StatusCode::SUCCESS;
    00354 }

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

Definition at line 392 of file AlgTool.cpp.

    00394 {
    00395   // For the time being there is nothing to be done here.
    00396   return StatusCode::SUCCESS;
    00397 }

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

    00437 {
    00438   // For the time being there is nothing to be done here.
    00439   return StatusCode::SUCCESS;
    00440 }

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

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

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

Definition at line 551 of file AlgTool.cpp.

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

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

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

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

Start AlgTool.

Definition at line 314 of file AlgTool.cpp.

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

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

Stop AlgTool.

Definition at line 357 of file AlgTool.cpp.

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

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

Finalize AlgTool.

Definition at line 400 of file AlgTool.cpp.

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

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

Initialize AlgTool.

Definition at line 443 of file AlgTool.cpp.

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

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

Start AlgTool.

Definition at line 509 of file AlgTool.cpp.

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

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

Default implementations for IProperty interface.

Definition at line 101 of file AlgTool.cpp.

    00103 {
    00104   return m_propertyMgr->setProperty(p);
    00105 }

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

Definition at line 108 of file AlgTool.cpp.

    00110 {
    00111   return m_propertyMgr->setProperty(s);
    00112 }

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

Definition at line 115 of file AlgTool.cpp.

    00117 {
    00118   return m_propertyMgr->setProperty(n,v);
    00119 }

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

Definition at line 122 of file AlgTool.cpp.

    00124 {
    00125   return m_propertyMgr->getProperty(p);
    00126 }

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

Definition at line 129 of file AlgTool.cpp.

    00130 {
    00131   return m_propertyMgr->getProperty(n);
    00132 }

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

Definition at line 135 of file AlgTool.cpp.

    00137 {
    00138   return m_propertyMgr->getProperty(n,v);
    00139 }

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

Definition at line 142 of file AlgTool.cpp.

    00144 {
    00145   return m_propertyMgr->getProperties();
    00146 }

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

    00076 {
    00077   return m_svcLocator;
    00078 }

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

    00083 {
    00084   return m_messageSvc;
    00085 }

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

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

Definition at line 88 of file AlgTool.cpp.

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

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

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

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

    00047 {
    00048   m_interfaceList.push_back(std::make_pair(iid, ii));
    00049 }

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

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

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

    00615                                                  {
    00616 //-----------------------------------------------------------------------------
    00617    // do nothing... yet ?
    00618 }

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

implementation of service method

Definition at line 583 of file AlgTool.cpp.

    00586                                        {
    00587   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    00588   return helper.getService(svcName, createIf, iid, ppSvc);
    00589 }

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

Definition at line 593 of file AlgTool.cpp.

    00596                                        {
    00597   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    00598   return  helper.createService(svcType, svcName, iid, ppSvc);
    00599 }

## 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_v21r9/GaudiKernel/GaudiKernel/AlgTool.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r9/GaudiKernel/src/Lib/AlgTool.cpp