The Gaudi Framework  v30r4 (9b837755)
AlgTool Class Reference

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

#include <GaudiKernel/AlgTool.h>

Inheritance diagram for AlgTool:
Collaboration diagram for AlgTool:

Public Types

using Factory = Gaudi::PluginService::Factory< IAlgTool *(const std::string &, const std::string &, const IInterface *)>
 
- Public Types inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown) override
 Query for a given interface. More...
 
const std::stringname () const override
 Retrieve full identifying name of the concrete tool object. More...
 
const std::stringtype () const override
 Retrieve type (concrete class) of the sub-algtool. More...
 
const IInterfaceparent () const override
 Retrieve parent of the sub-algtool. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode sysInitialize () override
 Initialize AlgTool. More...
 
StatusCode sysStart () override
 Start AlgTool. More...
 
StatusCode sysStop () override
 Stop AlgTool. More...
 
StatusCode sysFinalize () override
 Finalize AlgTool. More...
 
StatusCode sysReinitialize () override
 Initialize AlgTool. More...
 
StatusCode sysRestart () override
 Start AlgTool. More...
 
 AlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
ISvcLocatorsvcLoc () const
 shortcut for the method service locator More...
 
IDataProviderSvcevtSvc () const
 accessor to event service service More...
 
SmartIF< IDataProviderSvc > & eventSvc () const final override
 Added for interface compatibility with Algorithm. More...
 
IToolSvctoolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified in the jobOptions via the job option service. More...
 
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. More...
 
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. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name") More...
 
template<typename T >
SmartIF< T > service (const std::string &name, const bool createIf=true, const bool quiet=false) const
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
const std::vector< IAlgTool * > & tools () const
 
IAuditorSvcauditorSvc () const
 Access the auditor service. More...
 
IMonitorSvcmonitorSvc () const
 Access the monitor service. More...
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information. More...
 
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) More...
 
 ~AlgTool () override
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > > >
 DataHandleHolderBase (Args &&...args)
 NOTE: Cannot use "using Super::Super;" due to a GCC 6 bug. More...
 
void registerDataHandle (Gaudi::v2::DataHandle &handle) final override
 Register a data handle of this algorithm/tool. More...
 
void addDataDependency (const DataObjID &key, AccessMode access) final override
 Add a data dependency, even after initialization. More...
 
const DataObjIDColldataDependencies (AccessMode access) const final override
 Tell which whiteboard keys the algorithm will be reading or writing. More...
 
void declare (Gaudi::v1::DataHandle &handle) override
 Declare ownership of a legacy DataHandle. More...
 
void renounce (Gaudi::v1::DataHandle &handle) override
 Discard ownership of a legacy DataHandle. More...
 
const DataObjIDCollallDataDependencies () const final override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Member Functions

template<typename I >
void declareInterface (I *i)
 
std::vector< IAlgTool * > & tools ()
 
- Protected Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > > >
void updateDataDependencies (const DataObjIDMapping &keyMap)
 Update the key of each registered data dependency, using a user-defined mapping from the old to the new key. More...
 
void collectExplicitDataDependencies ()
 Collect all explicit data dependencies in a single place. More...
 
StatusCode handleCircularDataDependencies (CircularDepHandler &&circularDepHandler)
 Look for circular dependencies and let a user-specified handler deal with each of them. More...
 
void collectImplicitDataDependencies (const IDataHandleHolder *child)
 Add the dependencies of another DataHandleHolder to our dependency list. More...
 
const DataObjIDCollignoredDataDependencies (AccessMode access) const
 Tell which data dependencies have been ignored due to an empty key. More...
 
void initializeDataHandleHolder ()
 Initialize the DataHandles. More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

DataObjIDMapping m_updateDependencies
 Hook for for derived classes to alter the DataObjID of dependencies. More...
 

Private Types

typedef std::list< std::pair< InterfaceID, void * > > InterfaceList
 

Private Member Functions

void initToolHandles () const
 
void addUninitializedTool (AlgTool *tool)
 
void propagateUninitializedTools (AlgTool *tool)
 
