The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Public Member Functions

StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown) override
 Query for a given interface.
 
void const * i_cast (const InterfaceID &riid) const override
 
const std::string & name () const override
 Retrieve full identifying name of the concrete tool object.
 
const std::string & type () const override
 Retrieve type (concrete class) of the sub-algtool.
 
const IInterfaceparent () const override
 Retrieve parent of the sub-algtool.
 
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.
 
StatusCode sysStart () override
 Start AlgTool.
 
StatusCode sysStop () override
 Stop AlgTool.
 
StatusCode sysFinalize () override
 Finalize AlgTool.
 
StatusCode sysReinitialize () override
 Initialize AlgTool.
 
StatusCode sysRestart () override
 Start AlgTool.
 
 AlgTool (std::string type, std::string name, const IInterface *parent)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
ISvcLocatorsvcLoc () const
 shortcut for the method service locator
 
IDataProviderSvcevtSvc () const
 accessor to event service service
 
IToolSvctoolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present.
 
SmartIF< IServiceservice (std::string_view name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name")
 
template<typename T>
SmartIF< T > service (std::string_view 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, const 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 acceptDHVisitor (IDataHandleVisitor *) const override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
const std::vector< IAlgTool * > & tools () const
 
IAuditorSvcauditorSvc () const
 Access the auditor service.
 
IMonitorSvcmonitorSvc () 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)
 
 ~AlgTool () override
 
- Public Member Functions inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > > >
std::vector< Gaudi::DataHandle * > inputHandles () const override
 
std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
void declare (Gaudi::DataHandle &handle) override
 
void renounce (Gaudi::DataHandle &handle) override
 
bool renounceInput (const DataObjID &id) override
 
const DataObjIDCollinputDataObjs () const override
 
const DataObjIDColloutputDataObjs () const override
 
void addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
 
- Public Member Functions inherited from extends< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >, IDataHandleHolder >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 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)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

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 initDataHandleHolder ()
 initializes all handles - called by the sysInitialize method of any descendant of this
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 

Protected Attributes

std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles.
 
- Protected Attributes inherited from DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > > > >
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 

Private Types

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

Private Member Functions

void initToolHandles () const
 

Private Attributes

friend ToolSvc
 
std::string m_type
 AlgTool type (concrete class name)
 
const std::string m_name
 AlgTool full name.
 
const IInterfacem_parent = nullptr
 AlgTool parent.
 
SmartIF< ISvcLocatorm_svcLocator
 Pointer to Service Locator service.
 
SmartIF< IDataProviderSvcm_evtSvc
 Event data service.
 
SmartIF< IToolSvcm_ptoolSvc
 Tool service.
 
SmartIF< IMonitorSvcm_pMonitorSvc
 Online Monitoring Service.
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
 
InterfaceList m_interfaceList
 Interface list.
 
Gaudi::Property< int > m_outputLevel
 
Gaudi::Property< std::string > m_monitorSvcName
 
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
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::CONFIGURED
 flag indicating whether ToolHandle tools have been added to m_tools
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::CONFIGURED
 state of the Tool
 

Friends

class ToolVisitor
 

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

Member Typedef Documentation

◆ Factory

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

Definition at line 60 of file AlgTool.h.

◆ InterfaceList

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

Definition at line 262 of file AlgTool.h.

Constructor & Destructor Documentation

◆ AlgTool()

