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

typedef Gaudi::PluginService::Factory< IAlgTool *, const std::string &, const std::string &, const IInterface * > Factory
 
- Public Types inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
using base_class = CommonMessaging
 

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...
 
StatusCode setProperty (const Property &p) override
 Default implementations for IProperty interface. More...
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
PropertyMgrgetPropertyMgr () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value 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...
 
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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none") const
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 
template<class T >
PropertydeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none") const
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 
virtual const DataObjIDCollextraInputDeps () const override
 
virtual const DataObjIDCollextraOutputDeps () const override
 
virtual void acceptDHVisitor (IDataHandleVisitor *) const override
 
DataObjIDColl inputDataObjs () const
 
DataObjIDColl outputDataObjs () const
 
void commitHandles () override
 
void registerTool (IAlgTool *tool) const
 
void deregisterTool (IAlgTool *tool) const
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used public tool. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used private tool. More...
 
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 CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
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...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Protected Member Functions

template<typename I >
void declareInterface (I *i)
 
virtual void declareInput (Gaudi::DataHandle *im) override
 
virtual void declareOutput (Gaudi::DataHandle *im) override
 
std::vector< IAlgTool * > & tools ()
 
- Protected Member Functions inherited from CommonMessaging< implements< IAlgTool, IDataHandleHolder, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

std::unique_ptr< IDataHandleVisitorm_updateDataHandles
 Hook for for derived classes to provide a custom visitor for data handles. More...
 
SmartIF< PropertyMgrm_propertyMgr
 Property Manager. More...
 

Private Types

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

Private Member Functions

void initToolHandles () const
 
