Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ToolSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDISVC_TOOLSVC_H
12 #define GAUDISVC_TOOLSVC_H
13 
14 // Include Files
16 #include "GaudiKernel/IToolSvc.h"
17 #include "GaudiKernel/Service.h"
18 #include <map>
19 #include <mutex>
20 #include <vector>
21 
35 class ToolSvc : public extends<Service, IToolSvc> {
36 
37 public:
39  using extends::extends;
40 
42  ~ToolSvc() override;
43 
45  StatusCode finalize() override;
46 
47  // Start transition for tools
48  StatusCode start() override;
49 
50  // Stop transition for tools
51  StatusCode stop() override;
52 
54  StatusCode retrieve( std::string_view type, const InterfaceID& iid, IAlgTool*& tool, const IInterface* parent,
55  bool createIf ) override;
56 
58  StatusCode retrieve( std::string_view tooltype, std::string_view toolname, const InterfaceID& iid, IAlgTool*& tool,
59  const IInterface* parent, bool createIf ) override;
60 
62  std::vector<std::string> getInstances( std::string_view toolType ) override;
63 
65  std::vector<std::string> getInstances() const override;
66 
68  std::vector<IAlgTool*> getTools() const override;
69 
71  StatusCode releaseTool( IAlgTool* tool ) override;
72 
74  StatusCode create( const std::string& type, const IInterface* parent, IAlgTool*& tool );
75 
77  StatusCode create( const std::string& type, const std::string& name, const IInterface* parent, IAlgTool*& tool );
78 
80  bool existsTool( std::string_view fullname ) const;
81 
83  std::string nameTool( std::string_view nameByUser, const IInterface* parent );
84 
85  void registerObserver( IToolSvc::Observer* obs ) override;
86 
87 private: // methods
88  // helper functions
89  //
91  unsigned long totalToolRefCount() const;
93  unsigned long minimumToolRefCount() const;
94 
96  StatusCode finalizeTool( IAlgTool* itool ) const;
97 
98 private: // data
100  this, "CheckedNamedToolsConfigured", false,
101  "Check that tools which do not have the default name have some explicit configuration." };
102 
103  Gaudi::Property<bool> m_showToolDataDeps{ this, "ShowDataDeps", false, "show the data dependencies of AlgTools" };
104 
106  std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
108 
111 
113 
115  mutable CallMutex m_mut;
116 };
117 
118 #endif
ToolSvc::m_observers
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:112
ToolSvc::finalize
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:74
ToolSvc::m_instancesTools
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:106
ToolSvc::finalizeTool
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:613
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
ToolSvc::nameTool
std::string nameTool(std::string_view nameByUser, const IInterface *parent)
Get Tool full name by combining nameByUser and "parent" part.
Definition: ToolSvc.cpp:586
ToolSvc::getInstances
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:330
ToolSvc::existsTool
bool existsTool(std::string_view fullname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:605
ToolSvc::m_instancesToolsMap
std::unordered_multimap< std::string_view, IAlgTool * > m_instancesToolsMap
Definition: ToolSvc.h:107
std::vector< std::string >
std::recursive_mutex
STL class.
ToolSvc::getTools
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:340
ToolSvc
Definition: ToolSvc.h:35
std::unordered_multimap< std::string_view, IAlgTool * >
IToolSvc.h
ToolSvc::stop
StatusCode stop() override
Definition: ToolSvc.cpp:715
ToolSvc::releaseTool
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:347
bug_34121.tool
tool
Definition: bug_34121.py:17
IHistorySvc
Definition: IHistorySvc.h:43
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
ToolSvc::m_pHistorySvc
IHistorySvc * m_pHistorySvc
Pointer to HistorySvc.
Definition: ToolSvc.h:110
ToolSvc::m_checkNamedToolsConfigured
Gaudi::Property< bool > m_checkNamedToolsConfigured
Definition: ToolSvc.h:99
ToolSvc::registerObserver
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:659
IHistorySvc.h
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
IToolSvc::Observer
allow call-backs when a tool is a created or retrieved
Definition: IToolSvc.h:230
ToolSvc::CallMutex
std::recursive_mutex CallMutex
Definition: ToolSvc.h:114
Service.h
ToolSvc::create
StatusCode create(const std::string &type, const IInterface *parent, IAlgTool *&tool)
Create Tool standard way with automatically assigned name.
Definition: ToolSvc.cpp:378
gaudirun.type
type
Definition: gaudirun.py:160
ToolSvc::retrieve
StatusCode retrieve(std::string_view 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:230
gaudirun.toolname
toolname
Definition: gaudirun.py:454
IInterface
Definition: IInterface.h:237
ToolSvc::minimumToolRefCount
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:649
ToolSvc::start
StatusCode start() override
Definition: ToolSvc.cpp:673
InterfaceID
Definition: IInterface.h:39
ToolSvc::m_showToolDataDeps
Gaudi::Property< bool > m_showToolDataDeps
Definition: ToolSvc.h:103
ToolSvc::totalToolRefCount
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:643
Gaudi::Property< bool >
ToolSvc::~ToolSvc
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:67
ToolSvc::m_mut
CallMutex m_mut
Definition: ToolSvc.h:115