AlgTool::AlgTool ( std::string type,
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 95 of file AlgTool.cpp.

96 : m_type( std::move( type ) ), m_name( std::move( name ) ), m_parent( parent ) {
97 addRef(); // Initial count set to 1
98
99 IInterface* _p = const_cast<IInterface*>( parent );
100
101 if ( Gaudi::Algorithm* _alg = dynamic_cast<Gaudi::Algorithm*>( _p ) ) {
102 m_svcLocator = _alg->serviceLocator();
103 } else if ( Service* _svc = dynamic_cast<Service*>( _p ) ) {
104 m_svcLocator = _svc->serviceLocator();
105 } else if ( AlgTool* _too = dynamic_cast<AlgTool*>( _p ) ) {
106 m_svcLocator = _too->serviceLocator();
107 } else if ( Gaudi::Auditor* _aud = dynamic_cast<Gaudi::Auditor*>( _p ) ) {
108 m_svcLocator = _aud->serviceLocator();
109 } else {
110 throw GaudiException( "Failure to create tool '" + m_type + "/" + m_name + "': illegal parent type '" +
111 System::typeinfoName( typeid( *_p ) ) + "'",
112 "AlgTool", StatusCode::FAILURE );
113 }
114
115 // inherit output level from parent
116 // get the "OutputLevel" property from parent
117 if ( SmartIF<IProperty> pprop( _p ); pprop && pprop->hasProperty( "OutputLevel" ) ) {
118 m_outputLevel.assign( pprop->getProperty( "OutputLevel" ) );
119 }
120
121 // Auditor monitoring properties
122 // Initialize the default value from ApplicationMgr AuditAlgorithms
123 Gaudi::Property<bool> audit( "AuditTools", false );
124 // note that here we need that the service locator is already defined
125 if ( auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" ) ) {
126 appMgr->getProperty( &audit ).ignore();
127 }
128
129 m_auditorInitialize = audit;
130 m_auditorStart = audit;
131 m_auditorStop = audit;
132 m_auditorFinalize = audit;
133 m_auditorReinitialize = audit;
134 m_auditorRestart = audit;
135}
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition AlgTool.h:268
Gaudi::Property< int > m_outputLevel
Definition AlgTool.h:278
const std::string m_name
AlgTool full name.
Definition AlgTool.h:265
Gaudi::Property< bool > m_auditorInitialize
Definition AlgTool.h:286
const IInterface * parent() const override
Retrieve parent of the sub-algtool.
Definition AlgTool.cpp:76
AlgTool(std::string type, std::string name, const IInterface *parent)
Standard Constructor.
Definition AlgTool.cpp:95
const std::string & type() const override
Retrieve type (concrete class) of the sub-algtool.
Definition AlgTool.cpp:74
const IInterface * m_parent
AlgTool parent.
Definition AlgTool.h:266
SmartIF< IService > service(std::string_view name, const bool createIf=true, const bool quiet=false) const
Return a pointer to the service identified by name (or "type/name")
Definition AlgTool.cpp:355
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition AlgTool.cpp:72
Gaudi::Property< bool > m_auditorStart
Definition AlgTool.h:287
Gaudi::Property< bool > m_auditorStop
Definition AlgTool.h:288
Gaudi::Property< bool > m_auditorReinitialize
Definition AlgTool.h:290
std::string m_type
AlgTool type (concrete class name)
Definition AlgTool.h:264
Gaudi::Property< bool > m_auditorFinalize
Definition AlgTool.h:289
Gaudi::Property< bool > m_auditorRestart
Definition AlgTool.h:291
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition AlgTool.cpp:78
constexpr static const auto FAILURE
Definition StatusCode.h:100
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ ~AlgTool()

AlgTool::~AlgTool ( )
override

Definition at line 298 of file AlgTool.cpp.

298 {
299 if ( m_pMonitorSvc ) { m_pMonitorSvc->undeclareAll( this ); }
300}
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
Definition AlgTool.h:271

Member Function Documentation

◆ acceptDHVisitor()

void AlgTool::acceptDHVisitor ( IDataHandleVisitor * vis) const
override

Definition at line 368 of file AlgTool.cpp.

368 {
369 vis->visit( this );
370
371 for ( auto tool : tools() ) vis->visit( dynamic_cast<AlgTool*>( tool ) );
372}
const std::vector< IAlgTool * > & tools() const
Definition AlgTool.cpp:343
virtual void visit(const IDataHandleHolder *)=0

◆ addToolsArray()

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

Definition at line 180 of file AlgTool.h.

180 {
181 m_toolHandleArrays.push_back( &hndlArr );
182 }
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition AlgTool.h:296

◆ auditorSvc()

IAuditorSvc * AlgTool::auditorSvc ( ) const

Access the auditor service.

Definition at line 360 of file AlgTool.cpp.

360 {
361 if ( !m_pAuditorSvc ) {
362 m_pAuditorSvc = service( "AuditorSvc", true );
363 if ( !m_pAuditorSvc ) { throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE ); }
364 }
365 return m_pAuditorSvc.get();
366}
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition AlgTool.h:272

