ATLAS Offline Software
AthToolSupport/AsgDataHandles/AsgDataHandles/ReadHandle.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 */
6 
14 #ifndef ASG_DATA_HANDLES_READ_HANDLE_H
15 #define ASG_DATA_HANDLES_READ_HANDLE_H
16 
17 
18 #ifndef XAOD_STANDALONE
19 #include <StoreGate/ReadHandle.h>
20 #else
21 
23 // #include "AsgDataHandles/ReadHandleKey.h"
24 
25 
26 
27 namespace SG {
28  template <class T> class ReadHandleKey;
29 
30 
37 template <class T>
38 class ReadHandle
39  : public SG::VarHandleBase
40 {
41 public:
42  typedef T* pointer_type; // FIXME: better handling of
43  typedef const T* const_pointer_type; // qualified T type ?
44  typedef T& reference_type;
45  typedef const T& const_reference_type;
46 
47 
48  //************************************************************************
49  // Constructors, etc.
50  //
51 
52 
58  ReadHandle() = default;
59 
60 
65  explicit ReadHandle(const std::string& sgkey);
66 
67 
75  explicit ReadHandle (const ReadHandleKey<T>& key);
76 
77 
89  explicit ReadHandle (const ReadHandleKey<T>& key, const EventContext& ctx);
90 
91 
92  //************************************************************************
93  // Dereference.
94  //
95 
96 
102 
103 
109 
110 
116 
117 
123 
124 
128  bool isValid();
129 
130 
134  const_pointer_type get() const;
135 
136 
141  const_pointer_type get (const EventContext& ctx) const;
142 
143 
149  bool isPresent() const;
150 
151 
158  bool isPresent_impl (const std::string& key) const;
159 
160 
161 protected:
167  explicit ReadHandle (const VarHandleKey& key, const EventContext* ctx);
168 
169 
170 private:
176 
180  const_pointer_type getCPtr() const;
181 };
182 
183 
191 template <class T>
192 ReadHandle<T> makeHandle (const ReadHandleKey<T>& key);
193 
194 
206 template <class T>
207 ReadHandle<T> makeHandle (const ReadHandleKey<T>& key,
208  const EventContext& ctx);
209 
210 
217 template <class T>
218 const T* get (const ReadHandleKey<T>& key);
219 
220 
221 
229 template <class T>
230 const T* get (const ReadHandleKey<T>& key,
231  const EventContext& ctx);
232 
233 
234 } /* namespace SG */
235 
236 
237 
239 
240 #endif
241 
242 #endif //> !STOREGATE_SG_READHANDLE_H
SG::ReadHandle::checkedCPtr
const_pointer_type checkedCPtr()
Helper: dereference the pointer.
common.sgkey
def sgkey(tool)
Definition: common.py:1028
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::VarHandleBase
Base class for VarHandle types.
Definition: StoreGate/StoreGate/VarHandleBase.h:83
SG::ReadHandle::operator*
const_reference_type operator*()
Dereference the pointer.
VarHandleBase.h
Base class for VarHandle classes.
ReadHandle< T >
a smart pointer to an object of a given type in an IProxyDict (such as StoreGateSvc)....
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
SG::ReadHandle::operator->
const_pointer_type operator->()
Dereference the pointer.
SG::ReadHandle::pointer_type
T * pointer_type
Definition: StoreGate/StoreGate/ReadHandle.h:72
SG::ReadHandle::reference_type
T & reference_type
Definition: StoreGate/StoreGate/ReadHandle.h:74
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::VarHandleBase::isPresent_impl
bool isPresent_impl(const std::string &key) const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:1108
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
SG::ReadHandle::const_pointer_type
const T * const_pointer_type
Definition: StoreGate/StoreGate/ReadHandle.h:73
SG::ReadHandle::const_reference_type
const T & const_reference_type
Definition: StoreGate/StoreGate/ReadHandle.h:75
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:397
ReadHandle.h
Handle class for reading from StoreGate.
SG::get
const T * get(const ReadHandleKey< T > &key)
Convenience function to retrieve an object given a ReadHandleKey.
SG::ReadHandle::ReadHandle
ReadHandle()
Default constructor.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ReadHandle.icc
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37