ToolSvc.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_TOOLSVC_H
2 #define GAUDISVC_TOOLSVC_H
3 
4 // Include Files
5 #include "GaudiKernel/Service.h"
6 #include "GaudiKernel/IToolSvc.h"
7 #include <vector>
8 
22 class ToolSvc : public extends1<Service, IToolSvc> {
23 
24 public:
25 
27  StatusCode initialize() override;
28 
30  StatusCode finalize() override;
31 
32  // Start transition for tools
33  StatusCode start() override;
34 
35  // Stop transition for tools
36  StatusCode stop() override;
37 
39  StatusCode retrieve(const std::string& type, const InterfaceID& iid,
40  IAlgTool*& tool, const IInterface* parent,
41  bool createIf) override;
42 
44  StatusCode retrieve(const std::string& tooltype, const std::string& toolname,
45  const InterfaceID& iid, IAlgTool*& tool,
46  const IInterface* parent, bool createIf) override;
47 
49  std::vector<std::string> getInstances( const std::string& toolType ) override;
50 
52  std::vector<std::string> getInstances() const override;
53 
55  std::vector<IAlgTool*> getTools() const override;
56 
58  StatusCode releaseTool( IAlgTool* tool ) override;
59 
61  StatusCode create(const std::string& type, const IInterface* parent,
62  IAlgTool*& tool);
63 
65  StatusCode create(const std::string& type, const std::string& name,
66  const IInterface* parent, IAlgTool*& tool);
67 
69  bool existsTool( const std::string& toolname) const;
70 
72  std::string nameTool(const std::string& nameByUser, const IInterface* parent);
73 
78  ToolSvc( const std::string& name, ISvcLocator* svc );
79 
81  ~ToolSvc() override = default;
82 
83  void registerObserver(IToolSvc::Observer *obs) override;
84  void unRegisterObserver(IToolSvc::Observer *obs) override;
85 
86 
87 private: // methods
88  // helper functions
89  //
91  unsigned long totalToolRefCount() const;
93  unsigned long minimumToolRefCount() const;
94 
96  StatusCode finalizeTool( IAlgTool* itool ) const;
97 
98 private: // data
99 
101  std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
102 
105 
106  std::vector<IToolSvc::Observer*> m_observers;
107 };
108 
109 #endif
110 
111 
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:104
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:358
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:373
void unRegisterObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:698
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:602
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:682
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:406
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:692
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:106
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:626
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:52
This service manages tools.
Definition: ToolSvc.h:22
StatusCode start() override
Definition: ToolSvc.cpp:705
Interface ID class.
Definition: IInterface.h:30
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:676
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:635
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:367
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:101
ToolSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ToolSvc.cpp:47
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:22
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:74
StatusCode stop() override
Definition: ToolSvc.cpp:733
~ToolSvc() override=default
Destructor.
tuple toolname
Definition: gaudirun.py:328
string type
Definition: gaudirun.py:151
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:32
StatusCode retrieve(const std::string &type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent, bool createIf) override
Retrieve tool, create it by default as common tool if it does not already exist.
Definition: ToolSvc.cpp:247