◆ configure()

StatusCode AlgTool::configure ( )
inlineoverride

Definition at line 76 of file AlgTool.h.

76{ return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ declareInfo() [1/2]

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

253 {
254 IMonitorSvc* mS = monitorSvc();
255 if ( mS ) mS->declareInfo( name, format, var, size, desc, this );
256 }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition MsgStream.cpp:93
IMonitorSvc * monitorSvc() const
Access the monitor service.
Definition AlgTool.h:228
virtual void declareInfo(const std::string &name, const bool &var, const std::string &desc, const IInterface *owner)=0
Declare monitoring information.

◆ declareInfo() [2/2]

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

240 {
241 IMonitorSvc* mS = monitorSvc();
242 if ( mS ) mS->declareInfo( name, var, desc, this );
243 }

◆ declareInterface()

template<typename I>
void AlgTool::declareInterface ( I * i)
inlineprotected

Definition at line 137 of file AlgTool.h.

137 {
138 m_interfaceList.emplace_back( I::interfaceID(), i );
139 }
InterfaceList m_interfaceList
Interface list.
Definition AlgTool.h:274

◆ declareProperty() [1/2]

template<class T>
Gaudi::Details::PropertyBase * AlgTool::declareProperty ( const std::string & name,
ToolHandle< T > & hndl,
const std::string & doc = "none" )
inline

Definition at line 145 of file AlgTool.h.

146 {
147 this->declareTool( hndl, hndl.typeAndName() ).ignore();
148 return PropertyHolderImpl::declareProperty( name, hndl, doc );
149 }
StatusCode declareTool(ToolHandle< T > &handle, bool createIf=true)
Definition AlgTool.h:152
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Details::PropertyBase &prop)
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
std::string typeAndName() const override
Definition ToolHandle.h:273

◆ declareProperty() [2/2]

template<class T>
Gaudi::Details::PropertyBase * AlgTool::declareProperty ( const std::string & name,
ToolHandleArray< T > & hndlArr,
const std::string & doc = "none" )
inline

Definition at line 173 of file AlgTool.h.

174 {
175 addToolsArray( hndlArr );
176 return PropertyHolderImpl::declareProperty( name, hndlArr, doc );
177 }
void addToolsArray(ToolHandleArray< T > &hndlArr)
Definition AlgTool.h:180

◆ declareTool() [1/2]

template<class T>
StatusCode AlgTool::declareTool ( ToolHandle< T > & handle,
bool createIf = true )
inline

Definition at line 152 of file AlgTool.h.

152 {
153 return this->declareTool( handle, handle.typeAndName(), createIf );
154 }

◆ declareTool() [2/2]

template<class T>
StatusCode AlgTool::declareTool ( ToolHandle< T > & handle,
const std::string & toolTypeAndName,
bool createIf = true )
inline

Definition at line 157 of file AlgTool.h.

157 {
158
159 StatusCode sc = handle.initialize( toolTypeAndName, handle.isPublic() ? nullptr : this, createIf );
160 if ( !sc ) {
161 throw GaudiException{ std::string{ "Cannot create handle for " } + ( handle.isPublic() ? "public" : "private" ) +
162 " tool " + toolTypeAndName,
163 name(), sc };
164 }
165
166 m_toolHandles.push_back( &handle );
167
168 return sc;
169 }
std::vector< BaseToolHandle * > m_toolHandles
Definition AlgTool.h:295
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition ToolHandle.h:213
bool isPublic() const noexcept
Definition ToolHandle.h:49

