ATLAS Offline Software
ServiceHandle.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 
10 #ifndef ASGSERVICES_SERVICEHANDLE_H
11 #define ASGSERVICES_SERVICEHANDLE_H
12 
13 // Local include(s):
14 #ifndef XAOD_STANDALONE
15 # include "GaudiKernel/ServiceHandle.h"
16 #else // not XAOD_STANDALONE
17 
18 // System include(s):
19 #include <string>
20 #include <iosfwd>
21 
22 // Local include(s):
25 
33 
34 class ServiceHandleBase
35 {
36 public:
38  ServiceHandleBase( const std::string& typeAndName, const std::string& parentName );
39 
41  const std::string& typeAndName() const;
43  const std::string& type() const;
45  const std::string& name() const;
47  const std::string& parentName() const;
48 
50  void setTypeAndName(const std::string& typeAndName);
52  void setName(const std::string& name);
53 
54 protected:
56  std::string m_typeAndName;
58  std::string m_type;
60  std::string m_name;
62  std::string m_parentName;
63 
64 }; // class ServiceHandleBase
65 
72 
73 template< class T >
74 class ServiceHandle : public ServiceHandleBase
75 {
76 public:
78  typedef T value_type;
79 
81  ServiceHandle( const std::shared_ptr<T>& pservice,
82  const std::string& parentName );
83 
85  ServiceHandle( const std::string& servicename, const std::string& parentName);
86 
88  template<typename T2>
89  ServiceHandle (T2 *parent, const std::string& propertyName,
90  const std::string& serviceName,
91  const std::string& propertyTitle = "");
92 
94  T& operator*();
96  const T& operator*() const;
98  T* operator->();
100  const T* operator->() const;
101 
105  StatusCode retrieve() const;
106 
108  void disable () noexcept;
109 
111  bool empty() const;
112 
114  bool isSet() const;
115 
116 private:
118  mutable std::shared_ptr<T> m_pservice;
119 
120 }; // class ServiceHandle
121 
123 template< class T >
124 std::ostream& operator<< ( std::ostream& out,
125  const ServiceHandle< T >& handle );
126 
127 // Include the implementation of the code:
128 #include "AsgServices/ServiceHandle.icc"
129 
130 #endif // not XAOD_STANDALONE
131 #endif // ASGSERVICES_SERVICEHANDLE_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:560
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
ServiceStore.h
StatusCode.h
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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
ServiceHandle
Definition: ClusterMakerTool.h:37