ATLAS Offline Software
Loading...
Searching...
No Matches
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-2026 CERN for the benefit of the ATLAS collaboration
4*/
11
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
25namespace SG {
26
27
63template <class T>
65 : public SG::VarHandleBase
66{
67public:
68 typedef T* pointer_type; // FIXME: better handling of
69 typedef const T* const_pointer_type; // qualified T type ?
70 typedef T& reference_type;
71 typedef const T& const_reference_type;
72
73
74 //************************************************************************
75 // Constructors, etc.
76 //
77
78
85
86
92 explicit ReadHandle(const std::string& sgkey,
93 const std::string& storename = StoreID::storeName(StoreID::EVENT_STORE));
94
95
101 explicit ReadHandle(const std::string& sgkey, const EventContext& ctx);
102
103
109 explicit ReadHandle(const std::string& sgkey, IProxyDict* sg);
110
111
118 explicit ReadHandle(const std::string& sgkey,
119 const std::string& storename,
120 const EventContext& ctx);
121
122
130 explicit ReadHandle (const ReadHandleKey<T>& key);
131
132
144 explicit ReadHandle (const ReadHandleKey<T>& key, const EventContext& ctx);
145
146
154 explicit ReadHandle (SG::DataProxy* proxy);
155
156
157 // Disallow initialization from a temporary Key object.
158 explicit ReadHandle (SG::ReadHandleKey<T>&& key) = delete; // Not allowed from a temporary.
160 const EventContext& ctx) = delete; // Not allowed from a temporary.
161
162
166 ReadHandle( const ReadHandle& rhs );
167
168
172 ReadHandle( ReadHandle&& rhs ) noexcept;
173
174
179
180
184 ReadHandle& operator=( ReadHandle&& rhs ) noexcept;
185
186
187 //************************************************************************
188 // Dereference.
189 //
190
191
197
198
204
205
211
212
218
219
224
225
229 virtual bool isValid() override final;
230
231
236
237
242 const_pointer_type get (const EventContext& ctx) const;
243
244
245 //************************************************************************
246 // Alias.
247 //
248
249
258 StatusCode alias (const WriteHandleKey<T>& key);
259
260
267 explicit ReadHandle (const VarHandleKey& key, const EventContext* ctx);
268
269
270private:
276};
277
278
286template <class T>
288
289
301template <class T>
303 const EventContext& ctx);
304
305
312template <class T>
314
315
316
324template <class T>
326 const EventContext& ctx);
327
328
337template <class T>
338StatusCode get (const T*& ptr,
340 const EventContext& ctx);
341
342} /* namespace SG */
343
344
345
346#include "StoreGate/ReadHandle.icc"
347
348
349#endif //> !STOREGATE_SG_READHANDLE_H
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Property holding a SG store/key/clid from which a ReadHandle is made.
Base class for VarHandle classes.
Property holding a SG store/key/clid from which a WriteHandle is made.
Property holding a SG store/key/clid from which a ReadHandle is made.
ReadHandle(const ReadHandleKey< T > &key)
Constructor from a ReadHandleKey.
ReadHandle(const ReadHandleKey< T > &key, const EventContext &ctx)
Constructor from a ReadHandleKey and an explicit event context.
ReadHandle(const std::string &sgkey, const std::string &storename=StoreID::storeName(StoreID::EVENT_STORE))
Constructor specifying the key as a string.
ReadHandle & operator=(const ReadHandle &rhs)
Assignment operator.
ReadHandle(const ReadHandle &rhs)
Copy constructor.
ReadHandle(const std::string &sgkey, IProxyDict *sg)
Constructor specifying the key as a string, with data store.
ReadHandle(const std::string &sgkey, const std::string &storename, const EventContext &ctx)
Constructor specifying the key as a string, with context.
const_pointer_type ptr()
Dereference the pointer.
ReadHandle()
Default constructor.
ReadHandle(ReadHandle &&rhs) noexcept
Move constructor.
ReadHandle & operator=(ReadHandle &&rhs) noexcept
Move operator.
StatusCode alias(const WriteHandleKey< xAOD::CaloClusterContainer > &key)
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ReadHandle(const std::string &sgkey, const EventContext &ctx)
Constructor specifying the key as a string, with context.
const_pointer_type operator->()
Dereference the pointer.
const_reference_type operator*()
Dereference the pointer.
ReadHandle(SG::DataProxy *proxy)
Constructor from a DataProxy.
const_pointer_type cptr()
Dereference the pointer.
ReadHandle(SG::ReadHandleKey< T > &&key, const EventContext &ctx)=delete
const_pointer_type cachedPtr() const
Return the cached pointer directly; no lookup.
ReadHandle(SG::ReadHandleKey< T > &&key)=delete
Base class for VarHandle types.
A property holding a SG store/key/clid from which a VarHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
@ EVENT_STORE
Definition StoreID.h:26
static const std::string & storeName(const StoreID::type &s)
Definition StoreID.cxx:77
Forward declaration.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
#define protected
Definition testRead.cxx:26
#define private
Definition testRead.cxx:27