The Gaudi Framework  master (b9786168)
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

void const * i_cast (const InterfaceID &riid) const override
 Query for a given interface.
 
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 261 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 80 of file AlgTool.cpp.

81 : m_type( std::move( type ) ), m_name( std::move( name ) ), m_parent( parent ) {
82 addRef(); // Initial count set to 1
83
84 IInterface* _p = const_cast<IInterface*>( parent );
85
86 if ( Gaudi::Algorithm* _alg = dynamic_cast<Gaudi::Algorithm*>( _p ) ) {
87 m_svcLocator = _alg->serviceLocator();
88 } else if ( Service* _svc = dynamic_cast<Service*>( _p ) ) {
89 m_svcLocator = _svc->serviceLocator();
90 } else if ( AlgTool* _too = dynamic_cast<AlgTool*>( _p ) ) {
91 m_svcLocator = _too->serviceLocator();
92 } else if ( Gaudi::Auditor* _aud = dynamic_cast<Gaudi::Auditor*>( _p ) ) {
93 m_svcLocator = _aud->serviceLocator();
94 } else {
95 throw GaudiException( "Failure to create tool '" + m_type + "/" + m_name + "': illegal parent type '" +
96 System::typeinfoName( typeid( *_p ) ) + "'",
97 "AlgTool", StatusCode::FAILURE );
98 }
99
100 // inherit output level from parent
101 // get the "OutputLevel" property from parent
102 if ( SmartIF<IProperty> pprop( _p ); pprop && pprop->hasProperty( "OutputLevel" ) ) {
103 m_outputLevel.assign( pprop->getProperty( "OutputLevel" ) );
104 }
105
106 // Auditor monitoring properties
107 // Initialize the default value from ApplicationMgr AuditAlgorithms
108 Gaudi::Property<bool> audit( "AuditTools", false );
109 // note that here we need that the service locator is already defined
110 if ( auto appMgr = serviceLocator()->service<IProperty>( "ApplicationMgr" ) ) {
111 appMgr->getProperty( &audit ).ignore();
112 }
113
114 m_auditorInitialize = audit;
115 m_auditorStart = audit;
116 m_auditorStop = audit;
117 m_auditorFinalize = audit;
118 m_auditorReinitialize = audit;
119 m_auditorRestart = audit;
120}
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition AlgTool.h:267
Gaudi::Property< int > m_outputLevel
Definition AlgTool.h:277
const std::string m_name
AlgTool full name.
Definition AlgTool.h:264
Gaudi::Property< bool > m_auditorInitialize
Definition AlgTool.h:285
const IInterface * parent() const override
Retrieve parent of the sub-algtool.
Definition AlgTool.cpp:61
AlgTool(std::string type, std::string name, const IInterface *parent)
Standard Constructor.
Definition AlgTool.cpp:80
const std::string & type() const override
Retrieve type (concrete class) of the sub-algtool.
Definition AlgTool.cpp:59
const IInterface * m_parent
AlgTool parent.
Definition AlgTool.h:265
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:340
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition AlgTool.cpp:57
Gaudi::Property< bool > m_auditorStart
Definition AlgTool.h:286
Gaudi::Property< bool > m_auditorStop
Definition AlgTool.h:287
Gaudi::Property< bool > m_auditorReinitialize
Definition AlgTool.h:289
std::string m_type
AlgTool type (concrete class name)
Definition AlgTool.h:263
Gaudi::Property< bool > m_auditorFinalize
Definition AlgTool.h:288
Gaudi::Property< bool > m_auditorRestart
Definition AlgTool.h:290
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition AlgTool.cpp:63
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 283 of file AlgTool.cpp.

283 {
284 if ( m_pMonitorSvc ) { m_pMonitorSvc->undeclareAll( this ); }
285}
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
Definition AlgTool.h:270

Member Function Documentation

◆ acceptDHVisitor()

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

Definition at line 353 of file AlgTool.cpp.

353 {
354 vis->visit( this );
355
356 for ( auto tool : tools() ) vis->visit( dynamic_cast<AlgTool*>( tool ) );
357}
const std::vector< IAlgTool * > & tools() const
Definition AlgTool.cpp:328
virtual void visit(const IDataHandleHolder *)=0

◆ addToolsArray()

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

