IToolSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_ITOOLSVC_H
2 #define GAUDIKERNEL_ITOOLSVC_H
3 
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:
22 
23  // Typedefs
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>
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>
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
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:18
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:244
#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
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
std::list< IAlgTool * > ListTools
Definition: IToolSvc.h:24
STL class.
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:247
Interface ID class.
Definition: IInterface.h:30
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
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
STL class.
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:248
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:237
#define GAUDI_API
Definition: Kernel.h:107