StatusCode service_i (const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
StatusCode service_i (const std::string &svcType, const std::string &svcName, const InterfaceID &iid, void **ppS) const
 

Private Attributes

std::vector< Gaudi::DataHandle * > m_inputHandles
 
std::vector< Gaudi::DataHandle * > m_outputHandles
 
DataObjIDColl m_inputDataObjs
 
DataObjIDColl m_outputDataObjs
 
DataObjIDColl m_extInputDataObjs
 
DataObjIDColl m_extOutputDataObjs
 
IntegerProperty m_outputLevel = MSG::NIL
 AlgTool output level. More...
 
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...
 
std::string m_monitorSvcName
 Name to use for Monitor Service. More...
 
InterfaceList m_interfaceList
 Interface list. More...
 
std::string m_threadID
 Thread Id for Alg Tool. More...
 
std::vector< IAlgTool * > m_tools
 
std::vector< BaseToolHandle * > m_toolHandles
 
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
 
bool m_toolHandlesInit = false
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 
BooleanProperty m_auditInit = false
 
bool m_auditorInitialize = false
 flag for auditors in "initialize()" More...
 
bool m_auditorStart = false
 flag for auditors in "start()" More...
 
bool m_auditorStop = false
 flag for auditors in "stop()" More...
 
bool m_auditorFinalize = false
 flag for auditors in "finalize()" More...
 
bool m_auditorReinitialize = false
 flag for auditors in "reinitialize()" More...
 
bool m_auditorRestart = false
 flag for auditors in "restart()" More...
 
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...
 

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

Member Typedef Documentation

Definition at line 54 of file AlgTool.h.

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

197  : m_type ( type )
198  , m_name ( name )
199  , m_parent ( parent )
200  , m_propertyMgr ( new PropertyMgr() )
201 {
202  addRef(); // Initial count set to 1
203 
204  declareProperty( "MonitorService", m_monitorSvcName = "MonitorSvc" );
205 
206  { // get the "OutputLevel" property from parent
207  const Property* _p = Gaudi::Utils::getProperty ( parent , "OutputLevel") ;
208  if ( _p ) { m_outputLevel.assign( *_p ) ; }
209  declareProperty ( "OutputLevel" , m_outputLevel ) ;
211  }
212 
213  IInterface* _p = const_cast<IInterface*> ( parent ) ;
214 
215  if ( Algorithm* _alg = dynamic_cast<Algorithm*> ( _p ) )
216  {
217  m_svcLocator = _alg -> serviceLocator () ;
218  m_threadID = getGaudiThreadIDfromName ( _alg -> name() ) ;
219  }
220  else if ( Service* _svc = dynamic_cast<Service*> ( _p ) )
221  {
222  m_svcLocator = _svc -> serviceLocator () ;
223  m_threadID = getGaudiThreadIDfromName ( _svc -> name() ) ;
224  }
225  else if ( AlgTool* _too = dynamic_cast<AlgTool*> ( _p ) )
226  {
227  m_svcLocator = _too -> serviceLocator ();
229  }
230  else if ( Auditor* _aud = dynamic_cast<Auditor*> ( _p ) )
231  {
232  m_svcLocator = _aud -> serviceLocator() ;
233  m_threadID = getGaudiThreadIDfromName ( _aud -> name() ) ;
234  }
235  else
236  {
237  throw GaudiException
238  ( "Failure to create tool '"
239  + type + "/" + name + "': illegal parent type '"
240  + System::typeinfoName(typeid(*_p)) + "'", "AlgTool", 0 );
241  }
242 
243 
244  { // audit tools
245  auto appMgr = m_svcLocator->service<IProperty>("ApplicationMgr");
246  if ( !appMgr ) {
247  throw GaudiException("Could not locate ApplicationMgr","AlgTool",0);
248  }
249  const Property* p = Gaudi::Utils::getProperty( appMgr , "AuditTools");
250  if ( p ) { m_auditInit.assign ( *p ) ; }
251  declareProperty ( "AuditTools", m_auditInit );
252  bool audit = m_auditInit.value();
253  // Declare common AlgTool properties with their defaults
254  declareProperty ( "AuditInitialize" , m_auditorInitialize = audit ) ;
255  declareProperty ( "AuditStart" , m_auditorStart = audit ) ;
256  declareProperty ( "AuditStop" , m_auditorStop = audit ) ;
257  declareProperty ( "AuditFinalize" , m_auditorFinalize = audit ) ;
258  }
259 
260  //declare Extra input and output properties
261  declareProperty( "ExtraInputs", m_extInputDataObjs);
262  declareProperty( "ExtraOutputs", m_extOutputDataObjs);
263 
264 
265  // check thread ID and try if tool name indicates thread ID
266  if ( m_threadID.empty() )
268 }
T empty(T...args)
Define general base for Gaudi exception.
std::string m_type
AlgTool type (concrete class name)
Definition: AlgTool.h:481
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
const IInterface * m_parent
AlgTool parent.
Definition: AlgTool.h:483
IntegerProperty m_outputLevel
AlgTool output level.
Definition: AlgTool.h:480
GAUDI_API Property * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
Definition: Property.cpp:278
Property manager helper class.
Definition: PropertyMgr.h:37
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: AlgTool.cpp:86
std::string m_monitorSvcName
Name to use for Monitor Service.
Definition: AlgTool.h:488
const std::string m_name
AlgTool full name.
Definition: AlgTool.h:482
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: AlgTool.h:249
Definition of the basic interface.
Definition: IInterface.h:234
std::string m_threadID
Thread Id for Alg Tool.
Definition: AlgTool.h:493
const TYPE & value() const
explicit conversion
Definition: Property.h:341
bool m_auditorFinalize
flag for auditors in "finalize()"
Definition: AlgTool.h:517
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
bool assign(const Property &source) override
get the value from another property
Definition: Property.h:269
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition: AlgTool.h:484
tuple appMgr
Definition: IOTest.py:83
DataObjIDColl m_extInputDataObjs
Definition: AlgTool.h:333
BooleanProperty m_auditInit
Definition: AlgTool.h:513
bool m_auditorStart
flag for auditors in "start()"
Definition: AlgTool.h:515
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
Base class for all services.
Definition: Service.h:36
bool m_auditorStop
flag for auditors in "stop()"
Definition: AlgTool.h:516
GAUDI_API std::string getGaudiThreadIDfromName(const std::string &name)
helper function to extract Gaudi Thread ID from thread copy name
Definition: ThreadGaudi.cpp:26
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
bool m_auditorInitialize
flag for auditors in "initialize()"
Definition: AlgTool.h:514
DataObjIDColl m_extOutputDataObjs
Definition: AlgTool.h:333
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35
const IInterface * parent() const override
Retrieve parent of the sub-algtool.
Definition: AlgTool.cpp:79
AlgTool::~AlgTool ( )
override

Definition at line 453 of file AlgTool.cpp.

455 {
456  if( m_pMonitorSvc ) { m_pMonitorSvc->undeclareAll(this); }
457 }
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
Definition: AlgTool.h:487
virtual void undeclareAll(const IInterface *owner)=0
Undeclare monitoring information.

Member Function Documentation

void AlgTool::acceptDHVisitor ( IDataHandleVisitor vis) const
overridevirtual

Definition at line 566 of file AlgTool.cpp.

566  {
567  //-----------------------------------------------------------------------------
568  vis->visit(this);
569 
570  for (auto tool : tools()) {
571  AlgTool *at = dynamic_cast<AlgTool*>(tool);
572  vis->visit(at);
573  }
574 
575 }
virtual void visit(const IDataHandleHolder *)=0
const std::vector< IAlgTool * > & tools() const
Definition: AlgTool.cpp:512
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
IAuditorSvc * AlgTool::auditorSvc ( ) const

Access the auditor service.

Definition at line 553 of file AlgTool.cpp.

553  {
554 //---------------------------------------------------------------------------
555  if ( !m_pAuditorSvc ) {
556  m_pAuditorSvc = service( "AuditorSvc", true );
557  if( !m_pAuditorSvc ) {
558  throw GaudiException("Service [AuditorSvc] not found", name(), StatusCode::FAILURE);
559  }
560  }
561  return m_pAuditorSvc.get();
562 }
Define general base for Gaudi exception.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
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.
Definition: AlgTool.h:195
SmartIF< IAuditorSvc > m_pAuditorSvc
Auditor Service.
Definition: AlgTool.h:511
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
void AlgTool::commitHandles ( )
override

Definition at line 579 of file AlgTool.cpp.

579  {
580  //-----------------------------------------------------------------------------
581 
582  for (auto h : m_outputHandles) {
583  h->commit();
584  }
585 
586  for (auto t : m_tools) {
587  AlgTool* at = dynamic_cast<AlgTool*>(t);
588  if (at != 0) at->commitHandles();
589  }
590 
591 }
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:496
void commitHandles() override
Definition: AlgTool.cpp:579
std::vector< Gaudi::DataHandle * > m_outputHandles
Definition: AlgTool.h:330
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
StatusCode AlgTool::configure ( )
inlineoverride

Definition at line 70 of file AlgTool.h.

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

453  {
454  IMonitorSvc* mS = monitorSvc();
455  if ( mS ) mS->declareInfo(name, var, desc, this);
456  }
IMonitorSvc * monitorSvc() const
Access the monitor service.
Definition: AlgTool.h:437
Definition of the IMonitorSvc interface, which publishes Gaudi variables to outside monitoring proces...
Definition: IMonitorSvc.h:21
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 465 of file AlgTool.h.

470  {
471  IMonitorSvc* mS = monitorSvc();
472  if ( mS ) mS->declareInfo(name, format, var, size, desc, this);
473  }
IMonitorSvc * monitorSvc() const
Access the monitor service.
Definition: AlgTool.h:437
Definition of the IMonitorSvc interface, which publishes Gaudi variables to outside monitoring proces...
Definition: IMonitorSvc.h:21
virtual void declareInfo(const std::string &name, const bool &var, const std::string &desc, const IInterface *owner)=0
Declare monitoring information.
virtual void AlgTool::declareInput ( Gaudi::DataHandle im)
inlineoverrideprotectedvirtual

Definition at line 299 of file AlgTool.h.

299  {
301  }
std::vector< Gaudi::DataHandle * > m_inputHandles
Definition: AlgTool.h:330
T push_back(T...args)
template<typename I >
void AlgTool::declareInterface ( I *  i)
inlineprotected

Definition at line 215 of file AlgTool.h.

215 { m_interfaceList.emplace_back( I::interfaceID(), i ); }
InterfaceList m_interfaceList
Interface list.
Definition: AlgTool.h:492
list i
Definition: ana.py:128
T emplace_back(T...args)
virtual void AlgTool::declareOutput ( Gaudi::DataHandle im)
inlineoverrideprotectedvirtual

Definition at line 303 of file AlgTool.h.

303  {
305  }
T push_back(T...args)
std::vector< Gaudi::DataHandle * > m_outputHandles
Definition: AlgTool.h:330
template<class T >
StatusCode AlgTool::declarePrivateTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName = "",
bool  createIf = true 
)
inline

