| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

IToolSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ITOOLSVC_H
2 #define GAUDIKERNEL_ITOOLSVC_H
3
4 #include "GaudiKernel/IInterface.h"
5 #include "GaudiKernel/System.h"
6 #include <string>
7 #include <list>
8
9 // Forward declaration
10 class IAlgTool;
11
18 class GAUDI_API IToolSvc: virtual public IInterface {
19 public:
21 DeclareInterfaceID(IToolSvc,2,1);
22
23 // Typedefs
24 typedef std::list<IAlgTool*> ListTools;
25
37 virtual StatusCode retrieve ( const std::string& type ,
38 const InterfaceID& iid ,
39 IAlgTool*& tool ,
40 const IInterface* parent = 0 ,
41 bool createIf = true ) = 0;
42
55 virtual StatusCode retrieve ( const std::string& type ,
56 const std::string& name ,
57 const InterfaceID& iid ,
58 IAlgTool*& tool ,
59 const IInterface* parent = 0 ,
60 bool createIf = true ) = 0 ;
61
65 virtual std::vector<std::string> getInstances( const std::string& toolType ) = 0;
66
69 virtual std::vector<std::string> getInstances() const = 0;
70
73 virtual std::vector<IAlgTool*> getTools() const = 0;
74
78 virtual StatusCode releaseTool( IAlgTool* tool ) = 0;
79
80
144 template <class T>
145 StatusCode retrieveTool ( const std::string& type ,
146 T*& tool ,
147 const IInterface* parent = nullptr,
148 bool createIf = true )
149 {
150 return retrieve( type,
151 T::interfaceID(),
152 (IAlgTool*&)tool,
153 parent,
154 createIf );
155 }
156
200 template <class T>
201 StatusCode retrieveTool ( const std::string& type ,
202 const std::string& name ,
203 T*& tool ,
204 const IInterface* parent = nullptr ,
205 bool createIf = true )
206 {
207 return retrieve ( type,
208 name,
209 T::interfaceID(),
210 (IAlgTool*&)tool,
211 parent,
212 createIf );
213 }
214
244 class Observer {
245 public:
246 virtual ~Observer() = default;
247 virtual void onCreate(const IAlgTool*) {}
248 virtual void onRetrieve(const IAlgTool*) {}
249 };
250
251 virtual void registerObserver(Observer *obs) = 0;
252 virtual void unRegisterObserver(Observer *obs) = 0;
253
254 };
255
256
257 #endif // GAUDIKERNEL_ITOOLSVC_H
System.h
IToolSvc
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:18
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:244
IToolSvc::retrieveTool
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
IToolSvc::ListTools
std::list< IAlgTool * > ListTools
Definition: IToolSvc.h:24
std::string
STL class.
IToolSvc::Observer::onCreate
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:247
InterfaceID
Interface ID class.
Definition: IInterface.h:30
gaudirun.type
string type
Definition: gaudirun.py:151
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
IToolSvc::retrieveTool
StatusCode retrieveTool(const std::string &type, const std::string &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...
Definition: IToolSvc.h:201
std::list
STL class.
DeclareInterfaceID
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:14
std::vector< std::string >
IToolSvc::Observer::onRetrieve
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:248
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
IInterface::iid
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:237
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
IInterface.h