The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
IToolSvc Class Referenceabstract

The interface implemented by the IToolSvc base class. More...

#include <GaudiKernel/IToolSvc.h>

Inheritance diagram for IToolSvc:
Collaboration diagram for IToolSvc:

Classes

class  Observer
 allow call-backs when a tool is a created or retrieved More...
 

Public Types

typedef std::list< IAlgTool * > ListTools
 
- Public Types inherited from IInterface
enum class  Status : StatusCode::code_t {
  FAILURE = 0 , SUCCESS = 1 , NO_INTERFACE , VERSMISMATCH ,
  LAST_ERROR
}
 Return status. More...
 
using iid = Gaudi::InterfaceId<IInterface, 0, 0>
 Interface ID.
 
using ext_iids = Gaudi::interface_list<iid>
 Extra interfaces.
 

Public Member Functions

 DeclareInterfaceID (IToolSvc, 2, 1)
 InterfaceID.
 
virtual StatusCode retrieve (std::string_view type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent=0, bool createIf=true)=0
 Retrieve tool with tool dependent part of the name automatically assigned.
 
virtual StatusCode retrieve (std::string_view type, std::string_view name, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent=0, bool createIf=true)=0
 Retrieve tool with tool dependent part of the name specified by the requester.
 
virtual std::vector< std::string > getInstances (std::string_view toolType)=0
 Get the names of all instances of tools of a given type.
 
virtual std::vector< std::string > getInstances () const =0
 Get the names all tool instances.
 
virtual std::vector< IAlgTool * > getTools () const =0
 Get pointers to all tool instances.
 
virtual StatusCode releaseTool (IAlgTool *tool)=0
 Release the tool.
 
