ToolSvc.h
Go to the documentation of this file.
1 // $Id: ToolSvc.h,v 1.12 2008/06/02 14:21:35 marcocle Exp $
2 #ifndef GAUDISVC_TOOLSVC_H
3 #define GAUDISVC_TOOLSVC_H
4 
5 // Include Files
6 #include "GaudiKernel/Service.h"
7 #include "GaudiKernel/IToolSvc.h"
8 #include <vector>
9 
23 class ToolSvc : public extends1<Service, IToolSvc> {
24 
25 public:
26 
27  // Typedefs
28  typedef std::list<IAlgTool*> ListTools;
29 
31  virtual StatusCode initialize();
32 
34  virtual StatusCode finalize();
35 
36  // Start transition for tools
37  virtual StatusCode start();
38 
39  // Stop transition for tools
40  virtual StatusCode stop();
41 
43  virtual StatusCode retrieve(const std::string& type, const InterfaceID& iid,
44  IAlgTool*& tool, const IInterface* parent,
45  bool createIf);
46 
48  virtual StatusCode retrieve(const std::string& tooltype, const std::string& toolname,
49  const InterfaceID& iid, IAlgTool*& tool,
50  const IInterface* parent, bool createIf);
51 
53  virtual std::vector<std::string> getInstances( const std::string& toolType );
54 
56  virtual std::vector<std::string> getInstances() const;
57 
59  virtual std::vector<IAlgTool*> getTools() const;
60 
62  virtual StatusCode releaseTool( IAlgTool* tool );
63 
65  StatusCode create(const std::string& type, const IInterface* parent,
66  IAlgTool*& tool);
67 
69  StatusCode create(const std::string& type, const std::string& name,
70  const IInterface* parent, IAlgTool*& tool);
71 
73  bool existsTool( const std::string& toolname) const;
74 
76  std::string nameTool(const std::string& nameByUser, const IInterface* parent);
77 
79  unsigned long refCountTool( IAlgTool* tool ) const { return tool->refCount(); }
80 
85  ToolSvc( const std::string& name, ISvcLocator* svc );
86 
88  virtual ~ToolSvc();
89 
90  virtual void registerObserver(IToolSvc::Observer *obs) ;
91  virtual void unRegisterObserver(IToolSvc::Observer *obs) ;
92 
93 
94 private: // methods
95 
96  // helper functions
97  //
99  unsigned long totalToolRefCount() const;
101  unsigned long totalToolRefCount( const ListTools& ) const;
103  unsigned long minimumToolRefCount() const;
104 
106  StatusCode finalizeTool( IAlgTool* itool ) const;
107 
108 private: // data
109 
111  ListTools m_instancesTools; // List of all instances of tools
112 
115 
116  std::vector<IToolSvc::Observer*> m_observers;
117 };
118 
119 #endif
120 
121 
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:114
virtual void unRegisterObserver(IToolSvc::Observer *obs)
Definition: ToolSvc.cpp:761
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
virtual ~ToolSvc()
Destructor.
Definition: ToolSvc.cpp:38
virtual StatusCode finalize()
Finalize the service.
Definition: ToolSvc.cpp:67
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:640
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:240
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:739
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:436
ListTools m_instancesTools
Common Tools.
Definition: ToolSvc.h:111
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:116
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:669
This service manages tools.
Definition: ToolSvc.h:23
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:164
virtual StatusCode releaseTool(IAlgTool *tool)
Release tool.
Definition: ToolSvc.cpp:402
Interface ID class.
Definition: IInterface.h:55
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:733
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:680
virtual StatusCode stop()
Stop (from RUNNING to INITIALIZED).
Definition: ToolSvc.cpp:798
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
virtual void registerObserver(IToolSvc::Observer *obs)
Definition: ToolSvc.cpp:755
virtual unsigned long refCount() const =0
Current number of reference counts.
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:329
virtual std::vector< std::string > getInstances() const
Get names of all tool instances.
Definition: ToolSvc.cpp:385
virtual StatusCode retrieve(const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent, bool createIf)
Retrieve tool, create it by default as common tool if it does not already exist.
Definition: ToolSvc.cpp:248
virtual StatusCode initialize()
Initialize the service.
Definition: ToolSvc.cpp:45
ToolSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ToolSvc.cpp:31
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
virtual StatusCode start()
Start (from INITIALIZED to RUNNING).
Definition: ToolSvc.cpp:769
std::list< IAlgTool * > ListTools
Definition: ToolSvc.h:28
virtual std::vector< IAlgTool * > getTools() const
Get pointers to all tool instances.
Definition: ToolSvc.cpp:395
tuple toolname
Definition: gaudirun.py:326
string type
Definition: gaudirun.py:151
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:34
unsigned long refCountTool(IAlgTool *tool) const
Get current refcount for tool.
Definition: ToolSvc.h:79