The Gaudi Framework  v36r16 (ea80daf8)
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 <mutex>
19 #include <vector>
20 
34 class ToolSvc : public extends<Service, IToolSvc> {
35 
36 public:
38  using extends::extends;
39 
41  ~ToolSvc() override;
42 
44  StatusCode finalize() override;
45 
46  // Start transition for tools
47  StatusCode start() override;
48 
49  // Stop transition for tools
50  StatusCode stop() override;
51 
53  StatusCode retrieve( std::string_view type, const InterfaceID& iid, IAlgTool*& tool, const IInterface* parent,
54  bool createIf ) override;
55 
57  StatusCode retrieve( std::string_view tooltype, std::string_view toolname, const InterfaceID& iid, IAlgTool*& tool,
58  const IInterface* parent, bool createIf ) override;
59 
61  std::vector<std::string> getInstances( std::string_view toolType ) override;
62 
64  std::vector<std::string> getInstances() const override;
65 
67  std::vector<IAlgTool*> getTools() const override;
68 
70  StatusCode releaseTool( IAlgTool* tool ) override;
71 
73  StatusCode create( const std::string& type, const IInterface* parent, IAlgTool*& tool );
74 
76  StatusCode create( const std::string& type, const std::string& name, const IInterface* parent, IAlgTool*& tool );
77 
79  bool existsTool( std::string_view toolname ) const;
80 
82  std::string nameTool( std::string_view nameByUser, const IInterface* parent );
83 
84  void registerObserver( IToolSvc::Observer* obs ) override;
85 
86 private: // methods
87  // helper functions
88  //
90  unsigned long totalToolRefCount() const;
92  unsigned long minimumToolRefCount() const;
93 
95  StatusCode finalizeTool( IAlgTool* itool ) const;
96 
97 private: // data
99  this, "CheckedNamedToolsConfigured", false,
100  "Check that tools which do not have the default name have some explicit configuration." };
101 
102  Gaudi::Property<bool> m_showToolDataDeps{ this, "ShowDataDeps", false, "show the data dependencies of AlgTools" };
103 
105  std::vector<IAlgTool*> m_instancesTools; // List of all instances of tools
106 
109 
111 
113  mutable CallMutex m_mut;
114 };
115 
116 #endif
ToolSvc::m_observers
std::vector< IToolSvc::Observer * > m_observers
Definition: ToolSvc.h:110
ToolSvc::finalize
StatusCode finalize() override
Finalize the service.
Definition: ToolSvc.cpp:63
ToolSvc::m_instancesTools
std::vector< IAlgTool * > m_instancesTools
Common Tools.
Definition: ToolSvc.h:105
ToolSvc::finalizeTool
StatusCode finalizeTool(IAlgTool *itool) const
Finalize the given tool, with exception handling.
Definition: ToolSvc.cpp:596
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:567
ToolSvc::getInstances
std::vector< std::string > getInstances() const override
Get names of all tool instances.
Definition: ToolSvc.cpp:319
std::vector< std::string >
std::recursive_mutex
STL class.
ToolSvc::existsTool
bool existsTool(std::string_view toolname) const
Check if the tool instance exists.
Definition: ToolSvc.cpp:586
ToolSvc::getTools
std::vector< IAlgTool * > getTools() const override
Get pointers to all tool instances.
Definition: ToolSvc.cpp:329
ToolSvc
Definition: ToolSvc.h:34
IToolSvc.h
ToolSvc::stop
StatusCode stop() override
Definition: ToolSvc.cpp:698
ToolSvc::releaseTool
StatusCode releaseTool(IAlgTool *tool) override
Release tool.
Definition: ToolSvc.cpp:336
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:108
ToolSvc::m_checkNamedToolsConfigured
Gaudi::Property< bool > m_checkNamedToolsConfigured
Definition: ToolSvc.h:98
ToolSvc::registerObserver
void registerObserver(IToolSvc::Observer *obs) override
Definition: ToolSvc.cpp:642
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:112
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:366
gaudirun.type
type
Definition: gaudirun.py:162
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:219
gaudirun.toolname
toolname
Definition: gaudirun.py:456
IInterface
Definition: IInterface.h:237
ToolSvc::minimumToolRefCount
unsigned long minimumToolRefCount() const
The minimum number of refCounts of all tools.
Definition: ToolSvc.cpp:632
ToolSvc::start
StatusCode start() override
Definition: ToolSvc.cpp:656
InterfaceID
Definition: IInterface.h:39
ToolSvc::m_showToolDataDeps
Gaudi::Property< bool > m_showToolDataDeps
Definition: ToolSvc.h:102
ToolSvc::totalToolRefCount
unsigned long totalToolRefCount() const
The total number of refCounts on all tools in the instancesTools list.
Definition: ToolSvc.cpp:626
Gaudi::Property< bool >
ToolSvc::~ToolSvc
~ToolSvc() override
Destructor.
Definition: ToolSvc.cpp:56
ToolSvc::m_mut
CallMutex m_mut
Definition: ToolSvc.h:113