◆ deregisterTool()

void AlgTool::deregisterTool ( IAlgTool * tool) const
inline

Definition at line 193 of file AlgTool.h.

193 {
194 auto it = std::find( m_tools.begin(), m_tools.end(), tool );
195 if ( it != m_tools.end() ) {
196 if ( msgLevel( MSG::DEBUG ) ) debug() << "De-Registering tool " << tool->name() << endmsg;
197 m_tools.erase( it );
198 } else {
199 if ( msgLevel( MSG::DEBUG ) ) debug() << "Could not de-register tool " << tool->name() << endmsg;
200 }
201 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
std::vector< IAlgTool * > m_tools
Definition AlgTool.h:294
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
@ DEBUG
Definition IMessageSvc.h:22

◆ evtSvc()

IDataProviderSvc * AlgTool::evtSvc ( ) const

accessor to event service service

Returns
pointer to detector service

Definition at line 80 of file AlgTool.cpp.

80 {
81 if ( !m_evtSvc ) {
82 m_evtSvc = service( "EventDataSvc", true );
83 if ( !m_evtSvc ) { throw GaudiException( "Service [EventDataSvc] not found", name(), StatusCode::FAILURE ); }
84 }
85 return m_evtSvc.get();
86}
SmartIF< IDataProviderSvc > m_evtSvc
Event data service.
Definition AlgTool.h:269

◆ finalize()

StatusCode AlgTool::finalize ( )
override

Definition at line 225 of file AlgTool.cpp.

225 {
226 // For the time being there is nothing to be done here.
227 return StatusCode::SUCCESS;
228}

◆ FSMState()

Gaudi::StateMachine::State AlgTool::FSMState ( ) const
inlineoverride

Definition at line 84 of file AlgTool.h.

84{ return m_state; }
Gaudi::StateMachine::State m_state
flag indicating whether ToolHandle tools have been added to m_tools
Definition AlgTool.h:299

◆ i_cast()

void const * AlgTool::i_cast ( const InterfaceID & riid) const
override

Definition at line 61 of file AlgTool.cpp.

61 {
62 if ( auto output = base_class::i_cast( riid ) ) { return output; }
63 if ( auto i =
64 std::find_if( std::begin( m_interfaceList ), std::end( m_interfaceList ),
65 [&]( const std::pair<InterfaceID, void*>& item ) { return item.first.versionMatch( riid ); } );
66 i != std::end( m_interfaceList ) ) {
67 return i->second;
68 }
69 return nullptr;
70}
void const * i_cast(const InterfaceID &tid) const override
Implementation of IInterface::i_cast.
Definition extends.h:30

◆ initialize()

StatusCode AlgTool::initialize ( )
override

Definition at line 173 of file AlgTool.cpp.

173 {
174 // For the time being there is nothing to be done here.
175 // Setting the properties is done by the ToolSvc calling setProperties()
176 // explicitly.
177 return StatusCode::SUCCESS;
178}

◆ initToolHandles()

void AlgTool::initToolHandles ( ) const
private

Definition at line 302 of file AlgTool.cpp.

302 {
303 auto init_one = [&]( BaseToolHandle* th ) {
304 if ( !th->isEnabled() ) {
305 if ( msgLevel( MSG::DEBUG ) && !th->typeAndName().empty() )
306 debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
307 return;
308 }
309 if ( !th->get() ) {
310 auto sc = th->retrieve();
311 if ( sc.isFailure() ) {
312 throw GaudiException( "Failed to retrieve tool " + th->typeAndName(), this->name(), StatusCode::FAILURE );
313 }
314 }
315 auto* tool = th->get();
316 if ( msgLevel( MSG::DEBUG ) )
317 debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
318 << tool->type() << ")" << endmsg;
319 m_tools.push_back( tool );
320 };
321
322 for ( auto thArr : m_toolHandleArrays ) {
323 if ( msgLevel( MSG::DEBUG ) )
324 debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
325 // Iterate over its tools:
326 for ( auto toolHandle : thArr->getBaseArray() ) {
327 // Try to cast it into a BaseToolHandle pointer:
328 BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
329 if ( bth ) {
330 init_one( bth );
331 } else {
332 error() << "Error retrieving Tool " << toolHandle->typeAndName() << " in ToolHandleArray "
333 << thArr->propertyName() << ". Not registered" << endmsg;
334 }
335 }
336 }
337
338 for ( BaseToolHandle* th : m_toolHandles ) init_one( th );
339
340 m_toolHandlesInit = true;
341}
bool m_toolHandlesInit
Definition AlgTool.h:297
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)