Declare used private tool.

Parameters
handleToolHandle<T>
toolTypeAndName
parent,defaultpublic tool
createif necessary, default true

Definition at line 391 of file AlgTool.h.

393  {
394 
395  if (toolTypeAndName == "")
396  toolTypeAndName = handle.typeAndName();
397 
398  StatusCode sc = handle.initialize(toolTypeAndName, this, createIf);
399  if (UNLIKELY(!sc)) {
400  throw GaudiException{"Cannot create handle for private tool " + toolTypeAndName,
401  name(), sc};
402  }
403 
404  m_toolHandles.push_back(&handle);
405 
406  return sc;
407  }
std::string typeAndName() const override
Definition: ToolHandle.h:199
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< BaseToolHandle * > m_toolHandles
Definition: AlgTool.h:497
Define general base for Gaudi exception.
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:157
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
template<class T >
Property* AlgTool::declareProperty ( const std::string name,
T &  property,
const std::string doc = "none" 
) const
inline

Declare the named property.

MyTool ( const std::string& type ,
const std::string& name ,
const IInterface* parent )
: AlgTool ( type , name , pSvc )
, m_property1 ( ... )
, m_property2 ( ... )
{
// declare the property
declareProperty( "Property1" , m_property1 , "Doc for property #1" ) ;
// declare the property and attach the handler to it
declareProperty( "Property2" , m_property2 , "Doc for property #2" )
-> declareUpdateHandler( &MyTool::handler_2 ) ;
}
See also
PropertyMgr
PropertyMgr::declareProperty
Parameters
namethe property name
propertythe property itself,
docthe documentation string
Returns
the actual property objects

Definition at line 249 of file AlgTool.h.

252  {
253  return m_propertyMgr -> declareProperty ( name , property , doc ) ;
254  }
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: AlgTool.h:249
template<class T >
Property* AlgTool::declareProperty ( const std::string name,
ToolHandle< T > &  hndl,
const std::string doc = "none" 
) const
inline

Definition at line 266 of file AlgTool.h.

268  {
269 
270  AlgTool* a = const_cast<AlgTool*>(this);
271  a->declareTool(hndl).ignore();
272 
273  return m_propertyMgr->declareProperty(name, hndl, doc);
274 
275  }
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
Property * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:186
StatusCode declareTool(ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
Definition: AlgTool.h:278
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
void ignore() const
Definition: StatusCode.h:108
template<class T >
Property* AlgTool::declareProperty ( const std::string name,
ToolHandleArray< T > &  hndlArr,
const std::string doc = "none" 
) const
inline

Definition at line 291 of file AlgTool.h.

293  {
294  m_toolHandleArrays.push_back( &hndlArr );
295  return m_propertyMgr->declareProperty(name, hndlArr, doc);
296  }
T push_back(T...args)
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
Property * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition: PropertyMgr.h:186
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition: AlgTool.h:498
template<class T >
StatusCode AlgTool::declarePublicTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName = "",
bool  createIf = true 
)
inline

Declare used public tool.

Parameters
handleToolHandle<T>
toolTypeAndName
parent,defaultpublic tool
createif necessary, default true

Definition at line 365 of file AlgTool.h.