StatusCode service_i (const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
 implementation of service method More...
 
StatusCode service_i (const std::string &svcType, const std::string &svcName, const InterfaceID &iid, void **ppS) const
 

Private Attributes

std::string m_type
 AlgTool type (concrete class name) More...
 
const std::string m_name
 AlgTool full name. More...
 
const IInterfacem_parent = nullptr
 AlgTool parent. More...
 
SmartIF< ISvcLocatorm_svcLocator
 Pointer to Service Locator service. More...
 
SmartIF< IDataProviderSvcm_evtSvc
 Event data service. More...
 
SmartIF< IToolSvcm_ptoolSvc
 Tool service. More...
 
SmartIF< IMonitorSvcm_pMonitorSvc
 Online Monitoring Service. More...
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 
InterfaceList m_interfaceList
 Interface list. More...
 
Gaudi::Property< int > m_outputLevel
 
Gaudi::Property< std::stringm_monitorSvcName
 
Gaudi::Property< bool > m_auditInit {this, "AuditTools", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
std::vector< IAlgTool * > m_tools
 
std::vector< BaseToolHandle * > m_toolHandles
 
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
 
bool m_toolHandlesInit = false
 
std::unordered_set< AlgTool * > m_uninitializedTools
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
std::unordered_set< AlgTool * > m_toolsAwaitingInit
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::CONFIGURED
 state of the Tool More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::CONFIGURED
 state of the Tool More...
 

Additional Inherited Members

- Protected Types inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > > >
enum  CircularDepAction
 A circular dependency handling action. More...
 
using DataObjIDMapping = std::function< boost::optional< DataObjID >(const DataObjID &)>
 DataObjID mapping function, with optimized identity mapping case. More...
 
using CircularDepHandler = std::function< CircularDepAction(const DataObjID &)>
 A circular dependency handler, which can take any user-specified step (e.g. More...
 

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

Member Typedef Documentation

using AlgTool::Factory = Gaudi::PluginService::Factory<IAlgTool*( const std::string&, const std::string&, const IInterface* )>

Definition at line 52 of file AlgTool.h.

Definition at line 296 of file AlgTool.h.

Constructor & Destructor Documentation

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

Standard Constructor.

Parameters
typethe concrete class of the sub-algtool
namethe full name of the concrete sub-algtool
parentthe parent of the concrete sub-algtool

Definition at line 126 of file AlgTool.cpp.

128  : m_type( type ),
129  m_name( name ),
130  m_parent( parent )
131 {
132  addRef(); // Initial count set to 1
133 
134  IInterface* _p = const_cast<IInterface*>( parent );
135 
136  if ( Algorithm* _alg = dynamic_cast<Algorithm*>( _p ) ) {
137  m_svcLocator = _alg->serviceLocator();
138  } else if ( Service* _svc = dynamic_cast<Service*>( _p ) ) {
139  m_svcLocator = _svc->serviceLocator();
140  } else if ( AlgTool* _too = dynamic_cast<AlgTool*>( _p ) ) {
141  m_svcLocator = _too->serviceLocator();
142  } else if ( Auditor* _aud = dynamic_cast<Auditor*>( _p ) ) {
143  m_svcLocator = _aud->serviceLocator();
144  } else {
145  throw GaudiException( "Failure to create tool '" + type + "/" + name + "': illegal parent type '" +
146  System::typeinfoName( typeid( *_p ) ) + "'",
147  "AlgTool", StatusCode::FAILURE );
148  }
149 
150  // inherit output level from parent
151  { // get the "OutputLevel" property from parent
152  SmartIF<IProperty> pprop( _p );
153  if ( pprop && pprop->hasProperty( "OutputLevel" ) ) {
154  m_outputLevel.assign( pprop->getProperty( "OutputLevel" ) );
155  }
156  }
157 
158  {
159  // Auditor monitoring properties
160  // Initialize the default value from ApplicationMgr AuditAlgorithms
161  Gaudi::Property<bool> audit( false );
162  // note that here we need that the service locator is already defined
163  auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" );
164  if ( appMgr && appMgr->hasProperty( "AuditTools" ) ) {
165  audit.assign( appMgr->getProperty( "AuditTools" ) );
166  }
167  m_auditInit = audit;
168  m_auditorInitialize = audit;
169  m_auditorStart = audit;
170  m_auditorStop = audit;
171  m_auditorFinalize = audit;
172  m_auditorReinitialize = audit;
173  m_auditorRestart = audit;
174  }
175 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: AlgTool.cpp:82
Gaudi::Property< bool > m_auditorStart
Definition: AlgTool.h:321
std::string m_type
AlgTool type (concrete class name)
Definition: AlgTool.h:298
Implementation of property with value of concrete type.
Definition: Property.h:383
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:332
const IInterface * m_parent
AlgTool parent.
Definition: AlgTool.h:300
Gaudi::Property< bool > m_auditorReinitialize
Definition: AlgTool.h:324
const std::string m_name
AlgTool full name.
Definition: AlgTool.h:299
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
Gaudi::Property< int > m_outputLevel
Definition: AlgTool.h:312
Definition of the basic interface.
Definition: IInterface.h:277
Gaudi::Property< bool > m_auditorStop
Definition: AlgTool.h:322
Gaudi::Property< bool > m_auditorRestart
Definition: AlgTool.h:325
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
Gaudi::Property< bool > m_auditInit
Definition: AlgTool.h:319
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:47
const IInterface * parent() const override
Retrieve parent of the sub-algtool.
Definition: AlgTool.cpp:75
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition: AlgTool.h:302
appMgr
Definition: IOTest.py:94
Gaudi::Property< bool > m_auditorInitialize
Definition: AlgTool.h:320
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
Base class for all services.
Definition: Service.h:36
Gaudi::Property< bool > m_auditorFinalize
Definition: AlgTool.h:323
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35
AlgTool::~AlgTool ( )
override

Definition at line 399 of file AlgTool.cpp.

401 {
402  if ( m_pMonitorSvc ) {
403  m_pMonitorSvc->undeclareAll( this );
404  }
405 }
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
Definition: AlgTool.h:305
virtual void undeclareAll(const IInterface *owner)=0
Undeclare monitoring information.

Member Function Documentation

template<class T >
void AlgTool::addToolsArray ( ToolHandleArray< T > &  hndlArr)
inline

Definition at line 204 of file AlgTool.h.

205  {
206  m_toolHandleArrays.push_back( &hndlArr );
207  }
T push_back(T...args)
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition: AlgTool.h:330
void AlgTool::addUninitializedTool ( AlgTool tool)
private

Definition at line 478 of file AlgTool.cpp.

479 {
480  if ( tool == this ) return;
482  tool->m_toolsAwaitingInit.insert( this );
483 }
std::unordered_set< AlgTool * > m_toolsAwaitingInit
Definition: AlgTool.h:335
std::unordered_set< AlgTool * > m_uninitializedTools
flag indicating whether ToolHandle tools have been added to m_tools
Definition: AlgTool.h:334
T insert(T...args)
IAuditorSvc * AlgTool::auditorSvc ( ) const

Access the auditor service.

Definition at line 529 of file AlgTool.cpp.

530 {
531  //---------------------------------------------------------------------------
532  if ( !m_pAuditorSvc ) {
533  m_pAuditorSvc = service( "AuditorSvc", true );
534  if ( !m_pAuditorSvc ) {
535  throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE );
536  }
537  }
538  return m_pAuditorSvc.get();
539 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: AlgTool.h:131
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: AlgTool.h:306
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:61
StatusCode AlgTool::configure ( )
inlineoverride

Definition at line 67 of file AlgTool.h.

67 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
template<class T >
void AlgTool::declareInfo ( const std::string name,
const T &  var,
const std::string desc 
) const
inline

Declare monitoring information.

Parameters
nameMonitoring information name known to the external system
varMonitoring Listener address (the item to monitor...)
descTextual description of the information being monitored

Definition at line 272 of file AlgTool.h.

273  {
274  IMonitorSvc* mS = monitorSvc();
275  if ( mS ) mS->declareInfo( name, var, desc, this );
276  }
IMonitorSvc * monitorSvc() const
Access the monitor service.
Definition: AlgTool.h:259
Definition of the IMonitorSvc interface, which publishes Gaudi variables to outside monitoring proces...
Definition: IMonitorSvc.h:24
virtual void declareInfo(const std::string &name, const bool &var, const std::string &desc, const IInterface *owner)=0
Declare monitoring information.
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
nameMonitoring information name known to the external system
formatFormat information
varMonitoring Listener address
sizeMonitoring Listener address size
descTextual description of the information being monitored

Definition at line 285 of file AlgTool.h.

287  {
288  IMonitorSvc* mS = monitorSvc();
289  if ( mS ) mS->declareInfo( name, format, var, size, desc, this );
290  }
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
IMonitorSvc * monitorSvc() const
Access the monitor service.
Definition: AlgTool.h:259
Definition of the IMonitorSvc interface, which publishes Gaudi variables to outside monitoring proces...
Definition: IMonitorSvc.h:24
virtual void declareInfo(const std::string &name, const bool &var, const std::string &desc, const IInterface *owner)=0
Declare monitoring information.
template<typename I >
void AlgTool::declareInterface ( I *  i)
inlineprotected

Definition at line 155 of file AlgTool.h.

156  {
157  m_interfaceList.emplace_back( I::interfaceID(), i );
158  }
InterfaceList m_interfaceList
Interface list.
Definition: AlgTool.h:308
T emplace_back(T...args)
template<class T >
Gaudi::Details::PropertyBase* AlgTool::declareProperty ( const std::string name,
ToolHandle< T > &  hndl,
const std::string doc = "none" 
)
inline

Definition at line 164 of file AlgTool.h.

166  {
167  this->declareTool( hndl, hndl.typeAndName() ).ignore();
168  return PropertyHolderImpl::declareProperty( name, hndl, doc );
169  }
StatusCode declareTool(ToolHandle< T > &handle, bool createIf=true)
Definition: AlgTool.h:172
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
std::string typeAndName() const override
Definition: ToolHandle.h:281
template<class T >
Gaudi::Details::PropertyBase* AlgTool::declareProperty ( const std::string name,
ToolHandleArray< T > &  hndlArr,
const std::string doc = "none" 
)
inline

Definition at line 196 of file AlgTool.h.

198  {
199  addToolsArray( hndlArr );
200  return PropertyHolderImpl::declareProperty( name, hndlArr, doc );
201  }
void addToolsArray(ToolHandleArray< T > &hndlArr)
Definition: AlgTool.h:204
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
Declare a property.
template<class T >
StatusCode AlgTool::declareTool ( ToolHandle< T > &  handle,
bool  createIf = true 
)
inline

Definition at line 172 of file AlgTool.h.

173  {
174  return this->declareTool( handle, handle.typeAndName(), createIf );
175  }
StatusCode declareTool(ToolHandle< T > &handle, bool createIf=true)
Definition: AlgTool.h:172
std::string typeAndName() const override
Definition: ToolHandle.h:281
template<class T >
StatusCode AlgTool::declareTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName,
bool  createIf = true 
)
inline

Definition at line 178 of file AlgTool.h.

179  {
180 
181  StatusCode sc = handle.initialize( toolTypeAndName, handle.isPublic() ? nullptr : this, createIf );
182  if ( UNLIKELY( !sc ) ) {
183  throw GaudiException{std::string{"Cannot create handle for "} + ( handle.isPublic() ? "public" : "private" ) +
184  " tool " + toolTypeAndName,
185  name(), sc};
186  }
187 
188  m_toolHandles.push_back( &handle );
189 
190  return sc;
191  }
#define UNLIKELY(x)
Definition: Kernel.h:89
Define general base for Gaudi exception.
bool isPublic() const noexcept
Definition: ToolHandle.h:41
STL class.
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:214
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:61
std::vector< BaseToolHandle * > m_toolHandles
Definition: AlgTool.h:329
void AlgTool::deregisterTool ( IAlgTool tool) const
inline

Definition at line 216 of file AlgTool.h.

217  {
218  auto it = std::find( m_tools.begin(), m_tools.end(), tool );
219  if ( it != m_tools.end() ) {
220  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "De-Registering tool " << tool->name() << endmsg;
221  m_tools.erase( it );
222  } else {
223  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "Could not de-register tool " << tool->name() << endmsg;
224  }
225  }
#define UNLIKELY(x)
Definition: Kernel.h:89
T end(T...args)
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:328
T erase(T...args)
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T begin(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
SmartIF< IDataProviderSvc > & AlgTool::eventSvc ( ) const
finaloverride

Added for interface compatibility with Algorithm.

Definition at line 91 of file AlgTool.cpp.

92 {
93  if ( !m_evtSvc ) {
94  m_evtSvc = service( "EventDataSvc", true );
95  if ( !m_evtSvc ) {
96  throw GaudiException( "Service [EventDataSvc] not found", name(), StatusCode::FAILURE );
97  }
98  }
99  return m_evtSvc;
100 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: AlgTool.h:131
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:61
SmartIF< IDataProviderSvc > m_evtSvc
Event data service.
Definition: AlgTool.h:303
IDataProviderSvc* AlgTool::evtSvc ( ) const
inline

accessor to event service service

Returns
pointer to detector service

Definition at line 113 of file AlgTool.h.

113 { return eventSvc().get(); }
SmartIF< IDataProviderSvc > & eventSvc() const final override
Added for interface compatibility with Algorithm.
Definition: AlgTool.cpp:91
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
StatusCode AlgTool::finalize ( )
override

Definition at line 311 of file AlgTool.cpp.

313 {
314  // For the time being there is nothing to be done here.
315  return StatusCode::SUCCESS;
316 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Gaudi::StateMachine::State AlgTool::FSMState ( ) const
inlineoverride

Definition at line 75 of file AlgTool.h.

75 { return m_state; }
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:342
StatusCode AlgTool::initialize ( )
override

Definition at line 241 of file AlgTool.cpp.

243 {
244  // For the time being there is nothing to be done here.
245  // Setting the properties is done by the ToolSvc calling setProperties()
246  // explicitly.
247  return StatusCode::SUCCESS;
248 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
void AlgTool::initToolHandles ( ) const
private

Definition at line 407 of file AlgTool.cpp.

408 {
409 
410  IAlgTool* tool = nullptr;
411  for ( auto thArr : m_toolHandleArrays ) {
412  if ( !thArr->retrieved() ) {
413  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
414  debug() << "ToolHandleArray " << thArr->propertyName() << " not used: not registering any of its Tools"
415  << endmsg;
416  } else {
417  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
418  debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
419  // Iterate over its tools:
420  for ( auto toolHandle : thArr->getBaseArray() ) {
421  // Try to cast it into a BaseToolHandle pointer:
422  BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
423  if ( bth ) {
424  // If the cast was successful, the code is pretty simple:
425  tool = bth->get();
426  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
427  debug() << "Adding " << ( bth->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name()
428  << " (" << tool->type() << ") from ToolHandleArray " << thArr->propertyName() << endmsg;
429  }
430  m_tools.push_back( tool );
431  } else {
432  // If it wasn't for some strange reason, then fall back on the
433  // logic implemented previously:
434  if ( toolSvc()->retrieveTool( toolHandle->typeAndName(), tool, this, false ).isSuccess() ) {
435  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
436  debug() << "Adding private"
437  << " ToolHandle tool " << tool->name() << " (" << tool->type() << ") from ToolHandleArray "
438  << thArr->propertyName() << endmsg;
439  }
440  m_tools.push_back( tool );
441  } else if ( toolSvc()->retrieveTool( toolHandle->typeAndName(), tool, 0, false ).isSuccess() ) {
442  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) {
443  debug() << "Adding public"
444  << " ToolHandle tool " << tool->name() << " (" << tool->type() << ") from ToolHandleArray "
445  << thArr->propertyName() << endmsg;
446  }
447  m_tools.push_back( tool );
448  } else {
449  warning() << "Error retrieving Tool " << toolHandle->typeAndName() << " in ToolHandleArray "
450  << thArr->propertyName() << ". Not registered" << endmsg;
451  }
452  }
453  }
454  }
455  }
456 
457  for ( auto th : m_toolHandles ) {
458  if ( !th->isEnabled() ) {
459  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) && !th->typeAndName().empty() )
460  debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
461  continue;
462  }
463  if ( !th->get() ) {
464  auto sc = th->retrieve();
465  if ( UNLIKELY( sc.isFailure() ) ) {
466  throw GaudiException( "Failed to retrieve tool " + th->typeAndName(), this->name(), StatusCode::FAILURE );
467  }
468  }
469  tool = th->get();
470  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
471  debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
472  << tool->type() << ")" << endmsg;
473  m_tools.push_back( tool );
474  }
475  m_toolHandlesInit = true;
476 }
#define UNLIKELY(x)
Definition: Kernel.h:89
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
bool m_toolHandlesInit
Definition: AlgTool.h:331
virtual const std::string & type() const =0
The type of an AlgTool, meaning the concrete AlgTool class.
bool isPublic() const noexcept
Definition: ToolHandle.h:41
IToolSvc * toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: AlgTool.cpp:102
Non-templated base class for actual ToolHandle<T>.
Definition: ToolHandle.h:71
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:328
T push_back(T...args)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:61
std::vector< BaseToolHandle * > m_toolHandles
Definition: AlgTool.h:329
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
const IAlgTool * get() const
Definition: ToolHandle.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition: AlgTool.h:330
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
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
NULLNo monitor service is present
non-NULLA monitor service is present and available to be used

Definition at line 259 of file AlgTool.h.

260  {
261  // If not already located try to locate it without forcing a creation
262  if ( !m_pMonitorSvc ) m_pMonitorSvc = service( m_monitorSvcName, false, true );
263  return m_pMonitorSvc.get();
264  }
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
Definition: AlgTool.h:305
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: AlgTool.h:131
Gaudi::Property< std::string > m_monitorSvcName
Definition: AlgTool.h:316
const std::string & AlgTool::name ( ) const
override

Retrieve full identifying name of the concrete tool object.

Definition at line 61 of file AlgTool.cpp.

63 {
64  return m_name;
65 }
const std::string m_name
AlgTool full name.
Definition: AlgTool.h:299
const IInterface * AlgTool::parent ( ) const
override

Retrieve parent of the sub-algtool.

Definition at line 75 of file AlgTool.cpp.

77 {
78  return m_parent;
79 }
const IInterface * m_parent
AlgTool parent.
Definition: AlgTool.h:300
void AlgTool::propagateUninitializedTools ( AlgTool tool)
private

Definition at line 485 of file AlgTool.cpp.

486 {
487  for ( auto uninitializedTool : tool->m_uninitializedTools ) {
488  addUninitializedTool( uninitializedTool );
489  }
490 }
std::unordered_set< AlgTool * > m_uninitializedTools
flag indicating whether ToolHandle tools have been added to m_tools
Definition: AlgTool.h:334
void addUninitializedTool(AlgTool *tool)
Definition: AlgTool.cpp:478
StatusCode AlgTool::queryInterface ( const InterfaceID riid,
void **  ppvUnknown 
)
override

Query for a given interface.

Definition at line 42 of file AlgTool.cpp.

44 {
45  if ( !ppvi ) {
46  return StatusCode::FAILURE;
47  } // RETURN
48  StatusCode sc = base_class::queryInterface( riid, ppvi );
49  if ( sc.isSuccess() ) return sc;
51  [&]( const std::pair<InterfaceID, void*>& item ) { return item.first.versionMatch( riid ); } );
52  if ( i == std::end( m_interfaceList ) ) {
53  *ppvi = nullptr;
54  return Status::NO_INTERFACE; // RETURN
55  }
56  *ppvi = i->second;
57  addRef();
58  return StatusCode::SUCCESS; // RETURN
59 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
bool isSuccess() const
Definition: StatusCode.h:287
T end(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T find_if(T...args)
T begin(T...args)
InterfaceList m_interfaceList
Interface list.
Definition: AlgTool.h:308
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
void AlgTool::registerTool ( IAlgTool tool) const
inline

Definition at line 210 of file AlgTool.h.

211  {
212  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "Registering tool " << tool->name() << endmsg;
213  m_tools.push_back( tool );
214  }
#define UNLIKELY(x)
Definition: Kernel.h:89
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:328
T push_back(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode AlgTool::reinitialize ( )
override

Definition at line 338 of file AlgTool.cpp.

340 {
341  /* @TODO
342  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
343  * is causing too many problems
344  *
345  // Default implementation is finalize+initialize
346  StatusCode sc = finalize();
347  if (sc.isFailure()) {
348  error() << "reinitialize(): cannot be finalized" << endmsg;
349  return sc;
350  }
351  sc = initialize();
352  if (sc.isFailure()) {
353  error() << "reinitialize(): cannot be initialized" << endmsg;
354  return sc;
355  }
356  */
357  return StatusCode::SUCCESS;
358 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode AlgTool::restart ( )
override

Definition at line 381 of file AlgTool.cpp.

383 {
384  // Default implementation is stop+start
385  StatusCode sc = stop();
386  if ( sc.isFailure() ) {
387  error() << "restart(): cannot be stopped" << endmsg;
388  return sc;
389  }
390  sc = start();
391  if ( sc.isFailure() ) {
392  error() << "restart(): cannot be started" << endmsg;
393  return sc;
394  }
395  return StatusCode::SUCCESS;
396 }
bool isFailure() const
Definition: StatusCode.h:139
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode stop() override
Definition: AlgTool.cpp:289
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode start() override
Definition: AlgTool.cpp:266
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 131 of file AlgTool.h.

132  {
133  return service_i( name, createIf, T::interfaceID(), (void**)&svc );
134  }
StatusCode service_i(const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: AlgTool.cpp:508
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 139 of file AlgTool.h.

140  {
141  return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &svc ) );
142  }
StatusCode service_i(const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: AlgTool.cpp:508
SmartIF< IService > AlgTool::service ( const std::string name,
const bool  createIf = true,
const bool  quiet = false 
) const

Return a pointer to the service identified by name (or "type/name")

Definition at line 522 of file AlgTool.cpp.

523 {
524  const ServiceLocatorHelper helper( *serviceLocator(), *this );
525  return helper.service( name, quiet, createIf );
526 }
an helper to share the implementation of service() among the various kernel base classes ...
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: AlgTool.cpp:82
template<typename T >
SmartIF<T> AlgTool::service ( const std::string name,
const bool  createIf = true,
const bool  quiet = false 
) const
inline

Definition at line 148 of file AlgTool.h.

149  {
150  return SmartIF<T>( service( name, createIf, quiet ) );
151  }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:15
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: AlgTool.h:131
StatusCode AlgTool::service_i ( const std::string algName,
bool  createIf,
const InterfaceID iid,
void **  ppSvc 
) const
private

implementation of service method

Definition at line 508 of file AlgTool.cpp.

509 {
510  const ServiceLocatorHelper helper( *serviceLocator(), *this );
511  return helper.getService( svcName, createIf, iid, ppSvc );
512 }
an helper to share the implementation of service() among the various kernel base classes ...
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: AlgTool.cpp:82
StatusCode AlgTool::service_i ( const std::string svcType,
const std::string svcName,
const InterfaceID iid,
void **  ppS 
) const
private

Definition at line 515 of file AlgTool.cpp.

517 {
518  const ServiceLocatorHelper helper( *serviceLocator(), *this );
519  return helper.createService( svcType, svcName, iid, ppSvc );
520 }
an helper to share the implementation of service() among the various kernel base classes ...
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: AlgTool.cpp:82
SmartIF< ISvcLocator > & AlgTool::serviceLocator ( ) const
override

Retrieve pointer to service locator.

Definition at line 82 of file AlgTool.cpp.

84 {
85  return m_svcLocator;
86 }
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition: AlgTool.h:302
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 115 of file AlgTool.cpp.

117 {
118  if ( !m_svcLocator ) return StatusCode::FAILURE;
119  auto jos = m_svcLocator->service<IJobOptionsSvc>( "JobOptionsSvc" );
120  if ( !jos ) return StatusCode::FAILURE;
121 
122  return jos->setMyProperties( name(), this );
123 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
Main interface for the JobOptions service.
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:61
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition: AlgTool.h:302
StatusCode AlgTool::start ( )
override

Definition at line 266 of file AlgTool.cpp.

268 {
269  // For the time being there is nothing to be done here.
270  return StatusCode::SUCCESS;
271 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode AlgTool::stop ( )
override

Definition at line 289 of file AlgTool.cpp.

291 {
292  // For the time being there is nothing to be done here.
293  return StatusCode::SUCCESS;
294 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
ISvcLocator* AlgTool::svcLoc ( ) const
inline

shortcut for the method service locator

Definition at line 108 of file AlgTool.h.

108 { return serviceLocator(); }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: AlgTool.cpp:82
StatusCode AlgTool::sysFinalize ( )
override

Finalize AlgTool.

Definition at line 297 of file AlgTool.cpp.

298 {
299  //-----------------------------------------------------------------------------
300  return attempt( *this, "sysFinalize", [&]() {
302  Gaudi::Guards::AuditorGuard guard( this,
303  // check if we want to audit the initialize
305  StatusCode sc = finalize();
306  if ( sc.isSuccess() ) m_state = m_targetState;
307  return sc;
308  } );
309 }
bool isSuccess() const
Definition: StatusCode.h:287
StatusCode finalize() override
Definition: AlgTool.cpp:311
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:342
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:343
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:529
Gaudi::Property< bool > m_auditorFinalize
Definition: AlgTool.h:323
StatusCode AlgTool::sysInitialize ( )
override

Initialize AlgTool.

Definition at line 178 of file AlgTool.cpp.

179 {
180  //-----------------------------------------------------------------------------
181  return attempt( *this, "sysInitialize", [&]() {
183  Gaudi::Guards::AuditorGuard guard( this,
184  // check if we want to audit the initialize
186  StatusCode sc = initialize();
187  if ( !sc ) return sc;
188 
190 
191  // Perfor any scheduled dependency update
193 
194  // Collect all explicit dependencies in a single place
196 
197  // Check for explicit circular data dependencies
198  sc = handleCircularDataDependencies( [this]( const DataObjID& key ) -> CircularDepAction {
199  error() << "Explicit circular data dependency detected for id " << key << endmsg;
200  return CircularDepAction::Abort;
201  } );
202  if ( !sc ) return sc;
203 
204  // Add tool dependencies to our dependency list
205  for ( auto i_tool : tools() ) {
206  auto tool = dynamic_cast<AlgTool*>( i_tool );
207 
208  // Here, there is an edge case to be handled concerning circular
209  // dependencies between tools: in the presence of a circular dependency,
210  // one tool will observe the other in an uninitialized state, before its
211  // data dependencies are ready and finalized.
212  //
213  // To handle this, we need to setup a notification mechanism so that this
214  // tool may complete our dependency list once it is initialized. And we
215  // also need to propagate this information and notification to any tool
216  // depending on us which will be initialized in meantime.
217  //
218  if ( tool->FSMState() >= Gaudi::StateMachine::INITIALIZED ) {
221  } else {
222  addUninitializedTool( tool );
223  }
224  }
225 
226  // Initialize the inner DataHandles
227  initializeDataHandleHolder(); // this should 'freeze' the handle configuration.
228 
229  // Notify all tools waiting for us to be initialized
230  for ( auto tool : m_toolsAwaitingInit ) {
231  tool->collectImplicitDataDependencies( this );
232  tool->propagateUninitializedTools( this );
233  tool->m_uninitializedTools.erase( this );
234  }
235  m_toolsAwaitingInit.clear();
236 
237  return sc;
238  } );
239 }
std::unordered_set< AlgTool * > m_toolsAwaitingInit
Definition: AlgTool.h:335
StatusCode initialize() override
Definition: AlgTool.cpp:241
void updateDataDependencies(const DataObjIDMapping &keyMap)
Update the key of each registered data dependency, using a user-defined mapping from the old to the n...
DataObjIDMapping m_updateDependencies
Hook for for derived classes to alter the DataObjID of dependencies.
Definition: AlgTool.h:233
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
void collectImplicitDataDependencies(const IDataHandleHolder *child)
Add the dependencies of another DataHandleHolder to our dependency list.
const std::vector< IAlgTool * > & tools() const
Definition: AlgTool.cpp:492
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:342
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
void addUninitializedTool(AlgTool *tool)
Definition: AlgTool.cpp:478
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:47
void propagateUninitializedTools(AlgTool *tool)
Definition: AlgTool.cpp:485
Gaudi::Property< bool > m_auditorInitialize
Definition: AlgTool.h:320
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:343
StatusCode handleCircularDataDependencies(CircularDepHandler &&circularDepHandler)
Look for circular dependencies and let a user-specified handler deal with each of them...
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:529
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode AlgTool::sysReinitialize ( )
override

Initialize AlgTool.

Definition at line 319 of file AlgTool.cpp.

320 {
321  //-----------------------------------------------------------------------------
322 
323  // Check that the current status is the correct one.
325  error() << "sysReinitialize(): cannot reinitialize tool not initialized" << endmsg;
326  return StatusCode::FAILURE;
327  }
328 
329  return attempt( *this, "SysReinitialize()", [&]() {
330  Gaudi::Guards::AuditorGuard guard( this,
331  // check if we want to audit the initialize
333  return reinitialize();
334  } );
335 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Gaudi::Property< bool > m_auditorReinitialize
Definition: AlgTool.h:324
Gaudi::StateMachine::State FSMState() const override
Definition: AlgTool.h:75
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode reinitialize() override
Definition: AlgTool.cpp:338
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:529
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode AlgTool::sysRestart ( )
override

Start AlgTool.

Definition at line 361 of file AlgTool.cpp.

362 {
363  //-----------------------------------------------------------------------------
364 
365  // Check that the current status is the correct one.
367  error() << "sysRestart(): cannot reinitialize tool not started" << endmsg;
368  return StatusCode::FAILURE;
369  }
370 
371  return attempt( *this, "sysRestart", [&]() {
373  Gaudi::Guards::AuditorGuard guard( this,
374  // check if we want to audit the initialize
376  return restart();
377  } );
378 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Gaudi::StateMachine::State FSMState() const override
Definition: AlgTool.h:75
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode restart() override
Definition: AlgTool.cpp:381
Gaudi::Property< bool > m_auditorRestart
Definition: AlgTool.h:325
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:342
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:343
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:529
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode AlgTool::sysStart ( )
override

Start AlgTool.

Definition at line 251 of file AlgTool.cpp.

252 {
253  //-----------------------------------------------------------------------------
254  return attempt( *this, "sysStart", [&]() {
256  Gaudi::Guards::AuditorGuard guard( this,
257  // check if we want to audit the initialize
258  m_auditorStart ? auditorSvc() : nullptr, IAuditor::Start );
259  StatusCode sc = start();
260  if ( sc.isSuccess() ) m_state = m_targetState;
261  return sc;
262  } );
263 }
Gaudi::Property< bool > m_auditorStart
Definition: AlgTool.h:321
bool isSuccess() const
Definition: StatusCode.h:287
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:342
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:343
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:529
StatusCode start() override
Definition: AlgTool.cpp:266
StatusCode AlgTool::sysStop ( )
override

Stop AlgTool.

Definition at line 274 of file AlgTool.cpp.

275 {
276  //-----------------------------------------------------------------------------
277  return attempt( *this, "sysStop", [&]() {
279  Gaudi::Guards::AuditorGuard guard( this,
280  // check if we want to audit the initialize
281  m_auditorStop ? auditorSvc() : nullptr, IAuditor::Stop );
282  StatusCode sc = stop();
283  if ( sc.isSuccess() ) m_state = m_targetState;
284  return sc;
285  } );
286 }
bool isSuccess() const
Definition: StatusCode.h:287
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Gaudi::Property< bool > m_auditorStop
Definition: AlgTool.h:322
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:342
State GAUDI_API ChangeState(const Transition transition, const State state)
Function to get the new state according to the required transition, checking if the transition is all...
StatusCode stop() override
Definition: AlgTool.cpp:289
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:343
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:215
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:529
Gaudi::StateMachine::State AlgTool::targetFSMState ( ) const
inlineoverride

Definition at line 76 of file AlgTool.h.

76 { return m_targetState; }
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:343
StatusCode AlgTool::terminate ( )
inlineoverride

Definition at line 72 of file AlgTool.h.

72 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
const std::vector< IAlgTool * > & AlgTool::tools ( ) const

Definition at line 492 of file AlgTool.cpp.

493 {
495 
496  return m_tools;
497 }
#define UNLIKELY(x)
Definition: Kernel.h:89
bool m_toolHandlesInit
Definition: AlgTool.h:331
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:328
void initToolHandles() const
Definition: AlgTool.cpp:407
std::vector< IAlgTool * > & AlgTool::tools ( )
protected

Definition at line 499 of file AlgTool.cpp.

500 {
502 
503  return m_tools;
504 }
#define UNLIKELY(x)
Definition: Kernel.h:89
bool m_toolHandlesInit
Definition: AlgTool.h:331
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:328
void initToolHandles() const
Definition: AlgTool.cpp:407
IToolSvc * AlgTool::toolSvc ( ) const

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

Definition at line 102 of file AlgTool.cpp.

104 {
105  if ( !m_ptoolSvc ) {
106  m_ptoolSvc = service( "ToolSvc", true );
107  if ( !m_ptoolSvc ) {
108  throw GaudiException( "Service [ToolSvc] not found", name(), StatusCode::FAILURE );
109  }
110  }
111  return m_ptoolSvc.get();
112 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Define general base for Gaudi exception.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
StatusCode service(const std::string &name, T *&svc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: AlgTool.h:131
SmartIF< IToolSvc > m_ptoolSvc
Tool service.
Definition: AlgTool.h:304
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:61
const std::string & AlgTool::type ( ) const
override

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

Definition at line 68 of file AlgTool.cpp.

70 {
71  return m_type;
72 }
std::string m_type
AlgTool type (concrete class name)
Definition: AlgTool.h:298

Member Data Documentation

Gaudi::Property<bool> AlgTool::m_auditInit {this, "AuditTools", false, "[[deprecated]] unused"}
private

Definition at line 319 of file AlgTool.h.

Gaudi::Property<bool> AlgTool::m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
private

Definition at line 323 of file AlgTool.h.

Gaudi::Property<bool> AlgTool::m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
private

Definition at line 320 of file AlgTool.h.

Gaudi::Property<bool> AlgTool::m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
private

Definition at line 324 of file AlgTool.h.

Gaudi::Property<bool> AlgTool::m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
private

Definition at line 325 of file AlgTool.h.

Gaudi::Property<bool> AlgTool::m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
private

Definition at line 321 of file AlgTool.h.

Gaudi::Property<bool> AlgTool::m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
private

Definition at line 322 of file AlgTool.h.

SmartIF<IDataProviderSvc> AlgTool::m_evtSvc
mutableprivate

Event data service.

Definition at line 303 of file AlgTool.h.

InterfaceList AlgTool::m_interfaceList
private

Interface list.

Definition at line 308 of file AlgTool.h.

Gaudi::Property<std::string> AlgTool::m_monitorSvcName
private
Initial value:
{this, "MonitorService", "MonitorSvc",
"name to use for Monitor Service"}

Definition at line 316 of file AlgTool.h.

const std::string AlgTool::m_name
private

AlgTool full name.

Definition at line 299 of file AlgTool.h.

Gaudi::Property<int> AlgTool::m_outputLevel
private
Initial value:
{this, "OutputLevel", setUpMessaging(),
[this]( auto& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
"output level"}

Definition at line 312 of file AlgTool.h.

const IInterface* AlgTool::m_parent = nullptr
private

AlgTool parent.

Definition at line 300 of file AlgTool.h.

SmartIF<IAuditorSvc> AlgTool::m_pAuditorSvc
mutableprivate

Auditor Service.

Definition at line 306 of file AlgTool.h.

SmartIF<IMonitorSvc> AlgTool::m_pMonitorSvc
mutableprivate

Online Monitoring Service.

Definition at line 305 of file AlgTool.h.

SmartIF<IToolSvc> AlgTool::m_ptoolSvc
mutableprivate

Tool service.

Definition at line 304 of file AlgTool.h.

state of the Tool

Definition at line 342 of file AlgTool.h.

SmartIF<ISvcLocator> AlgTool::m_svcLocator
mutableprivate

Pointer to Service Locator service.

Definition at line 302 of file AlgTool.h.

state of the Tool

Definition at line 343 of file AlgTool.h.

std::vector<GaudiHandleArrayBase*> AlgTool::m_toolHandleArrays
mutableprivate

Definition at line 330 of file AlgTool.h.

std::vector<BaseToolHandle*> AlgTool::m_toolHandles
mutableprivate

Definition at line 329 of file AlgTool.h.

bool AlgTool::m_toolHandlesInit = false
mutableprivate

Definition at line 331 of file AlgTool.h.

std::vector<IAlgTool*> AlgTool::m_tools
mutableprivate

Definition at line 328 of file AlgTool.h.

std::unordered_set<AlgTool*> AlgTool::m_toolsAwaitingInit
private

Definition at line 335 of file AlgTool.h.

std::string AlgTool::m_type
private

AlgTool type (concrete class name)

Definition at line 298 of file AlgTool.h.

std::unordered_set<AlgTool*> AlgTool::m_uninitializedTools
private

flag indicating whether ToolHandle tools have been added to m_tools

Definition at line 334 of file AlgTool.h.

DataObjIDMapping AlgTool::m_updateDependencies
protected

Hook for for derived classes to alter the DataObjID of dependencies.

Definition at line 233 of file AlgTool.h.


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