The Gaudi Framework  v30r3 (a5ef0a68)
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 
27 public:
29  using extends::extends;
30 
32  ~ToolSvc() override;
34  StatusCode initialize() override;
35 
37  StatusCode finalize() override;
38 
39  // Start transition for tools
40  StatusCode start() override;
41 
42  // Stop transition for tools
43  StatusCode stop() override;
44 
46  StatusCode retrieve( const std::string& type, const InterfaceID& iid, IAlgTool*& tool, const IInterface* parent,
47  bool createIf ) override;
48 
50  StatusCode retrieve( const std::string& tooltype, const std::string& toolname, const InterfaceID& iid,
51  IAlgTool*& tool, const IInterface* parent, bool createIf ) override;
52 
54  std::vector<std::string> getInstances( const std::string& toolType ) override;
55 
57  std::vector<std::string> getInstances() const override;
58 
60  std::vector<IAlgTool*> getTools() const override;
61 
63  StatusCode releaseTool( IAlgTool* tool ) override;
64 
66  StatusCode create( const std::string& type, const IInterface* parent, IAlgTool*& tool );
67 
69  StatusCode create( const std::string& type, const std::string& name, const IInterface* parent, IAlgTool*& tool );
70 
72  bool existsTool( const std::string& toolname ) const;
73 
75  std::string nameTool( const std::string& nameByUser, const IInterface* parent );
76 
77  void registerObserver( IToolSvc::Observer* obs ) override;
78 
79 private: // methods
80  // helper functions
81  //
83  unsigned long totalToolRefCount() const;
85  unsigned long minimumToolRefCount() const;
86 
88  StatusCode finalizeTool( IAlgTool* itool ) const;
89 
90 private: // data
92  std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
93 
96 
98 
100  mutable CallMutex m_mut;
101 };
102 
103 #endif
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:95
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:360
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:585
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:223
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:652
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:390
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:343
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:662
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:97
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:606
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:55
This service manages tools.
Definition: ToolSvc.h:24
std::recursive_mutex CallMutex
Definition: ToolSvc.h:99
STL class.
StatusCode start() override
Definition: ToolSvc.cpp:677
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:646
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:616
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:48
Definition of the basic interface.
Definition: IInterface.h:277
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:92
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:76
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:353
CallMutex m_mut
Definition: ToolSvc.h:100
StatusCode stop() override
Definition: ToolSvc.cpp:701
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:31
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:241