◆ monitorSvc()

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

228 {
229 // If not already located try to locate it without forcing a creation
230 if ( !m_pMonitorSvc ) m_pMonitorSvc = service( m_monitorSvcName, false, true );
231 return m_pMonitorSvc.get();
232 }
Gaudi::Property< std::string > m_monitorSvcName
Definition AlgTool.h:283

◆ name()

const std::string & AlgTool::name ( ) const
override

Retrieve full identifying name of the concrete tool object.

Definition at line 72 of file AlgTool.cpp.

72{ return m_name; }

◆ parent()

const IInterface * AlgTool::parent ( ) const
override

Retrieve parent of the sub-algtool.

Definition at line 76 of file AlgTool.cpp.

76{ return m_parent; }

◆ queryInterface()

StatusCode AlgTool::queryInterface ( const InterfaceID & riid,
void ** ppvUnknown )
override

Query for a given interface.

Definition at line 46 of file AlgTool.cpp.

46 {
47 if ( !ppvi ) { return StatusCode::FAILURE; }
48 StatusCode sc = base_class::queryInterface( riid, ppvi );
49 if ( sc.isSuccess() ) return sc;
50 auto i = std::find_if( std::begin( m_interfaceList ), std::end( m_interfaceList ),
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;
55 }
56 *ppvi = i->second;
57 addRef();
59}
bool isSuccess() const
Definition StatusCode.h:314
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition extends.h:37

◆ registerTool()

void AlgTool::registerTool ( IAlgTool * tool) const
inline

Definition at line 188 of file AlgTool.h.

188 {
189 if ( msgLevel( MSG::DEBUG ) ) debug() << "Registering tool " << tool->name() << endmsg;
190 m_tools.push_back( tool );
191 }

◆ reinitialize()

StatusCode AlgTool::reinitialize ( )
override

Definition at line 246 of file AlgTool.cpp.

246 {
247 /* @TODO
248 * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
249 * is causing too many problems
250 *
251 // Default implementation is finalize+initialize
252 StatusCode sc = finalize();
253 if (sc.isFailure()) {
254 error() << "reinitialize(): cannot be finalized" << endmsg;
255 return sc;
256 }
257 sc = initialize();
258 if (sc.isFailure()) {
259 error() << "reinitialize(): cannot be initialized" << endmsg;
260 return sc;
261 }
262 */
263 return StatusCode::SUCCESS;
264}

◆ restart()

StatusCode AlgTool::restart ( )
override

Definition at line 283 of file AlgTool.cpp.

283 {
284 // Default implementation is stop+start
285 StatusCode sc = stop();
286 if ( sc.isFailure() ) {
287 error() << "restart(): cannot be stopped" << endmsg;
288 return sc;
289 }
290 sc = start();
291 if ( sc.isFailure() ) {
292 error() << "restart(): cannot be started" << endmsg;
293 return sc;
294 }
295 return StatusCode::SUCCESS;
296}
StatusCode start() override
Definition AlgTool.cpp:192
StatusCode stop() override
Definition AlgTool.cpp:209
bool isFailure() const
Definition StatusCode.h:129

◆ service() [1/2]

