ATLAS Offline Software
StoreGate/StoreGate/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  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 */
12 #ifndef STOREGATE_SG_READHANDLE_H
13 #define STOREGATE_SG_READHANDLE_H 1
14 
15 
20 #include "GaudiKernel/EventContext.h"
21 #include <string>
22 
23 
24 
25 namespace SG {
26 
27 
64 template <class T>
66  : public SG::VarHandleBase
67 {
68 public:
69  typedef T* pointer_type; // FIXME: better handling of
70  typedef const T* const_pointer_type; // qualified T type ?
71  typedef T& reference_type;
72  typedef const T& const_reference_type;
73 
74 
75  //************************************************************************
76  // Constructors, etc.
77  //
78 
79 
86 
87 
93  explicit ReadHandle(const std::string& sgkey,
94  const std::string& storename = StoreID::storeName(StoreID::EVENT_STORE));
95 
96 
102  explicit ReadHandle(const std::string& sgkey,
103  const EventContext& ctx);
104 
105 
112  explicit ReadHandle(const std::string& sgkey,
113  const std::string& storename,
114  const EventContext& ctx);
115 
116 
124  explicit ReadHandle (const ReadHandleKey<T>& key);
125 
126 
138  explicit ReadHandle (const ReadHandleKey<T>& key, const EventContext& ctx);
139 
140 
149 
150 
151  // Disallow initialization from a temporary Key object.
152  explicit ReadHandle (SG::ReadHandleKey<T>&& key) = delete; // Not allowed from a temporary.
154  const EventContext& ctx) = delete; // Not allowed from a temporary.
155 
156 
160  ReadHandle( const ReadHandle& rhs );
161 
162 
167 
168 
172  ReadHandle& operator=( const ReadHandle& rhs );
173 
174 
179 
180 
181  //************************************************************************
182  // Dereference.
183  //
184 
185 
191 
192 
198 
199 
205 
206 
212 
213 
218 
219 
223  virtual bool isValid() override final;
224 
225 
230 
231 
236  const_pointer_type get (const EventContext& ctx) const;
237 
238 
239  //************************************************************************
240  // Alias.
241  //
242 
243 
253 
254 
255 protected:
261  explicit ReadHandle (const VarHandleKey& key, const EventContext* ctx);
262 
263 
264 private:
270 };
271 
272 
280 template <class T>
282 
283 
295 template <class T>
297  const EventContext& ctx);
298 
299 
306 template <class T>
308 
309 
310 
318 template <class T>
320  const EventContext& ctx);
321 
322 
323 } /* namespace SG */
324 
325 
326 
327 #include "StoreGate/ReadHandle.icc"
328 
329 
330 #ifndef NO_LEGACY_HANDLES
331 namespace SG {
332  template <class T>
334 }
335 #endif
336 
337 
338 #endif //> !STOREGATE_SG_READHANDLE_H
VarHandleBase.h
Base class for VarHandle classes.
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
SG::ReadHandle::checkedCPtr
const_pointer_type checkedCPtr()
Helper: dereference the pointer.
common.sgkey
def sgkey(tool)
Definition: common.py:1028
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
SG::VarHandleBase
Base class for VarHandle types.
Definition: StoreGate/StoreGate/VarHandleBase.h:83
taskman.template
dictionary template
Definition: taskman.py:317
SG::ReadHandle::ReadHandle
ReadHandle(const ReadHandleKey< T > &key, const EventContext &ctx)
Constructor from a ReadHandleKey and an explicit event context.
LArHitContainer
Hit collection.
Definition: LArHitContainer.h:26
SG::ReadHandle::operator*
const_reference_type operator*()
Dereference the pointer.
SG::ReadHandle::operator=
ReadHandle & operator=(const ReadHandle &rhs)
Assignment operator.
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::ReadHandle::ReadHandle
ReadHandle(ReadHandle &&rhs)
Move constructor.
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
protected
#define protected
Definition: DetDescrConditionsDict_dict_fixes.cxx:14
SG::ReadHandle::ReadHandle
ReadHandle(SG::ReadHandleKey< T > &&key)=delete
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:274
SG::ReadHandle::cachedPtr
const_pointer_type cachedPtr() const
Return the cached pointer directly; no lookup.
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
SG::ReadHandle::ReadHandle
ReadHandle(const std::string &sgkey, const std::string &storename, const EventContext &ctx)
Constructor specifying the key as a string, with context.
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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:69
SG::ReadHandle::reference_type
T & reference_type
Definition: StoreGate/StoreGate/ReadHandle.h:71
SG::ReadHandle::ReadHandle
ReadHandle(SG::ReadHandleKey< T > &&key, const EventContext &ctx)=delete
SG::ReadHandle::ReadHandle
ReadHandle(const ReadHandle &rhs)
Copy constructor.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
SG::ReadHandle::ReadHandle
ReadHandle(SG::DataProxy *proxy)
Constructor from a DataProxy.
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::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
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:70
SG::ReadHandle::const_reference_type
const T & const_reference_type
Definition: StoreGate/StoreGate/ReadHandle.h:72
SG::ReadHandle::ReadHandle
ReadHandle(const std::string &sgkey, const std::string &storename=StoreID::storeName(StoreID::EVENT_STORE))
Constructor specifying the key as a string.
SG::ReadHandle::ReadHandle
ReadHandle(const std::string &sgkey, const EventContext &ctx)
Constructor specifying the key as a string, with context.
SG::ReadHandle::operator=
ReadHandle & operator=(ReadHandle &&rhs)
Move operator.
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::ReadHandle::ReadHandle
ReadHandle(const ReadHandleKey< T > &key)
Constructor from a ReadHandleKey.
SG::DataProxy
Definition: DataProxy.h:45
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77
SG::ReadHandle::ReadHandle
ReadHandle()
Default constructor.
SG::ReadHandle::alias
StatusCode alias(const WriteHandleKey< T > &key)
Make an alias.