ATLAS Offline Software
ToolHandle.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ASGTOOLS_TOOLHANDLE_H
6 #define ASGTOOLS_TOOLHANDLE_H
7 
8 // Local include(s):
9 #ifndef XAOD_STANDALONE
10 # include "GaudiKernel/ToolHandle.h"
11 #else // not XAOD_STANDALONE
12 
13 // System include(s):
14 #include <string>
15 #include <iosfwd>
16 
17 // Local include(s):
19 
20 class INamedInterface;
21 
33 class ToolHandleBase {
34 
35 public:
37  ToolHandleBase( const std::string& typeAndName = "", INamedInterface* parent = 0 );
38 
40  const std::string& typeAndName() const;
42  const std::string& type() const;
44  const std::string& name() const;
46  const std::string& parentName() const;
48  INamedInterface *parent() const noexcept;
49 
51  void setTypeAndName(const std::string& typeAndName);
53  void setName(const std::string& name);
54 
55 protected:
57  std::string m_typeAndName;
59  std::string m_type;
61  std::string m_name;
63  INamedInterface *m_parent;
64 
65 }; // class ToolHandleBase
66 
78 template< class T >
79 class ToolHandle : public ToolHandleBase {
80 
81 public:
83  typedef T value_type;
84 
86  ToolHandle( T* ptool = 0 );
87 
89  ToolHandle( const std::string& toolname, INamedInterface* parent = 0 );
90 
92  template<typename T2>
93  ToolHandle (T2 *parent, const std::string& propertyName,
94  const std::string& toolName,
95  const std::string& propertyTitle = "");
96 
98  T& operator*();
100  const T& operator*() const;
102  T* operator->();
104  const T* operator->() const;
105 
109  StatusCode retrieve() const;
110 
112  void disable () noexcept;
113 
115  bool empty() const;
116 
118  bool isSet() const;
119 
120 private:
122  mutable T* m_ptool {nullptr};
123 
124 }; // class ToolHandle
125 
127 template< class T >
128 std::ostream& operator<< ( std::ostream& out,
129  const ToolHandle< T >& handle );
130 
131 // Include the implementation of the code:
132 #include "AsgTools/ToolHandle.icc"
133 
134 #endif // not XAOD_STANDALONE
135 #endif // ASGTOOLS_TOOLHANDLE_H
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
taskman.template
dictionary template
Definition: taskman.py:317
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
ToolHandle.icc
protected
#define protected
Definition: DetDescrConditionsDict_dict_fixes.cxx:14
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
InDetDD::operator*
SiLocalPosition operator*(const SiLocalPosition &position, const double factor)
Definition: SiLocalPosition.cxx:98
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
test_pyathena.parent
parent
Definition: test_pyathena.py:15
StatusCode.h
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
python.hypoToolDisplay.toolname
def toolname(tool)
Definition: hypoToolDisplay.py:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
value_type
Definition: EDM_MasterSearch.h:11
python.TrigTLAMonitorAlgorithm.parentName
parentName
Definition: TrigTLAMonitorAlgorithm.py:192
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35