SmartIF< IService > AlgTool::service ( std::string_view 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 355 of file AlgTool.cpp.

355 {
356 const ServiceLocatorHelper helper( *serviceLocator(), *this );
357 return helper.service( name, quiet, createIf );
358}

◆ service() [2/2]

template<typename T>
SmartIF< T > AlgTool::service ( std::string_view name,
const bool createIf = true,
const bool quiet = false ) const
inline

Definition at line 131 of file AlgTool.h.

131 {
132 return SmartIF<T>( service( name, createIf, quiet ) );
133 }

◆ serviceLocator()

SmartIF< ISvcLocator > & AlgTool::serviceLocator ( ) const
override

Retrieve pointer to service locator.

Definition at line 78 of file AlgTool.cpp.

78{ return m_svcLocator; }

◆ start()

StatusCode AlgTool::start ( )
override

Definition at line 192 of file AlgTool.cpp.

192 {
193 // For the time being there is nothing to be done here.
194 return StatusCode::SUCCESS;
195}

◆ stop()

StatusCode AlgTool::stop ( )
override

Definition at line 209 of file AlgTool.cpp.

209 {
210 // For the time being there is nothing to be done here.
211 return StatusCode::SUCCESS;
212}

◆ svcLoc()

ISvcLocator * AlgTool::svcLoc ( ) const
inline

shortcut for the method service locator

Definition at line 117 of file AlgTool.h.

117{ return serviceLocator(); }

◆ sysFinalize()

StatusCode AlgTool::sysFinalize ( )
override

Finalize AlgTool.

Definition at line 214 of file AlgTool.cpp.

214 {
215 return attempt( *this, "sysFinalize", [&]() {
217 Gaudi::Guards::AuditorGuard guard( name(),
218 // check if we want to audit the initialize
220 StatusCode sc = finalize();
221 if ( sc.isSuccess() ) m_state = m_targetState;
222 return sc;
223 } );
224}
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition AlgTool.cpp:360
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition AlgTool.h:300
StatusCode finalize() override
Definition AlgTool.cpp:225
static const std::string Finalize
Definition IAuditor.h:53
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...

◆ sysInitialize()

StatusCode AlgTool::sysInitialize ( )
override

Initialize AlgTool.

Definition at line 137 of file AlgTool.cpp.

137 {
138 return attempt( *this, "sysInitialize", [&]() {
140 Gaudi::Guards::AuditorGuard guard( name(),
141 // check if we want to audit the initialize
143 StatusCode sc = initialize();
144 if ( !sc ) return sc;
145
148
149 // check for explicit circular data dependencies in declared handles
151 for ( auto& h : outputHandles() ) {
152 if ( !h->objKey().empty() ) out.emplace( h->fullKey() );
153 }
154 for ( auto& h : inputHandles() ) {
155 if ( !h->objKey().empty() && out.find( h->fullKey() ) != out.end() ) {
156 error() << "Explicit circular data dependency found for id " << h->fullKey() << endmsg;
158 }
159 }
160
161 if ( !sc ) return sc;
162
163 // visit all sub-tools, build full set
164 DHHVisitor avis( m_inputDataObjs, m_outputDataObjs );
165 acceptDHVisitor( &avis );
166
167 // initialize handles
168 initDataHandleHolder(); // this should 'freeze' the handle configuration.
169
170 return sc;
171 } );
172}
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
Definition DataObjID.h:121
std::unique_ptr< IDataHandleVisitor > m_updateDataHandles
Hook for for derived classes to provide a custom visitor for data handles.
Definition AlgTool.h:209
StatusCode initialize() override
Definition AlgTool.cpp:173
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition AlgTool.cpp:368
static const std::string Initialize
Definition IAuditor.h:47

◆ sysReinitialize()

StatusCode AlgTool::sysReinitialize ( )
override

Initialize AlgTool.

Definition at line 230 of file AlgTool.cpp.

230 {
231
232 // Check that the current status is the correct one.
234 error() << "sysReinitialize(): cannot reinitialize tool not initialized" << endmsg;
235 return StatusCode::FAILURE;
236 }
237
238 return attempt( *this, "SysReinitialize()", [&]() {
239 Gaudi::Guards::AuditorGuard guard( name(),
240 // check if we want to audit the initialize
242 return reinitialize();
243 } );
244}
Gaudi::StateMachine::State FSMState() const override
Definition AlgTool.h:84
StatusCode reinitialize() override
Definition AlgTool.cpp:246
static const std::string ReInitialize
Definition IAuditor.h:48

◆ sysRestart()

StatusCode AlgTool::sysRestart ( )
override

Start AlgTool.

Definition at line 266 of file AlgTool.cpp.

266 {
267
268 // Check that the current status is the correct one.
270 error() << "sysRestart(): cannot reinitialize tool not started" << endmsg;
271 return StatusCode::FAILURE;
272 }
273
274 return attempt( *this, "sysRestart", [&]() {
276 Gaudi::Guards::AuditorGuard guard( name(),
277 // check if we want to audit the initialize
279 return restart();
280 } );
281}
StatusCode restart() override
Definition AlgTool.cpp:283
static const std::string ReStart
Definition IAuditor.h:50

◆ sysStart()

StatusCode AlgTool::sysStart ( )
override

Start AlgTool.

Definition at line 180 of file AlgTool.cpp.

180 {
181 return attempt( *this, "sysStart", [&]() {
183 Gaudi::Guards::AuditorGuard guard( name(),
184 // check if we want to audit the initialize
186 StatusCode sc = start();
187 if ( sc.isSuccess() ) m_state = m_targetState;
188 return sc;
189 } );
190}
static const std::string Start
Definition IAuditor.h:49

◆ sysStop()

StatusCode AlgTool::sysStop ( )
override

Stop AlgTool.

Definition at line 197 of file AlgTool.cpp.

197 {
198 return attempt( *this, "sysStop", [&]() {
200 Gaudi::Guards::AuditorGuard guard( name(),
201 // check if we want to audit the initialize
203 StatusCode sc = stop();
204 if ( sc.isSuccess() ) m_state = m_targetState;
205 return sc;
206 } );
207}
static const std::string Stop
Definition IAuditor.h:52

◆ targetFSMState()

Gaudi::StateMachine::State AlgTool::targetFSMState ( ) const
inlineoverride

Definition at line 85 of file AlgTool.h.

85{ return m_targetState; }

◆ terminate()

StatusCode AlgTool::terminate ( )
inlineoverride

Definition at line 81 of file AlgTool.h.

81{ return StatusCode::SUCCESS; }

◆ tools() [1/2]

std::vector< IAlgTool * > & AlgTool::tools ( )
protected

Definition at line 349 of file AlgTool.cpp.

349 {
351
352 return m_tools;
353}
void initToolHandles() const
Definition AlgTool.cpp:302

◆ tools() [2/2]

const std::vector< IAlgTool * > & AlgTool::tools ( ) const

Definition at line 343 of file AlgTool.cpp.

343 {
345
346 return m_tools;
347}

◆ toolSvc()

IToolSvc * AlgTool::toolSvc ( ) const

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

Definition at line 87 of file AlgTool.cpp.

87 {
88 if ( !m_ptoolSvc ) {
89 m_ptoolSvc = service( "ToolSvc", true );
90 if ( !m_ptoolSvc ) { throw GaudiException( "Service [ToolSvc] not found", name(), StatusCode::FAILURE ); }
91 }
92 return m_ptoolSvc.get();
93}
SmartIF< IToolSvc > m_ptoolSvc
Tool service.
Definition AlgTool.h:270

◆ type()

const std::string & AlgTool::type ( ) const
override

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

Definition at line 74 of file AlgTool.cpp.

74{ return m_type; }

Friends And Related Symbol Documentation

◆ ToolVisitor

friend class ToolVisitor
friend

Definition at line 57 of file AlgTool.h.

Member Data Documentation

◆ m_auditorFinalize

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

Definition at line 289 of file AlgTool.h.

289{ this, "AuditFinalize", false, "trigger auditor on finalize()" };

◆ m_auditorInitialize

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

Definition at line 286 of file AlgTool.h.

286{ this, "AuditInitialize", false, "trigger auditor on initialize()" };

◆ m_auditorReinitialize

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

Definition at line 290 of file AlgTool.h.

290{ this, "AuditReinitialize", false, "trigger auditor on reinitialize()" };

◆ m_auditorRestart

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

Definition at line 291 of file AlgTool.h.

291{ this, "AuditRestart", false, "trigger auditor on restart()" };

◆ m_auditorStart

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

Definition at line 287 of file AlgTool.h.

287{ this, "AuditStart", false, "trigger auditor on start()" };

◆ m_auditorStop

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

Definition at line 288 of file AlgTool.h.

288{ this, "AuditStop", false, "trigger auditor on stop()" };

◆ m_evtSvc

SmartIF<IDataProviderSvc> AlgTool::m_evtSvc
mutableprivate

Event data service.

Definition at line 269 of file AlgTool.h.

◆ m_interfaceList

InterfaceList AlgTool::m_interfaceList
private

Interface list.

Definition at line 274 of file AlgTool.h.

◆ m_monitorSvcName

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

Definition at line 283 of file AlgTool.h.

283 { this, "MonitorService", "MonitorSvc",
284 "name to use for Monitor Service" };

◆ m_name

const std::string AlgTool::m_name
private

AlgTool full name.

Definition at line 265 of file AlgTool.h.

◆ m_outputLevel

Gaudi::Property<int> AlgTool::m_outputLevel
private
Initial value:
{
this, "OutputLevel", setUpMessaging(),
"output level" }
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".

Definition at line 278 of file AlgTool.h.

278 {
279 this, "OutputLevel", setUpMessaging(),
280 [this]( Gaudi::Details::PropertyBase& ) { this->updateMsgStreamOutputLevel( this->m_outputLevel ); },
281 "output level" };

◆ m_parent

const IInterface* AlgTool::m_parent = nullptr
private

AlgTool parent.

Definition at line 266 of file AlgTool.h.

◆ m_pAuditorSvc

SmartIF<IAuditorSvc> AlgTool::m_pAuditorSvc
mutableprivate

Auditor Service.

Definition at line 272 of file AlgTool.h.

◆ m_pMonitorSvc

SmartIF<IMonitorSvc> AlgTool::m_pMonitorSvc
mutableprivate

Online Monitoring Service.

Definition at line 271 of file AlgTool.h.

◆ m_ptoolSvc

SmartIF<IToolSvc> AlgTool::m_ptoolSvc
mutableprivate

Tool service.

Definition at line 270 of file AlgTool.h.

◆ m_state

flag indicating whether ToolHandle tools have been added to m_tools

state of the Tool

Definition at line 299 of file AlgTool.h.

◆ m_svcLocator

SmartIF<ISvcLocator> AlgTool::m_svcLocator
mutableprivate

Pointer to Service Locator service.

Definition at line 268 of file AlgTool.h.

◆ m_targetState

state of the Tool

Definition at line 300 of file AlgTool.h.

◆ m_toolHandleArrays

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

Definition at line 296 of file AlgTool.h.

◆ m_toolHandles

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

Definition at line 295 of file AlgTool.h.

◆ m_toolHandlesInit

bool AlgTool::m_toolHandlesInit = false
mutableprivate

Definition at line 297 of file AlgTool.h.

◆ m_tools

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

Definition at line 294 of file AlgTool.h.

◆ m_type

std::string AlgTool::m_type
private

AlgTool type (concrete class name)

Definition at line 264 of file AlgTool.h.

◆ m_updateDataHandles

std::unique_ptr<IDataHandleVisitor> AlgTool::m_updateDataHandles
protected

Hook for for derived classes to provide a custom visitor for data handles.

Definition at line 209 of file AlgTool.h.

◆ ToolSvc

friend AlgTool::ToolSvc
private

Definition at line 56 of file AlgTool.h.


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