| The Gaudi Framework v29r0 (ff2e7097)

- 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/IHistorySvc.h"
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 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, IAlgTool*& tool, const IInterface* parent,
42 bool createIf ) override;
43
45 StatusCode retrieve( const std::string& tooltype, const std::string& toolname, const InterfaceID& iid,
46 IAlgTool*& tool, 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, IAlgTool*& tool );
62
64 StatusCode create( const std::string& type, const std::string& name, const IInterface* parent, IAlgTool*& tool );
65
67 bool existsTool( const std::string& toolname ) const;
68
70 std::string nameTool( const std::string& nameByUser, const IInterface* parent );
71
76 ToolSvc( const std::string& name, ISvcLocator* svc );
77
79 ~ToolSvc() override;
80
81 void registerObserver( IToolSvc::Observer* obs ) override;
82
83 private: // methods
84 // helper functions
85 //
87 unsigned long totalToolRefCount() const;
89 unsigned long minimumToolRefCount() const;
90
92 StatusCode finalizeTool( IAlgTool* itool ) const;
93
94 private: // data
96 std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
97
99 IHistorySvc* m_pHistorySvc = nullptr;
100
101 std::vector<IToolSvc::Observer*> m_observers;
102
103 typedef std::recursive_mutex CallMutex;
104 mutable CallMutex m_mut;
105 };
106
107 #endif
ToolSvc::m_pHistorySvc
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:99
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:366
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
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:591
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:223
ToolSvc::minimumToolRefCount
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:658
ToolSvc::create
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:396
ToolSvc::getInstances
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:349
ToolSvc::registerObserver
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:668
ToolSvc::m_observers
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:101
IToolSvc.h
ToolSvc::existsTool
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:612
ToolSvc::initialize
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:61
ToolSvc
This service manages tools.
Definition: ToolSvc.h:24
ToolSvc::CallMutex
std::recursive_mutex CallMutex
Definition: ToolSvc.h:103
std::string
STL class.
ToolSvc::start
StatusCode start() override
Definition: ToolSvc.cpp:683
Service.h
InterfaceID
Interface ID class.
Definition: IInterface.h:29
ToolSvc::totalToolRefCount
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:652
ToolSvc::finalizeTool
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:622
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
ToolSvc::~ToolSvc
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:54
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
gaudirun.type
type
Definition: gaudirun.py:133
gaudirun.toolname
toolname
Definition: gaudirun.py:338
std::recursive_mutex
IHistorySvc.h
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:96
ToolSvc::ToolSvc
ToolSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ToolSvc.cpp:48
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ToolSvc::finalize
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:82
ToolSvc::getTools
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:359
ToolSvc::m_mut
CallMutex m_mut
Definition: ToolSvc.h:104
ToolSvc::stop
StatusCode stop() override
Definition: ToolSvc.cpp:707
IHistorySvc
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:31
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