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 #include <mutex>
9 
23 class ToolSvc : public extends<Service,
24  IToolSvc> {
25 
26 public:
27 
29  StatusCode initialize() override;
30 
32  StatusCode finalize() override;
33 
34  // Start transition for tools
35  StatusCode start() override;
36 
37  // Stop transition for tools
38  StatusCode stop() override;
39 
41  StatusCode retrieve(const std::string& type, const InterfaceID& iid,
42  IAlgTool*& tool, const IInterface* parent,
43  bool createIf) override;
44 
46  StatusCode retrieve(const std::string& tooltype, const std::string& toolname,
47  const InterfaceID& iid, IAlgTool*& tool,
48  const IInterface* parent, bool createIf) override;
49 
51  std::vector<std::string> getInstances( const std::string& toolType ) override;
52 
54  std::vector<std::string> getInstances() const override;
55 
57  std::vector<IAlgTool*> getTools() const override;
58 
60  StatusCode releaseTool( IAlgTool* tool ) override;
61 
63  StatusCode create(const std::string& type, const IInterface* parent,
64  IAlgTool*& tool);
65 
67  StatusCode create(const std::string& type, const std::string& name,
68  const IInterface* parent, IAlgTool*& tool);
69 
71  bool existsTool( const std::string& toolname) const;
72 
74  std::string nameTool(const std::string& nameByUser, const IInterface* parent);
75 
80  ToolSvc( const std::string& name, ISvcLocator* svc );
81 
83  ~ToolSvc() override;
84 
85  void registerObserver(IToolSvc::Observer *obs) override;
86 
87 
88 private: // methods
89  // helper functions
90  //
92  unsigned long totalToolRefCount() const;
94  unsigned long minimumToolRefCount() const;
95 
97  StatusCode finalizeTool( IAlgTool* itool ) const;
98 
99 private: // data
100 
102  std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
103 
106 
108 
110  mutable CallMutex m_mut;
111 };
112 
113 #endif
114 
115 
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:105
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:390
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
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:245
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:719
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:423
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:372
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:730
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:107
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:662
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:61
This service manages tools.
Definition: ToolSvc.h:23
std::recursive_mutex CallMutex
Definition: ToolSvc.h:109
STL class.
StatusCode start() override
Definition: ToolSvc.cpp:746
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:713
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:672
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:52
Definition of the basic interface.
Definition: IInterface.h:234
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:102
ToolSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ToolSvc.cpp:48
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:83
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:382
CallMutex m_mut
Definition: ToolSvc.h:110
StatusCode stop() override
Definition: ToolSvc.cpp:772
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:256