Loading [MathJax]/jax/input/TeX/config.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ToolSvc.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_TOOLSVC_H
2 #define GAUDISVC_TOOLSVC_H
3 
4 // Include Files
6 #include "GaudiKernel/IToolSvc.h"
7 #include "GaudiKernel/Service.h"
8 #include <mutex>
9 #include <vector>
10 
24 class ToolSvc : public extends<Service, IToolSvc> {
25 
26 public:
28  using extends::extends;
29 
31  ~ToolSvc() override;
33  StatusCode initialize() override;
34 
36  StatusCode finalize() override;
37 
38  // Start transition for tools
39  StatusCode start() override;
40 
41  // Stop transition for tools
42  StatusCode stop() override;
43 
45  StatusCode retrieve( const std::string& type, const InterfaceID& iid, IAlgTool*& tool, const IInterface* parent,
46  bool createIf ) override;
47 
49  StatusCode retrieve( const std::string& tooltype, const std::string& toolname, const InterfaceID& iid,
50  IAlgTool*& tool, const IInterface* parent, bool createIf ) override;
51 
53  std::vector<std::string> getInstances( const std::string& toolType ) override;
54 
56  std::vector<std::string> getInstances() const override;
57 
59  std::vector<IAlgTool*> getTools() const override;
60 
62  StatusCode releaseTool( IAlgTool* tool ) override;
63 
65  StatusCode create( const std::string& type, const IInterface* parent, IAlgTool*& tool );
66 
68  StatusCode create( const std::string& type, const std::string& name, 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 
76  void registerObserver( IToolSvc::Observer* obs ) override;
77 
78 private: // methods
79  // helper functions
80  //
82  unsigned long totalToolRefCount() const;
84  unsigned long minimumToolRefCount() const;
85 
87  StatusCode finalizeTool( IAlgTool* itool ) const;
88 
89 private: // data
91  std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
92 
95 
97 
99  mutable CallMutex m_mut;
100 };
101 
102 #endif
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:94
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:344
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:563
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:221
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:628
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:374
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:327
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:638
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:96
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:582
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:52
This service manages tools.
Definition: ToolSvc.h:24
std::recursive_mutex CallMutex
Definition: ToolSvc.h:98
STL class.
StatusCode start() override
Definition: ToolSvc.cpp:652
Interface ID class.
Definition: IInterface.h:29
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:622
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:592
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:46
Definition of the basic interface.
Definition: IInterface.h:244
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:91
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:73
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:337
CallMutex m_mut
Definition: ToolSvc.h:99
StatusCode stop() override
Definition: ToolSvc.cpp:676
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:33
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:229