| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 = default;
84
85 void registerObserver(IToolSvc::Observer *obs) override;
86 void unRegisterObserver(IToolSvc::Observer *obs) override;
87
88
89 private: // methods
90 // helper functions
91 //
93 unsigned long totalToolRefCount() const;
95 unsigned long minimumToolRefCount() const;
96
98 StatusCode finalizeTool( IAlgTool* itool ) const;
99
100 private: // data
101
103 std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
104
106 IHistorySvc* m_pHistorySvc = nullptr;
107
108 std::vector<IToolSvc::Observer*> m_observers;
109
110 typedef std::recursive_mutex CallMutex;
111 mutable CallMutex m_mut;
112 };
113
114 #endif
115
116
ToolSvc::m_pHistorySvc
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:106
ToolSvc::getInstances
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:363
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
ToolSvc::releaseTool
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:381
ToolSvc::unRegisterObserver
void unRegisterObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:730
ToolSvc::nameTool
std::string nameTool(const std::string &nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:631
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:244
ToolSvc::minimumToolRefCount
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:710
ToolSvc::create
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:414
ToolSvc::registerObserver
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:721
gaudirun.toolname
tuple toolname
Definition: gaudirun.py:327
ToolSvc::m_observers
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:108
IToolSvc.h
ToolSvc::existsTool
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:653
ToolSvc::initialize
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:52
ToolSvc
This service manages tools.
Definition: ToolSvc.h:23
ToolSvc::CallMutex
std::recursive_mutex CallMutex
Definition: ToolSvc.h:110
std::string
STL class.
ToolSvc::start
StatusCode start() override
Definition: ToolSvc.cpp:738
Service.h
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
InterfaceID
Interface ID class.
Definition: IInterface.h:30
ToolSvc::totalToolRefCount
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:704
ToolSvc::finalizeTool
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:663
gaudirun.type
string type
Definition: gaudirun.py:151
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
std::recursive_mutex
ToolSvc::getTools
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:373
std::vector< std::string >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
ToolSvc::m_instancesTools
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:103
ToolSvc::ToolSvc
ToolSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ToolSvc.cpp:47
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ToolSvc::finalize
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:74
ToolSvc::m_mut
CallMutex m_mut
Definition: ToolSvc.h:111
ToolSvc::stop
StatusCode stop() override
Definition: ToolSvc.cpp:764
ToolSvc::~ToolSvc
~ToolSvc() override=default
Destructor.
IHistorySvc
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:32
ToolSvc::retrieve
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