Definition at line 179 of file AlgTool.h.

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

◆ auditorSvc()

IAuditorSvc * AlgTool::auditorSvc ( ) const

Access the auditor service.

Definition at line 345 of file AlgTool.cpp.

345 {
346 if ( !m_pAuditorSvc ) {
347 m_pAuditorSvc = service( "AuditorSvc", true );
348 if ( !m_pAuditorSvc ) { throw GaudiException( "Service [AuditorSvc] not found", name(), StatusCode::FAILURE ); }
349 }
350 return m_pAuditorSvc.get();
351}
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition AlgTool.h:271

◆ configure()

StatusCode AlgTool::configure ( )
inlineoverride

Definition at line 75 of file AlgTool.h.

75{ 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 251 of file AlgTool.h.

252 {
253 IMonitorSvc* mS = monitorSvc();
254 if ( mS ) mS->declareInfo( name, format, var, size, desc, this );
255 }
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:227
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 239 of file AlgTool.h.

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

◆ declareInterface()

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

Definition at line 136 of file AlgTool.h.

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

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

145 {
146 this->declareTool( hndl, hndl.typeAndName() ).ignore();
147 return PropertyHolderImpl::declareProperty( name, hndl, doc );
148 }
StatusCode declareTool(ToolHandle< T > &handle, bool createIf=true)
Definition AlgTool.h:151
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 172 of file AlgTool.h.

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

◆ declareTool() [1/2]

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

Definition at line 151 of file AlgTool.h.

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

◆ declareTool() [2/2]

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

Definition at line 156 of file AlgTool.h.

156 {
157
158 StatusCode sc = handle.initialize( toolTypeAndName, handle.isPublic() ? nullptr : this, createIf );
159 if ( !sc ) {
160 throw GaudiException{ std::string{ "Cannot create handle for " } + ( handle.isPublic() ? "public" : "private" ) +
161 " tool " + toolTypeAndName,
162 name(), sc };
163 }
164
165 m_toolHandles.push_back( &handle );
166
167 return sc;
168 }
std::vector< BaseToolHandle * > m_toolHandles
Definition AlgTool.h:294
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 192 of file AlgTool.h.

192 {
193 auto it = std::find( m_tools.begin(), m_tools.end(), tool );
194 if ( it != m_tools.end() ) {
195 if ( msgLevel( MSG::DEBUG ) ) debug() << "De-Registering tool " << tool->name() << endmsg;
196 m_tools.erase( it );
197 } else {
198 if ( msgLevel( MSG::DEBUG ) ) debug() << "Could not de-register tool " << tool->name() << endmsg;
199 }
200 }
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:293
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 65 of file AlgTool.cpp.

65 {
66 if ( !m_evtSvc ) {
67 m_evtSvc = service( "EventDataSvc", true );
68 if ( !m_evtSvc ) { throw GaudiException( "Service [EventDataSvc] not found", name(), StatusCode::FAILURE ); }
69 }
70 return m_evtSvc.get();
71}
SmartIF< IDataProviderSvc > m_evtSvc
Event data service.
Definition AlgTool.h:268

◆ finalize()

StatusCode AlgTool::finalize ( )
override

Definition at line 210 of file AlgTool.cpp.

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

◆ FSMState()

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

Definition at line 83 of file AlgTool.h.

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

◆ i_cast()

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

Query for a given interface.

Definition at line 46 of file AlgTool.cpp.

46 {
47 if ( auto output = base_class::i_cast( riid ) ) { return output; }
48 if ( auto i =
49 std::find_if( std::begin( m_interfaceList ), std::end( m_interfaceList ),
50 [&]( const std::pair<InterfaceID, void*>& item ) { return item.first.versionMatch( riid ); } );
51 i != std::end( m_interfaceList ) ) {
52 return i->second;
53 }
54 return nullptr;
55}
void const * i_cast(const InterfaceID &tid) const override
Implementation of IInterface::i_cast.
Definition extends.h:32

◆ initialize()

StatusCode AlgTool::initialize ( )
override

Definition at line 158 of file AlgTool.cpp.

158 {
159 // For the time being there is nothing to be done here.
160 // Setting the properties is done by the ToolSvc calling setProperties()
161 // explicitly.
162 return StatusCode::SUCCESS;
163}

◆ initToolHandles()

void AlgTool::initToolHandles ( ) const
private

Definition at line 287 of file AlgTool.cpp.

287 {
288 auto init_one = [&]( BaseToolHandle* th ) {
289 if ( !th->isEnabled() ) {
290 if ( msgLevel( MSG::DEBUG ) && !th->typeAndName().empty() )
291 debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
292 return;
293 }
294 if ( !th->get() ) {
295 auto sc = th->retrieve();
296 if ( sc.isFailure() ) {
297 throw GaudiException( "Failed to retrieve tool " + th->typeAndName(), this->name(), StatusCode::FAILURE );
298 }
299 }
300 auto* tool = th->get();
301 if ( msgLevel( MSG::DEBUG ) )
302 debug() << "Adding " << ( th->isPublic() ? "public" : "private" ) << " ToolHandle tool " << tool->name() << " ("
303 << tool->type() << ")" << endmsg;
304 m_tools.push_back( tool );
305 };
306
307 for ( auto thArr : m_toolHandleArrays ) {
308 if ( msgLevel( MSG::DEBUG ) )
309 debug() << "Registering all Tools in ToolHandleArray " << thArr->propertyName() << endmsg;
310 // Iterate over its tools:
311 for ( auto toolHandle : thArr->getBaseArray() ) {
312 // Try to cast it into a BaseToolHandle pointer:
313 BaseToolHandle* bth = dynamic_cast<BaseToolHandle*>( toolHandle );
314 if ( bth ) {
315 init_one( bth );
316 } else {
317 error() << "Error retrieving Tool " << toolHandle->typeAndName() << " in ToolHandleArray "
318 << thArr->propertyName() << ". Not registered" << endmsg;
319 }
320 }
321 }
322
323 for ( BaseToolHandle* th : m_toolHandles ) init_one( th );
324
325 m_toolHandlesInit = true;
326}
bool m_toolHandlesInit
Definition AlgTool.h:296
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 227 of file AlgTool.h.

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

◆ name()

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

Retrieve full identifying name of the concrete tool object.

Definition at line 57 of file AlgTool.cpp.

57{ return m_name; }

◆ parent()

const IInterface * AlgTool::parent ( ) const
override

Retrieve parent of the sub-algtool.

Definition at line 61 of file AlgTool.cpp.

61{ return m_parent; }

◆ registerTool()

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

Definition at line 187 of file AlgTool.h.

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

◆ reinitialize()

StatusCode AlgTool::reinitialize ( )
override

Definition at line 231 of file AlgTool.cpp.

231 {
232 /* @TODO
233 * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
234 * is causing too many problems
235 *
236 // Default implementation is finalize+initialize
237 StatusCode sc = finalize();
238 if (sc.isFailure()) {
239 error() << "reinitialize(): cannot be finalized" << endmsg;
240 return sc;
241 }
242 sc = initialize();
243 if (sc.isFailure()) {
244 error() << "reinitialize(): cannot be initialized" << endmsg;
245 return sc;
246 }
247 */
248 return StatusCode::SUCCESS;
249}

◆ restart()

StatusCode AlgTool::restart ( )
override

Definition at line 268 of file AlgTool.cpp.

268 {
269 // Default implementation is stop+start
270 StatusCode sc = stop();
271 if ( sc.isFailure() ) {
272 error() << "restart(): cannot be stopped" << endmsg;
273 return sc;
274 }
275 sc = start();
276 if ( sc.isFailure() ) {
277 error() << "restart(): cannot be started" << endmsg;
278 return sc;
279 }
280 return StatusCode::SUCCESS;
281}
StatusCode start() override
Definition AlgTool.cpp:177
StatusCode stop() override
Definition AlgTool.cpp:194
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 340 of file AlgTool.cpp.

340 {
341 const ServiceLocatorHelper helper( *serviceLocator(), *this );
342 return helper.service( name, quiet, createIf );
343}

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

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

◆ serviceLocator()

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

Retrieve pointer to service locator.

Definition at line 63 of file AlgTool.cpp.

63{ return m_svcLocator; }

◆ start()

StatusCode AlgTool::start ( )
override

Definition at line 177 of file AlgTool.cpp.

177 {
178 // For the time being there is nothing to be done here.
179 return StatusCode::SUCCESS;
180}

◆ stop()

StatusCode AlgTool::stop ( )
override

Definition at line 194 of file AlgTool.cpp.

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

◆ svcLoc()

ISvcLocator * AlgTool::svcLoc ( ) const
inline

shortcut for the method service locator

Definition at line 116 of file AlgTool.h.

116{ return serviceLocator(); }

◆ sysFinalize()

StatusCode AlgTool::sysFinalize ( )
override

Finalize AlgTool.

Definition at line 199 of file AlgTool.cpp.

199 {
200 return attempt( *this, "sysFinalize", [&]() {
202 Gaudi::Guards::AuditorGuard guard( name(),
203 // check if we want to audit the initialize
205 StatusCode sc = finalize();
206 if ( sc.isSuccess() ) m_state = m_targetState;
207 return sc;
208 } );
209}
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition AlgTool.cpp:345
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition AlgTool.h:299
StatusCode finalize() override
Definition AlgTool.cpp:210
static const std::string Finalize
Definition IAuditor.h:53
bool isSuccess() const
Definition StatusCode.h:314
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 122 of file AlgTool.cpp.

122 {
123 return attempt( *this, "sysInitialize", [&]() {
125 Gaudi::Guards::AuditorGuard guard( name(),
126 // check if we want to audit the initialize
128 StatusCode sc = initialize();
129 if ( !sc ) return sc;
130
133
134 // check for explicit circular data dependencies in declared handles
136 for ( auto& h : outputHandles() ) {
137 if ( !h->objKey().empty() ) out.emplace( h->fullKey() );
138 }
139 for ( auto& h : inputHandles() ) {
140 if ( !h->objKey().empty() && out.find( h->fullKey() ) != out.end() ) {
141 error() << "Explicit circular data dependency found for id " << h->fullKey() << endmsg;
143 }
144 }
145
146 if ( !sc ) return sc;
147
148 // visit all sub-tools, build full set
149 DHHVisitor avis( m_inputDataObjs, m_outputDataObjs );
150 acceptDHVisitor( &avis );
151
152 // initialize handles
153 initDataHandleHolder(); // this should 'freeze' the handle configuration.
154
155 return sc;
156 } );
157}
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:208
StatusCode initialize() override
Definition AlgTool.cpp:158
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition AlgTool.cpp:353
static const std::string Initialize
Definition IAuditor.h:47

◆ sysReinitialize()

StatusCode AlgTool::sysReinitialize ( )
override

Initialize AlgTool.

Definition at line 215 of file AlgTool.cpp.

215 {
216
217 // Check that the current status is the correct one.
219 error() << "sysReinitialize(): cannot reinitialize tool not initialized" << endmsg;
220 return StatusCode::FAILURE;
221 }
222
223 return attempt( *this, "SysReinitialize()", [&]() {
224 Gaudi::Guards::AuditorGuard guard( name(),
225 // check if we want to audit the initialize
227 return reinitialize();
228 } );
229}
Gaudi::StateMachine::State FSMState() const override
Definition AlgTool.h:83
StatusCode reinitialize() override
Definition AlgTool.cpp:231
static const std::string ReInitialize
Definition IAuditor.h:48

◆ sysRestart()

StatusCode AlgTool::sysRestart ( )
override

Start AlgTool.

Definition at line 251 of file AlgTool.cpp.

251 {
252
253 // Check that the current status is the correct one.
255 error() << "sysRestart(): cannot reinitialize tool not started" << endmsg;
256 return StatusCode::FAILURE;
257 }
258
259 return attempt( *this, "sysRestart", [&]() {
261 Gaudi::Guards::AuditorGuard guard( name(),
262 // check if we want to audit the initialize
264 return restart();
265 } );
266}
StatusCode restart() override
Definition AlgTool.cpp:268
static const std::string ReStart
Definition IAuditor.h:50

◆ sysStart()

StatusCode AlgTool::sysStart ( )
override

Start AlgTool.

Definition at line 165 of file AlgTool.cpp.

165 {
166 return attempt( *this, "sysStart", [&]() {
168 Gaudi::Guards::AuditorGuard guard( name(),
169 // check if we want to audit the initialize
171 StatusCode sc = start();
172 if ( sc.isSuccess() ) m_state = m_targetState;
173 return sc;
174 } );
175}
static const std::string Start
Definition IAuditor.h:49

◆ sysStop()

StatusCode AlgTool::sysStop ( )
override

Stop AlgTool.

Definition at line 182 of file AlgTool.cpp.

182 {
183 return attempt( *this, "sysStop", [&]() {
185 Gaudi::Guards::AuditorGuard guard( name(),
186 // check if we want to audit the initialize
188 StatusCode sc = stop();
189 if ( sc.isSuccess() ) m_state = m_targetState;
190 return sc;
191 } );
192}
static const std::string Stop
Definition IAuditor.h:52

◆ targetFSMState()

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

Definition at line 84 of file AlgTool.h.

84{ return m_targetState; }

◆ terminate()

StatusCode AlgTool::terminate ( )
inlineoverride

Definition at line 80 of file AlgTool.h.

80{ return StatusCode::SUCCESS; }

◆ tools() [1/2]

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

Definition at line 334 of file AlgTool.cpp.

334 {
336
337 return m_tools;
338}
void initToolHandles() const
Definition AlgTool.cpp:287

◆ tools() [2/2]

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

Definition at line 328 of file AlgTool.cpp.

328 {
330
331 return m_tools;
332}

◆ toolSvc()

IToolSvc * AlgTool::toolSvc ( ) const

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

Definition at line 72 of file AlgTool.cpp.

72 {
73 if ( !m_ptoolSvc ) {
74 m_ptoolSvc = service( "ToolSvc", true );
75 if ( !m_ptoolSvc ) { throw GaudiException( "Service [ToolSvc] not found", name(), StatusCode::FAILURE ); }
76 }
77 return m_ptoolSvc.get();
78}
SmartIF< IToolSvc > m_ptoolSvc
Tool service.
Definition AlgTool.h:269

◆ type()

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

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

Definition at line 59 of file AlgTool.cpp.

59{ 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 288 of file AlgTool.h.

288{ 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 285 of file AlgTool.h.

285{ 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 289 of file AlgTool.h.

289{ 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 290 of file AlgTool.h.

290{ 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 286 of file AlgTool.h.

286{ 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 287 of file AlgTool.h.

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

◆ m_evtSvc

SmartIF<IDataProviderSvc> AlgTool::m_evtSvc
mutableprivate

Event data service.

Definition at line 268 of file AlgTool.h.

◆ m_interfaceList

InterfaceList AlgTool::m_interfaceList
private

Interface list.

Definition at line 273 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 282 of file AlgTool.h.

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

◆ m_name

const std::string AlgTool::m_name
private

AlgTool full name.

Definition at line 264 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 277 of file AlgTool.h.

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

◆ m_parent

const IInterface* AlgTool::m_parent = nullptr
private

AlgTool parent.

Definition at line 265 of file AlgTool.h.

◆ m_pAuditorSvc

SmartIF<IAuditorSvc> AlgTool::m_pAuditorSvc
mutableprivate

Auditor Service.

Definition at line 271 of file AlgTool.h.

◆ m_pMonitorSvc

SmartIF<IMonitorSvc> AlgTool::m_pMonitorSvc
mutableprivate

Online Monitoring Service.

Definition at line 270 of file AlgTool.h.

◆ m_ptoolSvc

SmartIF<IToolSvc> AlgTool::m_ptoolSvc
mutableprivate

Tool service.

Definition at line 269 of file AlgTool.h.

◆ m_state

flag indicating whether ToolHandle tools have been added to m_tools

state of the Tool

Definition at line 298 of file AlgTool.h.

◆ m_svcLocator

SmartIF<ISvcLocator> AlgTool::m_svcLocator
mutableprivate

Pointer to Service Locator service.

Definition at line 267 of file AlgTool.h.

◆ m_targetState

state of the Tool

Definition at line 299 of file AlgTool.h.

◆ m_toolHandleArrays

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

Definition at line 295 of file AlgTool.h.

◆ m_toolHandles

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

Definition at line 294 of file AlgTool.h.

◆ m_toolHandlesInit

bool AlgTool::m_toolHandlesInit = false
mutableprivate

Definition at line 296 of file AlgTool.h.

◆ m_tools

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

Definition at line 293 of file AlgTool.h.

◆ m_type

std::string AlgTool::m_type
private

AlgTool type (concrete class name)

Definition at line 263 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 208 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: