| The Gaudi Framework v32r1 (f65d50dc)

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 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
94 IHistorySvc* m_pHistorySvc = nullptr;
95
96 std::vector<IToolSvc::Observer*> m_observers;
97
98 typedef std::recursive_mutex CallMutex;
99 mutable CallMutex m_mut;
100 };
101
102 #endif
ToolSvc::m_pHistorySvc
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:94
ToolSvc::getInstances
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:327
ToolSvc::releaseTool
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:344
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:563
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:221
ToolSvc::create
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:374
ToolSvc::registerObserver
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:638
ToolSvc::minimumToolRefCount
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:628
ToolSvc::m_observers
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:96
IToolSvc.h
ToolSvc::initialize
StatusCode initialize() override
Initialize the service.
Definition: ToolSvc.cpp:52
ToolSvc
This service manages tools.
Definition: ToolSvc.h:24
ToolSvc::CallMutex
std::recursive_mutex CallMutex
Definition: ToolSvc.h:98
std::string
STL class.
ToolSvc::start
StatusCode start() override
Definition: ToolSvc.cpp:652
Service.h
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
InterfaceID
Interface ID class.
Definition: IInterface.h:29
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
ToolSvc::~ToolSvc
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:46
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
gaudirun.type
type
Definition: gaudirun.py:142
gaudirun.toolname
toolname
Definition: gaudirun.py:417
std::recursive_mutex
ToolSvc::getTools
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:337
IHistorySvc.h
ToolSvc::existsTool
bool existsTool(const std::string &toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:582
ToolSvc::totalToolRefCount
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:622
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:91
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ToolSvc::finalize
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:73
ToolSvc::finalizeTool
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:592
ToolSvc::m_mut
CallMutex m_mut
Definition: ToolSvc.h:99
ToolSvc::stop
StatusCode stop() override
Definition: ToolSvc.cpp:676
IHistorySvc
Definition of the IHistorySvc interface class.
Definition: IHistorySvc.h:33
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:229