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 
8 // Forward declaration
9 class IAlgTool;
10 
17 class GAUDI_API IToolSvc: virtual public IInterface {
18 public:
21 
33  virtual StatusCode retrieve ( const std::string& type ,
34  const InterfaceID& iid ,
35  IAlgTool*& tool ,
36  const IInterface* parent = 0 ,
37  bool createIf = true ) = 0;
38 
51  virtual StatusCode retrieve ( const std::string& type ,
52  const std::string& name ,
53  const InterfaceID& iid ,
54  IAlgTool*& tool ,
55  const IInterface* parent = 0 ,
56  bool createIf = true ) = 0 ;
57 
61  virtual std::vector<std::string> getInstances( const std::string& toolType ) = 0;
62 
65  virtual std::vector<std::string> getInstances() const = 0;
66 
69  virtual std::vector<IAlgTool*> getTools() const = 0;
70 
74  virtual StatusCode releaseTool( IAlgTool* tool ) = 0;
75 
76 
140  template <class T>
141  StatusCode retrieveTool ( const std::string& type ,
142  T*& tool ,
143  const IInterface* parent = 0 ,
144  bool createIf = true )
145  {
146  return retrieve( type,
147  T::interfaceID(),
148  (IAlgTool*&)tool,
149  parent,
150  createIf );
151  }
152 
196  template <class T>
197  StatusCode retrieveTool ( const std::string& type ,
198  const std::string& name ,
199  T*& tool ,
200  const IInterface* parent = 0 ,
201  bool createIf = true )
202  {
203  return retrieve ( type,
204  name,
205  T::interfaceID(),
206  (IAlgTool*&)tool,
207  parent,
208  createIf );
209  }
210 
240  class Observer {
241  public:
242  virtual ~Observer() {}
243  virtual void onCreate(const IAlgTool*) {}
244  virtual void onRetrieve(const IAlgTool*) {}
245  };
246 
247  virtual void registerObserver(Observer *obs) = 0;
248  virtual void unRegisterObserver(Observer *obs) = 0;
249 
250 
251 };
252 
253 
254 #endif // GAUDIKERNEL_ITOOLSVC_H
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:17
virtual ~Observer()
Definition: IToolSvc.h:242
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:240
StatusCode retrieveTool(const std::string &type, const std::string &name, T *&tool, const IInterface *parent=0, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name tool dependent part of the name...
Definition: IToolSvc.h:197
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:164
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:243
Interface ID class.
Definition: IInterface.h:55
string type
Definition: gaudirun.py:127
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
#define DeclareInterfaceID(name, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:23
virtual void onRetrieve(const IAlgTool *)
Definition: IToolSvc.h:244
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
#define GAUDI_API
Definition: Kernel.h:108
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=0, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned...
Definition: IToolSvc.h:141