| The Gaudi Framework v29r1 (5cd95fa2)

- 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 <functional>
7 #include <list>
8 #include <string>
9
10 // Forward declaration
11 class IAlgTool;
12
19 class GAUDI_API IToolSvc : virtual public IInterface
20 {
21 public:
23 DeclareInterfaceID( IToolSvc, 2, 1 );
24
25 // Typedefs
26 typedef std::list<IAlgTool*> ListTools;
27
39 virtual StatusCode retrieve( const std::string& type, const InterfaceID& iid, IAlgTool*& tool,
40 const IInterface* parent = 0, bool createIf = true ) = 0;
41
54 virtual StatusCode retrieve( const std::string& type, const std::string& name, const InterfaceID& iid,
55 IAlgTool*& tool, const IInterface* parent = 0, bool createIf = true ) = 0;
56
60 virtual std::vector<std::string> getInstances( const std::string& toolType ) = 0;
61
64 virtual std::vector<std::string> getInstances() const = 0;
65
68 virtual std::vector<IAlgTool*> getTools() const = 0;
69
73 virtual StatusCode releaseTool( IAlgTool* tool ) = 0;
74
138 template <class T>
139 StatusCode retrieveTool( const std::string& type, T*& tool, const IInterface* parent = nullptr, bool createIf = true )
140 {
141 return retrieve( type, T::interfaceID(), (IAlgTool*&)tool, parent, createIf );
142 }
143
187 template <class T>
188 StatusCode retrieveTool( const std::string& type, const std::string& name, T*& tool,
189 const IInterface* parent = nullptr, bool createIf = true )
190 {
191 return retrieve( type, name, T::interfaceID(), (IAlgTool*&)tool, parent, createIf );
192 }
193
223 class Observer
224 {
225 public:
226 virtual ~Observer()
227 {
228 if ( m_unregister ) m_unregister();
229 }
230 void setUnregister( std::function<void()> unregister ) { m_unregister = std::move( unregister ); }
231
232 virtual void onCreate( const IAlgTool* ) {}
233 virtual void onRetrieve( const IAlgTool* ) {}
234
235 private:
236 std::function<void()> m_unregister;
237 };
238
239 virtual void registerObserver( Observer* obs ) = 0;
240 };
241
242 #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:226
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
std::function
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:223
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:139
IToolSvc::ListTools
std::list< IAlgTool * > ListTools
Definition: IToolSvc.h:26
std::string
STL class.
IToolSvc::Observer::onCreate
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:232
InterfaceID
Interface ID class.
Definition: IInterface.h:29
IToolSvc::Observer::m_unregister
std::function< void()> m_unregister
Definition: IToolSvc.h:236
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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:13
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
gaudirun.type
type
Definition: gaudirun.py:133
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:188
std::list
STL class.
std::move
T move(T...args)
IToolSvc::Observer::setUnregister
void setUnregister(std::function< void()> unregister)
Definition: IToolSvc.h:230
std::vector< std::string >
IToolSvc::Observer::onRetrieve
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:233
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
IInterface.h
IInterface::iid
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:281