template<class T>
StatusCode retrieveTool (std::string_view type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
 Retrieve specified tool sub-type with tool dependent part of the name automatically assigned.
 
template<class T>
StatusCode retrieveTool (std::string_view type, std::string_view name, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
 Retrieve specified tool sub-type with tool dependent part of the name tool dependent part of the name specified by the requester.
 
virtual void registerObserver (Observer *obs)=0
 
- Public Member Functions inherited from IInterface
template<Gaudi::IsInterface TARGET>
TARGET * cast ()
 
template<Gaudi::IsInterface TARGET>
TARGET const * cast () const
 
template<typename TARGET>
requires ( !Gaudi::IsInterface<TARGET> )
TARGET * cast ()
 
template<typename TARGET>
requires ( !Gaudi::IsInterface<TARGET> )
TARGET const * cast () const
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces.
 
virtual unsigned long addRef () const =0
 Increment the reference count of Interface instance.
 
virtual unsigned long release () const =0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance.
 
virtual ~IInterface ()=default
 Virtual destructor.
 
virtual void const * i_cast (const InterfaceID &) const =0
 
void * i_cast (const InterfaceID &iid)
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Member Functions inherited from IInterface
virtual unsigned long decRef () const =0
 Decrement reference count and return the new reference count.
 

Detailed Description

The interface implemented by the IToolSvc base class.

Author
G.Corti

Definition at line 28 of file IToolSvc.h.

Member Typedef Documentation

◆ ListTools

typedef std::list<IAlgTool*> IToolSvc::ListTools

Definition at line 34 of file IToolSvc.h.

Member Function Documentation

◆ DeclareInterfaceID()

IToolSvc::DeclareInterfaceID ( IToolSvc ,
2 ,
1  )

◆ getInstances() [1/2]

virtual std::vector< std::string > IToolSvc::getInstances ( ) const
pure virtual

Get the names all tool instances.

◆ getInstances() [2/2]

virtual std::vector< std::string > IToolSvc::getInstances ( std::string_view toolType)
pure virtual

Get the names of all instances of tools of a given type.

Parameters
toolTypetype of tool

◆ getTools()

virtual std::vector< IAlgTool * > IToolSvc::getTools ( ) const
pure virtual

Get pointers to all tool instances.

◆ registerObserver()

virtual void IToolSvc::registerObserver ( Observer * obs)
pure virtual

◆ releaseTool()

virtual StatusCode IToolSvc::releaseTool ( IAlgTool * tool)
pure virtual

Release the tool.

Parameters
toolto be released

◆ retrieve() [1/2]

virtual StatusCode IToolSvc::retrieve ( std::string_view type,
const InterfaceID & iid,
IAlgTool *& tool,
const IInterface * parent = 0,
bool createIf = true )
pure virtual

Retrieve tool with tool dependent part of the name automatically assigned.

By default a tool will be created if it does not exist, unless otherwise specified. By default it will be a common tool unless a parent is specified. The parent of a common tool is automatically taken as the ToolSvc itself.

Parameters
typeAlgTool type name
iidthe unique interface identifier
toolreturned tool
parentconstant reference to the parent (def=none)
createIfcreation flag (def=create if not existing)

◆ retrieve() [2/2]

virtual StatusCode IToolSvc::retrieve ( std::string_view type,
std::string_view name,
const InterfaceID & iid,
IAlgTool *& tool,
const IInterface * parent = 0,
bool createIf = true )
pure virtual

Retrieve tool with tool dependent part of the name specified by the requester.

By default a tool will be created if it does not exist, unless otherwise specified. By default it will be a common tool unless a parent is specified. The parent of a common tool is automatically taken as the ToolSvc itself.

Parameters
typeAlgTool type name
namename to be assigned to tool dependent part of the name
iidthe unique interface identifier
toolreturned tool
parentconstant reference to parent (def=none)
createIfcreation flag (def=create if not existing)

◆ retrieveTool() [1/2]

template<class T>
StatusCode IToolSvc::retrieveTool ( std::string_view type,
std::string_view name,
T *& tool,
const IInterface * parent = nullptr,
bool createIf = true )
inline

Retrieve specified tool sub-type with tool dependent part of the name tool dependent part of the name specified by the requester.

Internally it uses the corresponding IToolSvc::retrieve and does the dynamic casting.

IToolSvc* svc = ... ;
IMyTool* tool = 0 ;
StatusCode sc = svc->retrieveTool ( "MyToolType" ,
"MyToolName" , tool ) ;
Example of an Interface of a Algorithm Tool.
Definition IMyTool.h:21
The interface implemented by the IToolSvc base class.
Definition IToolSvc.h:28
StatusCode retrieveTool(std::string_view 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:147
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64

For this example public tool of type 'MyToolType' will be retrieved from Tool Service (created on demand). The full name of the tool instance is set to be ToolSvc.MyToolName

IToolSvc* svc = ... ;
IAlgorithm* alg = ... ;
IMyTool* tool = 0 ;
StatusCode sc = svc->retrieveTool ( "MyToolType" ,
"MyToolName" , tool , alg ) ;
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:36

For this example the private tool of type 'MyToolType' will be retrieved from Tool Service (created on demand). The full name of the tool instance is set to be <AlgName>.MyToolName , where <AlgName> is a name of the algorithm.

If name is empty ("") it is assumed to be equal to the type

Parameters
typeAlgTool type name
namename to be assigned to tool dependent part of the name
toolreturned tool
parentconstant reference to parent (def=none)
createIfcreation flag (def=create if not existing)

Definition at line 195 of file IToolSvc.h.

196 {
197 return retrieve( type, name, T::interfaceID(), (IAlgTool*&)tool, parent, createIf );
198 }
virtual StatusCode retrieve(std::string_view type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent=0, bool createIf=true)=0
Retrieve tool with tool dependent part of the name automatically assigned.

◆ retrieveTool() [2/2]

template<class T>
StatusCode IToolSvc::retrieveTool ( std::string_view type,
T *& tool,
const IInterface * parent = nullptr,
bool createIf = true )
inline

Retrieve specified tool sub-type with tool dependent part of the name automatically assigned.

Internally it uses the corresponding IToolSvc::retrieve and does the dynamic casting.

IToolSvc* svc = ... ;
IMyTool* tool = 0 ;
StatusCode sc = svc->retrieveTool ( "MyToolType" , tool ) ;

For this example public tool of type 'MyToolType' will be retrieved from Tool Service (created on demand). The full name of the tool instance is set to be ToolSvc.MyToolType

IToolSvc* svc = ... ;
IAlgorithm* alg = ... ;
IMyTool* tool = 0 ;
StatusCode sc = svc->retrieveTool ( "MyToolType" , tool , alg ) ;

For this example the private tool of type 'MyToolType' will be retrieved from Tool Service (created on demand). The full name of the tool instance is set to be <AlgName>.MyToolType , where <AlgName> is a name of the algorithm.

IToolSvc* svc = ... ;
IMyTool* tool = 0 ;
StatusCode sc = svc->retrieveTool ( "MyToolType/MyToolName" , tool ) ;

For this example public tool of type 'MyToolType' will be retrieved from Tool Service (created on demand). The full name of the tool instance is set to be ToolSvc.MyToolName

IToolSvc* svc = ... ;
IAlgorithm* alg = ... ;
IMyTool* tool = 0 ;
StatusCode sc = svc ->
retrieveTool ( "MyToolType/MyToolName" , tool , alg ) ;

For this example the private tool of type 'MyToolType' will be retrieved from Tool Service (created on demand). The full name of the tool instance is set to be <AlgName>.MyToolName , where <AlgName> is a name of the algorithm.

Parameters
toolreturned tool
parentconstant reference to parent (def=none)
createIfcreation flag (def=create if not existing)

Definition at line 147 of file IToolSvc.h.

147 {
148 return retrieve( type, T::interfaceID(), (IAlgTool*&)tool, parent, createIf );
149 }

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