367  {
368 
369  if (toolTypeAndName == "")
370  toolTypeAndName = handle.typeAndName();
371 
372  StatusCode sc = handle.initialize(toolTypeAndName, 0, createIf);
373  if (UNLIKELY(!sc)) {
374  throw GaudiException{"Cannot create handle for public tool " + toolTypeAndName,
375  name(), sc};
376  }
377 
378  m_toolHandles.push_back(&handle);
379 
380  return sc;
381  }
std::string typeAndName() const override
Definition: ToolHandle.h:199
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< BaseToolHandle * > m_toolHandles
Definition: AlgTool.h:497
Define general base for Gaudi exception.
T push_back(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:157
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
Property* AlgTool::declareRemoteProperty ( const std::string name,
IProperty rsvc,
const std::string rname = "" 
) const
inline

Declare remote named properties.

Definition at line 257 of file AlgTool.h.

260  {
261  return m_propertyMgr-> declareRemoteProperty ( name , rsvc , rname ) ;
262  }
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
Property * declareRemoteProperty(const std::string &name, IProperty *rsvc, const std::string &rname="") const
Declare remote named properties.
Definition: AlgTool.h:257
template<class T >
StatusCode AlgTool::declareTool ( ToolHandle< T > &  handle,
std::string  toolTypeAndName = "",
bool  createIf = true 
)
inline

Definition at line 278 of file AlgTool.h.

280  {
281  if (handle.isPublic()) {
282  return declarePublicTool(handle, toolTypeAndName, createIf);
283  } else {
284  return declarePrivateTool(handle, toolTypeAndName, createIf);
285  }
286  }
StatusCode declarePrivateTool(ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
Declare used private tool.
Definition: AlgTool.h:391
bool isPublic() const
Definition: ToolHandle.h:34
StatusCode declarePublicTool(ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
Declare used public tool.
Definition: AlgTool.h:365
void AlgTool::deregisterTool ( IAlgTool tool) const
inline

Definition at line 345 of file AlgTool.h.

345  {
346  auto it = std::find(m_tools.begin(), m_tools.end(), tool);
347  if (it != m_tools.end()) {
349  debug() << "De-Registering tool " << tool->name() << endmsg;
350  m_tools.erase(it);
351  } else {
353  debug() << "Could not de-register tool " << tool->name() << endmsg;
354  }
355  }
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:496
T end(T...args)
virtual const std::string & name() const =0
Retrieve the name of the instance.
T erase(T...args)
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T begin(T...args)
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IDataProviderSvc * AlgTool::evtSvc ( ) const

accessor to event service service

Returns
pointer to detector service

Definition at line 95 of file AlgTool.cpp.

96 {
97  if ( !m_evtSvc ) {
98  m_evtSvc = service("EventDataSvc", true);
99  if ( !m_evtSvc ) {
100  throw GaudiException("Service [EventDataSvc] not found", name(), StatusCode::FAILURE);
101  }
102  }
103  return m_evtSvc.get();
104 }
Define general base for Gaudi exception.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
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.
Definition: AlgTool.h:195
SmartIF< IDataProviderSvc > m_evtSvc
Event data service.
Definition: AlgTool.h:485
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
virtual const DataObjIDColl& AlgTool::extraInputDeps ( ) const
inlineoverridevirtual

Definition at line 313 of file AlgTool.h.

313  {
314  return m_extInputDataObjs;
315  }
DataObjIDColl m_extInputDataObjs
Definition: AlgTool.h:333
virtual const DataObjIDColl& AlgTool::extraOutputDeps ( ) const
inlineoverridevirtual

Definition at line 316 of file AlgTool.h.

316  {
317  return m_extOutputDataObjs;
318  }
DataObjIDColl m_extOutputDataObjs
Definition: AlgTool.h:333
StatusCode AlgTool::finalize ( )
override

Definition at line 360 of file AlgTool.cpp.

362 {
363  // For the time being there is nothing to be done here.
364  return StatusCode::SUCCESS;
365 }
Gaudi::StateMachine::State AlgTool::FSMState ( ) const
inlineoverride

Definition at line 78 of file AlgTool.h.

78 { return m_state; }
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:521
const std::vector< Property * > & AlgTool::getProperties ( ) const
override

Definition at line 160 of file AlgTool.cpp.

162 {
163  return m_propertyMgr->getProperties();
164 }
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
const std::vector< Property * > & getProperties() const override
get all properties
StatusCode AlgTool::getProperty ( Property p) const
override

Definition at line 140 of file AlgTool.cpp.

142 {
143  return m_propertyMgr->getProperty(p);
144 }
StatusCode getProperty(Property *p) const override
get the property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
const Property & AlgTool::getProperty ( const std::string name) const
override

Definition at line 147 of file AlgTool.cpp.

148 {
149  return m_propertyMgr->getProperty(n);
150 }
StatusCode getProperty(Property *p) const override
get the property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
StatusCode AlgTool::getProperty ( const std::string n,
std::string v 
) const
override

Definition at line 153 of file AlgTool.cpp.

155 {
156  return m_propertyMgr->getProperty(n,v);
157 }
StatusCode getProperty(Property *p) const override
get the property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
PropertyMgr* AlgTool::getPropertyMgr ( ) const
inline

Definition at line 109 of file AlgTool.h.

109 { return m_propertyMgr; }
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
bool AlgTool::hasProperty ( const std::string name) const
override

Definition at line 166 of file AlgTool.cpp.

166  {
167  return m_propertyMgr->hasProperty(name);
168 }
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
StatusCode AlgTool::initialize ( )
override

Definition at line 290 of file AlgTool.cpp.

292 {
293  // For the time being there is nothing to be done here.
294  // Setting the properties is done by the ToolSvc calling setProperties()
295  // explicitly.
296  return StatusCode::SUCCESS;
297 }
void AlgTool::initToolHandles ( ) const
private

Definition at line 460 of file AlgTool.cpp.

460  {
461 
462  IAlgTool* tool(0);
463  for (auto thArr : m_toolHandleArrays) {
464  if (! thArr->retrieved()) {
466  debug() << "ToolHandleArray " << thArr->propertyName()
467  << " not used: not registering any of its Tools" << endmsg;
468  } else {
470  debug() << "Registering all Tools in ToolHandleArray "
471  << thArr->propertyName() ;
472  for (auto th_name : thArr->typesAndNames()) {
474  debug() << std::endl << " + " << th_name;
475  if (toolSvc()->retrieveTool(th_name, tool, this).isSuccess()) {
477  debug() << " (private)";
478  m_tools.push_back(tool);
479  } else if (toolSvc()->retrieveTool(th_name, tool, 0).isSuccess()) {
481  debug() << " (public)";
482  m_tools.push_back(tool);
483  } else {
485  debug() << " - ERROR" << endmsg;
486  warning() << "Error retrieving Tool " << th_name
487  << " in ToolHandleArray" << thArr->propertyName()
488  << ". Not registered" << endmsg;
489  }
490  }
492  }
493  }
494 
495  for(auto th : m_toolHandles){
496  tool = th->get();
497  if(tool){
498  m_tools.push_back(tool);
500  debug() << "Adding "
501  << (th->isPublic() ? "Public" : "Private" )
502  << " ToolHandle tool " << tool->name()
503  << " (" << tool->type() << ")" << endmsg;
504  } else {
506  debug() << "ToolHandle " << th->typeAndName() << " not used" << endmsg;
507  }
508  }
509  m_toolHandlesInit = true;
510 }
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:496
std::vector< BaseToolHandle * > m_toolHandles
Definition: AlgTool.h:497
bool m_toolHandlesInit
Definition: AlgTool.h:499
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
T endl(T...args)
IToolSvc * toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: AlgTool.cpp:106
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned...
Definition: IToolSvc.h:145
T push_back(T...args)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< GaudiHandleArrayBase * > m_toolHandleArrays
Definition: AlgTool.h:498
DataObjIDColl AlgTool::inputDataObjs ( ) const
inline

Definition at line 323 of file AlgTool.h.

323 { return m_inputDataObjs; }
DataObjIDColl m_inputDataObjs
Definition: AlgTool.h:331
virtual std::vector<Gaudi::DataHandle*> AlgTool::inputHandles ( ) const
inlineoverridevirtual

Definition at line 308 of file AlgTool.h.

308  {
309  return m_inputHandles; }
std::vector< Gaudi::DataHandle * > m_inputHandles
Definition: AlgTool.h:330
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 437 of file AlgTool.h.

438  {
439  // If not already located try to locate it without forcing a creation
440  if ( !m_pMonitorSvc ) m_pMonitorSvc = service(m_monitorSvcName, false, true);
441  return m_pMonitorSvc.get();
442  }
SmartIF< IMonitorSvc > m_pMonitorSvc
Online Monitoring Service.
Definition: AlgTool.h:487
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
std::string m_monitorSvcName
Name to use for Monitor Service.
Definition: AlgTool.h:488
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.
Definition: AlgTool.h:195
const std::string & AlgTool::name ( ) const
override

Retrieve full identifying name of the concrete tool object.

Definition at line 65 of file AlgTool.cpp.

67 {
68  return m_name;
69 }
const std::string m_name
AlgTool full name.
Definition: AlgTool.h:482
DataObjIDColl AlgTool::outputDataObjs ( ) const
inline

Definition at line 324 of file AlgTool.h.

324 { return m_outputDataObjs; }
DataObjIDColl m_outputDataObjs
Definition: AlgTool.h:331
virtual std::vector<Gaudi::DataHandle*> AlgTool::outputHandles ( ) const
inlineoverridevirtual

Definition at line 310 of file AlgTool.h.

310  {
311  return m_outputHandles; }
std::vector< Gaudi::DataHandle * > m_outputHandles
Definition: AlgTool.h:330
const IInterface * AlgTool::parent ( ) const
override

Retrieve parent of the sub-algtool.

Definition at line 79 of file AlgTool.cpp.

81 {
82  return m_parent;
83 }
const IInterface * m_parent
AlgTool parent.
Definition: AlgTool.h:483
StatusCode AlgTool::queryInterface ( const InterfaceID riid,
void **  ppvUnknown 
)
override

Query for a given interface.

Definition at line 45 of file AlgTool.cpp.

48 {
49  if ( !ppvi ) { return StatusCode::FAILURE ; } // RETURN
50  StatusCode sc = base_class::queryInterface(riid,ppvi);
51  if (sc.isSuccess()) return sc;
54  return item.first.versionMatch(riid);
55  } );
56  if ( i == std::end(m_interfaceList) ) {
57  *ppvi = nullptr ;
58  return NO_INTERFACE ; // RETURN
59  }
60  *ppvi = i->second ;
61  addRef() ;
62  return SUCCESS ; // RETURN
63 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
T end(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T find_if(T...args)
T begin(T...args)
tuple item
print s1,s2
Definition: ana.py:146
InterfaceList m_interfaceList
Interface list.
Definition: AlgTool.h:492
list i
Definition: ana.py:128
void AlgTool::registerTool ( IAlgTool tool) const
inline

Definition at line 339 of file AlgTool.h.

339  {
341  debug() << "Registering tool " << tool->name() << endmsg;
342  m_tools.push_back(tool);
343  }
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:496
virtual const std::string & name() const =0
Retrieve the name of the instance.
T push_back(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode AlgTool::reinitialize ( )
override

Definition at line 390 of file AlgTool.cpp.

392 {
393  /* @TODO
394  * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
395  * is causing too many problems
396  *
397  // Default implementation is finalize+initialize
398  StatusCode sc = finalize();
399  if (sc.isFailure()) {
400  error() << "reinitialize(): cannot be finalized" << endmsg;
401  return sc;
402  }
403  sc = initialize();
404  if (sc.isFailure()) {
405  error() << "reinitialize(): cannot be initialized" << endmsg;
406  return sc;
407  }
408  */
409  return StatusCode::SUCCESS;
410 }
StatusCode AlgTool::restart ( )
override

Definition at line 435 of file AlgTool.cpp.

437 {
438  // Default implementation is stop+start
439  StatusCode sc = stop();
440  if (sc.isFailure()) {
441  error() << "restart(): cannot be stopped" << endmsg;
442  return sc;
443  }
444  sc = start();
445  if (sc.isFailure()) {
446  error() << "restart(): cannot be started" << endmsg;
447  return sc;
448  }
449  return StatusCode::SUCCESS;
450 }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode stop() override
Definition: AlgTool.cpp:338
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode start() override
Definition: AlgTool.cpp:315
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 195 of file AlgTool.h.

195  {
196  return service_i(name, createIf, T::interfaceID(), (void**)&svc);
197  }
StatusCode service_i(const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
flag indicating whether ToolHandle tools have been added to m_tools
Definition: AlgTool.cpp:529
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 202 of file AlgTool.h.

202  {
203  return service_i(type, name, T::interfaceID(), (void**)&svc);
204  }
StatusCode service_i(const std::string &algName, bool createIf, const InterfaceID &iid, void **ppSvc) const
flag indicating whether ToolHandle tools have been added to m_tools
Definition: AlgTool.cpp:529
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 547 of file AlgTool.cpp.

547  {
548  const ServiceLocatorHelper helper(*serviceLocator(), *this);
549  return helper.service(name, quiet, createIf);
550 }
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:86
template<typename T >
SmartIF<T> AlgTool::service ( const std::string name,
const bool  createIf = true,
const bool  quiet = false 
) const
inline

Definition at line 210 of file AlgTool.h.

211  { return SmartIF<T>( service(name,createIf,quiet) ); }
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
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.
Definition: AlgTool.h:195
StatusCode AlgTool::service_i ( const std::string algName,
bool  createIf,
const InterfaceID iid,
void **  ppSvc 
) const
private

flag indicating whether ToolHandle tools have been added to m_tools

implementation of service method

Definition at line 529 of file AlgTool.cpp.

532  {
533  const ServiceLocatorHelper helper(*serviceLocator(), *this);
534  return helper.getService(svcName, createIf, iid, ppSvc);
535 }
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:86
StatusCode AlgTool::service_i ( const std::string svcType,
const std::string svcName,
const InterfaceID iid,
void **  ppS 
) const
private

Definition at line 539 of file AlgTool.cpp.

542  {
543  const ServiceLocatorHelper helper(*serviceLocator(), *this);
544  return helper.createService(svcType, svcName, iid, ppSvc);
545 }
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:86
SmartIF< ISvcLocator > & AlgTool::serviceLocator ( ) const
override

Retrieve pointer to service locator.

Definition at line 86 of file AlgTool.cpp.

88 {
89  return m_svcLocator;
90 }
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition: AlgTool.h:484
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 171 of file AlgTool.cpp.

173 {
174  if( !m_svcLocator ) return StatusCode::FAILURE;
175  auto jos = m_svcLocator->service<IJobOptionsSvc>("JobOptionsSvc");
176  if( !jos ) return StatusCode::FAILURE;
177 
178  // set first generic Properties
179  StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
180  if( sc.isFailure() ) return StatusCode::FAILURE;
181 
182  // set specific Properties
183  if (isGaudiThreaded(name())) {
184  if(jos->setMyProperties( name(), this ).isFailure()) {
185  return StatusCode::FAILURE;
186  }
187  }
189  return StatusCode::SUCCESS;
190 }
IntegerProperty m_outputLevel
AlgTool output level.
Definition: AlgTool.h:480
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
GAUDI_API bool isGaudiThreaded(const std::string &name)
test if current Gaudi object is running /will run in a thread
Definition: ThreadGaudi.cpp:73
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
Main interface for the JobOptions service.
void updateMsgStreamOutputLevel(int level)
Update the output level of the cached MsgStream.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< ISvcLocator > m_svcLocator
Pointer to Service Locator service.
Definition: AlgTool.h:484
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
GAUDI_API std::string getGaudiThreadGenericName(const std::string &name)
helper function to extract Gaudi instance name from thread copy name
Definition: ThreadGaudi.cpp:50
StatusCode AlgTool::setProperty ( const Property p)
override

Default implementations for IProperty interface.

Definition at line 119 of file AlgTool.cpp.

121 {
122  return m_propertyMgr->setProperty(p);
123 }
StatusCode setProperty(const Property &p) override
set the property form another property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
StatusCode AlgTool::setProperty ( const std::string s)
override

Definition at line 126 of file AlgTool.cpp.

128 {
129  return m_propertyMgr->setProperty(s);
130 }
StatusCode setProperty(const Property &p) override
set the property form another property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
StatusCode AlgTool::setProperty ( const std::string n,
const std::string v 
)
override

Definition at line 133 of file AlgTool.cpp.

135 {
136  return m_propertyMgr->setProperty(n,v);
137 }
StatusCode setProperty(const Property &p) override
set the property form another property
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
template<class TYPE >
StatusCode AlgTool::setProperty ( const std::string name,
const TYPE &  value 
)
inline

set the property form the value

std::vector<double> data = ... ;
setProperty( "Data" , data ) ;
setProperty( "Cuts" , cuts ) ;
setProperty( "Dictionary" , dict ) ;

Note: the interface IProperty allows setting of the properties either directly from other properties or from strings only

This is very convenient in resetting of the default properties in the derived classes. E.g. without this method one needs to convert everything into strings to use IProperty::setProperty

setProperty ( "OutputLevel" , "1" ) ;
setProperty ( "Enable" , "True" ) ;
setProperty ( "ErrorMax" , "10" ) ;

For simple cases it is more or less ok, but for complicated properties it is just ugly..

Parameters
namename of the property
valuevalue of the property
See also
Gaudi::Utils::setProperty
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-05-13

Definition at line 155 of file AlgTool.h.

157  { return Gaudi::Utils::setProperty ( m_propertyMgr.get() , name , value ) ; }
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
Definition: Property.h:1187
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
SmartIF< PropertyMgr > m_propertyMgr
Property Manager.
Definition: AlgTool.h:490
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
StatusCode AlgTool::start ( )
override

Definition at line 315 of file AlgTool.cpp.

317 {
318  // For the time being there is nothing to be done here.
319  return StatusCode::SUCCESS;
320 }
StatusCode AlgTool::stop ( )
override

Definition at line 338 of file AlgTool.cpp.

340 {
341  // For the time being there is nothing to be done here.
342  return StatusCode::SUCCESS;
343 }
ISvcLocator* AlgTool::svcLoc ( ) const
inline

shortcut for the method service locator

Definition at line 173 of file AlgTool.h.

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

Finalize AlgTool.

Definition at line 346 of file AlgTool.cpp.

346  {
347 //-----------------------------------------------------------------------------
348  return attempt( *this, "sysFinalize", [&]() {
350  Gaudi::Guards::AuditorGuard guard(this,
351  // check if we want to audit the initialize
352  m_auditorFinalize ? auditorSvc() : nullptr,
354  StatusCode sc = finalize();
355  if (sc.isSuccess()) m_state = m_targetState;
356  return sc;
357  } );
358 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
StatusCode finalize() override
Definition: AlgTool.cpp:360
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
bool m_auditorFinalize
flag for auditors in "finalize()"
Definition: AlgTool.h:517
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:521
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...
Definition: StateMachine.cpp:8
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:522
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:553
StatusCode AlgTool::sysInitialize ( )
override

Initialize AlgTool.

Definition at line 271 of file AlgTool.cpp.

271  {
272 //-----------------------------------------------------------------------------
273  return attempt( *this, "sysInitialize", [&]() {
275  Gaudi::Guards::AuditorGuard guard(this,
276  // check if we want to audit the initialize
277  m_auditorInitialize ? auditorSvc() : nullptr,
280  if (!sc) return sc;
281 
285 
286  return sc;
287  } );
288 }
StatusCode initialize() override
Definition: AlgTool.cpp:290
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: AlgTool.cpp:566
T get(T...args)
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:521
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...
Definition: StateMachine.cpp:8
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:522
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
bool m_auditorInitialize
flag for auditors in "initialize()"
Definition: AlgTool.h:514
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:553
std::unique_ptr< IDataHandleVisitor > m_updateDataHandles
Hook for for derived classes to provide a custom visitor for data handles.
Definition: AlgTool.h:416
StatusCode AlgTool::sysReinitialize ( )
override

Initialize AlgTool.

Definition at line 368 of file AlgTool.cpp.

368  {
369 //-----------------------------------------------------------------------------
370 
371  // Check that the current status is the correct one.
373  error()
374  << "sysReinitialize(): cannot reinitialize tool not initialized"
375  << endmsg;
376  return StatusCode::FAILURE;
377  }
378 
379  return attempt(*this, "SysReinitialize()", [&]() {
380  Gaudi::Guards::AuditorGuard guard(this,
381  // check if we want to audit the initialize
382  m_auditorReinitialize ? auditorSvc() : nullptr,
384  return reinitialize();
385  } );
386 
387 }
Gaudi::StateMachine::State FSMState() const override
Definition: AlgTool.h:78
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool m_auditorReinitialize
flag for auditors in "reinitialize()"
Definition: AlgTool.h:518
StatusCode reinitialize() override
Definition: AlgTool.cpp:390
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:553
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode AlgTool::sysRestart ( )
override

Start AlgTool.

Definition at line 413 of file AlgTool.cpp.

413  {
414 //-----------------------------------------------------------------------------
415 
416  // Check that the current status is the correct one.
418  error()
419  << "sysRestart(): cannot reinitialize tool not started"
420  << endmsg;
421  return StatusCode::FAILURE;
422  }
423 
424  return attempt(*this, "sysRestart", [&]() {
426  Gaudi::Guards::AuditorGuard guard(this,
427  // check if we want to audit the initialize
428  m_auditorRestart ? auditorSvc() : nullptr,
430  return restart();
431  } );
432 }
Gaudi::StateMachine::State FSMState() const override
Definition: AlgTool.h:78
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode restart() override
Definition: AlgTool.cpp:435
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:521
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...
Definition: StateMachine.cpp:8
bool m_auditorRestart
flag for auditors in "restart()"
Definition: AlgTool.h:519
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:522
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:553
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode AlgTool::sysStart ( )
override

Start AlgTool.

Definition at line 300 of file AlgTool.cpp.

300  {
301 //-----------------------------------------------------------------------------
302  return attempt( *this, "sysInitialize", [&]() {
304  Gaudi::Guards::AuditorGuard guard(this,
305  // check if we want to audit the initialize
306  m_auditorStart ? auditorSvc() : nullptr,
308  StatusCode sc = start();
309  if (sc.isSuccess()) m_state = m_targetState;
310  return sc;
311  } );
312 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:521
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...
Definition: StateMachine.cpp:8
bool m_auditorStart
flag for auditors in "start()"
Definition: AlgTool.h:515
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:522
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:553
StatusCode start() override
Definition: AlgTool.cpp:315
StatusCode AlgTool::sysStop ( )
override

Stop AlgTool.

Definition at line 323 of file AlgTool.cpp.

323  {
324 //-----------------------------------------------------------------------------
325  return attempt( *this, "sysStop", [&]() {
327  Gaudi::Guards::AuditorGuard guard(this,
328  // check if we want to audit the initialize
329  m_auditorStop ? auditorSvc() : nullptr,
331  StatusCode sc = stop();
332  if (sc.isSuccess()) m_state = m_targetState;
333  return sc;
334  } );
335 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Gaudi::StateMachine::State m_state
state of the Tool
Definition: AlgTool.h:521
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...
Definition: StateMachine.cpp:8
StatusCode stop() override
Definition: AlgTool.cpp:338
Gaudi::StateMachine::State m_targetState
state of the Tool
Definition: AlgTool.h:522
It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way...
Definition: Guards.h:214
bool m_auditorStop
flag for auditors in "stop()"
Definition: AlgTool.h:516
IAuditorSvc * auditorSvc() const
Access the auditor service.
Definition: AlgTool.cpp:553
Gaudi::StateMachine::State AlgTool::targetFSMState ( ) const
inlineoverride

Definition at line 79 of file AlgTool.h.

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

Definition at line 75 of file AlgTool.h.

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

Definition at line 512 of file AlgTool.cpp.

512  {
514  initToolHandles();
515 
516  return m_tools;
517 }
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:496
bool m_toolHandlesInit
Definition: AlgTool.h:499
void initToolHandles() const
Definition: AlgTool.cpp:460
std::vector< IAlgTool * > & AlgTool::tools ( )
protected

Definition at line 519 of file AlgTool.cpp.

519  {
521  initToolHandles();
522 
523  return m_tools;
524 }
#define UNLIKELY(x)
Definition: Kernel.h:126
std::vector< IAlgTool * > m_tools
Definition: AlgTool.h:496
bool m_toolHandlesInit
Definition: AlgTool.h:499
void initToolHandles() const
Definition: AlgTool.cpp:460
IToolSvc * AlgTool::toolSvc ( ) const

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

Definition at line 106 of file AlgTool.cpp.

108 {
109  if ( !m_ptoolSvc ) {
110  m_ptoolSvc = service( "ToolSvc", true );
111  if( !m_ptoolSvc ) {
112  throw GaudiException("Service [ToolSvc] not found", name(), StatusCode::FAILURE);
113  }
114  }
115  return m_ptoolSvc.get();
116 }
Define general base for Gaudi exception.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
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.
Definition: AlgTool.h:195
SmartIF< IToolSvc > m_ptoolSvc
Tool service.
Definition: AlgTool.h:486
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
const std::string & AlgTool::type ( ) const
override

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

Definition at line 72 of file AlgTool.cpp.

74 {
75  return m_type;
76 }
std::string m_type
AlgTool type (concrete class name)
Definition: AlgTool.h:481

Member Data Documentation

BooleanProperty AlgTool::m_auditInit = false
private

Definition at line 513 of file AlgTool.h.

bool AlgTool::m_auditorFinalize = false
private

flag for auditors in "finalize()"

Definition at line 517 of file AlgTool.h.

bool AlgTool::m_auditorInitialize = false
private

flag for auditors in "initialize()"

Definition at line 514 of file AlgTool.h.

bool AlgTool::m_auditorReinitialize = false
private

flag for auditors in "reinitialize()"

Definition at line 518 of file AlgTool.h.

bool AlgTool::m_auditorRestart = false
private

flag for auditors in "restart()"

Definition at line 519 of file AlgTool.h.

bool AlgTool::m_auditorStart = false
private

flag for auditors in "start()"

Definition at line 515 of file AlgTool.h.

bool AlgTool::m_auditorStop = false
private

flag for auditors in "stop()"

Definition at line 516 of file AlgTool.h.

SmartIF<IDataProviderSvc> AlgTool::m_evtSvc
mutableprivate

Event data service.

Definition at line 485 of file AlgTool.h.

DataObjIDColl AlgTool::m_extInputDataObjs
private

Definition at line 333 of file AlgTool.h.

DataObjIDColl AlgTool::m_extOutputDataObjs
private

Definition at line 333 of file AlgTool.h.

DataObjIDColl AlgTool::m_inputDataObjs
private

Definition at line 331 of file AlgTool.h.

std::vector<Gaudi::DataHandle*> AlgTool::m_inputHandles
private

Definition at line 330 of file AlgTool.h.

InterfaceList AlgTool::m_interfaceList
private

Interface list.

Definition at line 492 of file AlgTool.h.

std::string AlgTool::m_monitorSvcName
private

Name to use for Monitor Service.

Definition at line 488 of file AlgTool.h.

const std::string AlgTool::m_name
private

AlgTool full name.

Definition at line 482 of file AlgTool.h.

DataObjIDColl AlgTool::m_outputDataObjs
private

Definition at line 331 of file AlgTool.h.

std::vector<Gaudi::DataHandle*> AlgTool::m_outputHandles
private

Definition at line 330 of file AlgTool.h.

IntegerProperty AlgTool::m_outputLevel = MSG::NIL
private

AlgTool output level.

Definition at line 480 of file AlgTool.h.

const IInterface* AlgTool::m_parent = nullptr
private

AlgTool parent.

Definition at line 483 of file AlgTool.h.

SmartIF<IAuditorSvc> AlgTool::m_pAuditorSvc
mutableprivate

Auditor Service.

Definition at line 511 of file AlgTool.h.

SmartIF<IMonitorSvc> AlgTool::m_pMonitorSvc
mutableprivate

Online Monitoring Service.

Definition at line 487 of file AlgTool.h.

SmartIF<PropertyMgr> AlgTool::m_propertyMgr
protected

Property Manager.

Definition at line 490 of file AlgTool.h.

SmartIF<IToolSvc> AlgTool::m_ptoolSvc
mutableprivate

Tool service.

Definition at line 486 of file AlgTool.h.

state of the Tool

Definition at line 521 of file AlgTool.h.

SmartIF<ISvcLocator> AlgTool::m_svcLocator
mutableprivate

Pointer to Service Locator service.

Definition at line 484 of file AlgTool.h.

state of the Tool

Definition at line 522 of file AlgTool.h.

std::string AlgTool::m_threadID
private

Thread Id for Alg Tool.

Definition at line 493 of file AlgTool.h.

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

Definition at line 498 of file AlgTool.h.

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

Definition at line 497 of file AlgTool.h.

bool AlgTool::m_toolHandlesInit = false
mutableprivate

Definition at line 499 of file AlgTool.h.

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

Definition at line 496 of file AlgTool.h.

std::string AlgTool::m_type
private

AlgTool type (concrete class name)

Definition at line 481 of file AlgTool.h.

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

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

Definition at line 416 of file AlgTool.h.


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