| The Gaudi Framework v28r2-patches (bc4ad17a)

- 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 #include <functional>
9
10 // Forward declaration
11 class IAlgTool;
12
19 class GAUDI_API IToolSvc: virtual public IInterface {
20 public:
22 DeclareInterfaceID(IToolSvc,2,1);
23
24 // Typedefs
25 typedef std::list<IAlgTool*> ListTools;
26
38 virtual StatusCode retrieve ( const std::string& type ,
39 const InterfaceID& iid ,
40 IAlgTool*& tool ,
41 const IInterface* parent = 0 ,
42 bool createIf = true ) = 0;
43
56 virtual StatusCode retrieve ( const std::string& type ,
57 const std::string& name ,
58 const InterfaceID& iid ,
59 IAlgTool*& tool ,
60 const IInterface* parent = 0 ,
61 bool createIf = true ) = 0 ;
62
66 virtual std::vector<std::string> getInstances( const std::string& toolType ) = 0;
67
70 virtual std::vector<std::string> getInstances() const = 0;
71
74 virtual std::vector<IAlgTool*> getTools() const = 0;
75
79 virtual StatusCode releaseTool( IAlgTool* tool ) = 0;
80
81
145 template <class T>
146 StatusCode retrieveTool ( const std::string& type ,
147 T*& tool ,
148 const IInterface* parent = nullptr,
149 bool createIf = true )
150 {
151 return retrieve( type,
152 T::interfaceID(),
153 (IAlgTool*&)tool,
154 parent,
155 createIf );
156 }
157
201 template <class T>
202 StatusCode retrieveTool ( const std::string& type ,
203 const std::string& name ,
204 T*& tool ,
205 const IInterface* parent = nullptr ,
206 bool createIf = true )
207 {
208 return retrieve ( type,
209 name,
210 T::interfaceID(),
211 (IAlgTool*&)tool,
212 parent,
213 createIf );
214 }
215
245 class Observer {
246 public:
247 virtual ~Observer() { if (m_unregister) m_unregister(); }
248 void setUnregister(std::function<void()> unregister) { m_unregister=std::move(unregister); }
249
250 virtual void onCreate(const IAlgTool*) {}
251 virtual void onRetrieve(const IAlgTool*) {}
252 private:
253 std::function<void()> m_unregister;
254 };
255
256 virtual void registerObserver(Observer *obs) = 0;
257
258 };
259
260
261 #endif // GAUDIKERNEL_ITOOLSVC_H
System.h
IToolSvc
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:19
IToolSvc::Observer::~Observer
virtual ~Observer()
Definition: IToolSvc.h:247
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
std::function
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:245
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
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:146
IToolSvc::ListTools
std::list< IAlgTool * > ListTools
Definition: IToolSvc.h:25
std::string
STL class.
IToolSvc::Observer::onCreate
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:250
InterfaceID
Interface ID class.
Definition: IInterface.h:30
IToolSvc::Observer::m_unregister
std::function< void()> m_unregister
Definition: IToolSvc.h:253
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
gaudirun.type
type
Definition: gaudirun.py:125
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:202
std::list
STL class.
std::move
T move(T...args)
IToolSvc::Observer::setUnregister
void setUnregister(std::function< void()> unregister)
Definition: IToolSvc.h:248
std::vector< std::string >
IToolSvc::Observer::onRetrieve
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:251
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