All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
66  virtual StatusCode releaseTool( IAlgTool* tool ) = 0;
67 
68 
132  template <class T>
133  StatusCode retrieveTool ( const std::string& type ,
134  T*& tool ,
135  const IInterface* parent = 0 ,
136  bool createIf = true )
137  {
138  return retrieve( type,
139  T::interfaceID(),
140  (IAlgTool*&)tool,
141  parent,
142  createIf );
143  }
144 
188  template <class T>
189  StatusCode retrieveTool ( const std::string& type ,
190  const std::string& name ,
191  T*& tool ,
192  const IInterface* parent = 0 ,
193  bool createIf = true )
194  {
195  return retrieve ( type,
196  name,
197  T::interfaceID(),
198  (IAlgTool*&)tool,
199  parent,
200  createIf );
201  }
202 
232  class Observer {
233  public:
234  virtual ~Observer() {}
235  virtual void onCreate(const IAlgTool*) {}
236  virtual void onRetrieve(const IAlgTool*) {}
237  };
238 
239  virtual void registerObserver(Observer *obs) = 0;
240  virtual void unRegisterObserver(Observer *obs) = 0;
241 
242 
243 };
244 
245 
246 #endif // GAUDIKERNEL_ITOOLSVC_H
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:17
virtual ~Observer()
Definition: IToolSvc.h:234
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:232
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:189
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:164
virtual void onCreate(const IAlgTool *)
Definition: IToolSvc.h:235
Interface ID class.
Definition: IInterface.h:55
string type
Definition: gaudirun.py:126
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:236
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:133