Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StoreGate/StoreGate/WriteHandle.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_WRITEHANDLE_H
13 #define STOREGATE_SG_WRITEHANDLE_H 1
14 
15 
18 #include "StoreGate/StoreGateSvc.h" /* needed by clients */
19 #include "GaudiKernel/EventContext.h"
20 #include <string>
21 #include <memory> /*unique_ptr*/
22 
23 
24 template <class DV> class ConstDataVector;
25 
26 
27 namespace SG {
28 
29 
70 template <class T>
72  : public SG::VarHandleBase
73 {
74 public:
75  typedef T* pointer_type; // FIXME: better handling of
76  typedef const T* const_pointer_type; // qualified T type ?
77  typedef T& reference_type;
78  typedef const T& const_reference_type;
79 
80 
81  //************************************************************************
82  // Constructors, etc.
83  //
84 
85 
92 
93 
99  explicit WriteHandle(const std::string& sgkey,
100  const std::string& storename = StoreID::storeName(StoreID::EVENT_STORE));
101 
102 
108  explicit WriteHandle(const std::string& sgkey,
109  const EventContext& ctx);
110 
111 
118  explicit WriteHandle(const std::string& sgkey,
119  const std::string& storename,
120  const EventContext& ctx);
121 
122 
130  explicit WriteHandle (const WriteHandleKey<T>& key);
131 
132 
144  explicit WriteHandle (const WriteHandleKey<T>& key, const EventContext& ctx);
145 
146 
147  // Disallow initialization from a temporary Key object.
148  explicit WriteHandle (SG::WriteHandleKey<T>&& key) = delete; // Not allowed from a temporary.
150  const EventContext& ctx) = delete; // Not allowed from a temporary.
151 
152 
156  WriteHandle( const WriteHandle& rhs );
157 
158 
163 
164 
169 
170 
175 
176 
183 
184 
185  //************************************************************************
186  // Deference. These all return only the cached pointer.
187  //
188 
189 
195 
196 
202 
203 
209 
210 
216 
217 
222 
223 
227  virtual bool isValid() override final;
228 
229 
230  //************************************************************************
231  // Record.
232  //
233 
234 
239  StatusCode record (std::unique_ptr<T> data);
240 
241 
246  StatusCode recordNonConst (std::unique_ptr<T> data);
247 
248 
254  template <class AUXSTORE>
255  StatusCode record (std::unique_ptr<T> data,
256  std::unique_ptr<AUXSTORE> store);
257 
258 
264  template <class AUXSTORE>
265  StatusCode recordNonConst (std::unique_ptr<T> data,
266  std::unique_ptr<AUXSTORE> store);
267 
268 
276 
277 
285 
286 
301  const_pointer_type put (std::unique_ptr<T> data,
302  bool returnExisting = false) const;
303 
304 
319  const_pointer_type put (std::unique_ptr<const T> data,
320  bool returnExisting = false) const;
321 
322 
338  bool returnExisting = false) const;
339 
340 
356  const_pointer_type put (const EventContext& ctx,
357  std::unique_ptr<const ConstDataVector<T> > data,
358  bool returnExisting = false) const;
359 
360 
376  const_pointer_type put (const EventContext& ctx,
377  std::unique_ptr<T> data,
378  bool returnExisting = false) const;
379 
380 
396  const_pointer_type put (const EventContext& ctx,
397  std::unique_ptr<const T> data,
398  bool returnExisting = false) const;
399 
400 
414 
415 
429  const_pointer_type put (const EventContext& ctx,
431 
432 
446  template <class AUXSTORE>
448  put (std::unique_ptr<T> data,
449  std::unique_ptr<AUXSTORE> auxstore) const;
450 
451 
468  template <class AUXSTORE>
470  put (std::unique_ptr<const T> data,
471  std::unique_ptr<const AUXSTORE> auxstore) const;
472 
473 
488  template <class AUXSTORE>
490  put (const EventContext& ctx,
491  std::unique_ptr<T> data,
492  std::unique_ptr<AUXSTORE> auxstore) const;
493 
494 
512  template <class AUXSTORE>
514  put (const EventContext& ctx,
515  std::unique_ptr<const T> data,
516  std::unique_ptr<const AUXSTORE> auxstore) const;
517 
518 
525  WriteHandle& operator=( std::unique_ptr<T> data );
526 
527 
538 
539 
567  template <class U>
569 
570 
571 private:
578 
579 
586  template <class U>
588  bool isConst,
589  bool returnExisting);
590 
591 
608  template <class U>
609  const_pointer_type doPut (const EventContext* ctx,
610  U data,
611  bool returnExisting,
612  IProxyDict* & store) const;
613 
614 
629  template <class AUXSTORE>
631  doPut (const EventContext* ctx,
632  std::unique_ptr<T> data,
633  std::unique_ptr<AUXSTORE> auxstore) const;
634 
635 
650  template <class AUXSTORE>
652  doPut (const EventContext* ctx,
653  std::unique_ptr<const T> data,
654  std::unique_ptr<const AUXSTORE> auxstore) const;
655 
656 
663  template <class AUXSTORE>
664  StatusCode
665  record (std::unique_ptr<T> data,
666  std::unique_ptr<AUXSTORE> auxstore,
667  bool isConst);
668 
669 
670 private:
686 };
687 
688 
696 template <class T>
698 
699 
711 template <class T>
713  const EventContext& ctx);
714 
715 
716 } /* namespace SG */
717 
718 
719 #include "StoreGate/WriteHandle.icc"
720 
721 
722 #ifndef NO_LEGACY_HANDLES
723 namespace SG {
724  template <class T>
726 }
727 #endif
728 #endif //> !STOREGATE_SG_WRITEHANDLE_H
VarHandleBase.h
Base class for VarHandle classes.
common.sgkey
def sgkey(tool)
Definition: common.py:1028
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
SG::WriteHandle::operator=
WriteHandle & operator=(const WriteHandle &rhs)
Assignment operator.
SG::WriteHandle::WriteHandle
WriteHandle(const std::string &sgkey, const EventContext &ctx)
Constructor specifying the key as a string, with context.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::WriteHandle::reference_type
T & reference_type
Definition: StoreGate/StoreGate/WriteHandle.h:77
SG::VarHandleBase
Base class for VarHandle types.
Definition: StoreGate/StoreGate/VarHandleBase.h:83
SG::WriteHandle::symLink
StatusCode symLink(const WriteHandleKey< U > &key)
Make an explicit link.
WriteHandle< T >
A smart pointer to an object of a given type in an IProxyDict (such as StoreGateSvc)....
taskman.template
dictionary template
Definition: taskman.py:317
LArHitContainer
Hit collection.
Definition: LArHitContainer.h:26
SG::WriteHandle::alias
StatusCode alias(const WriteHandleKey< T > &key)
Make an alias.
SG::WriteHandle::cptr
const_pointer_type cptr() const
Dereference the pointer.
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::WriteHandle::WriteHandle
WriteHandle(WriteHandle &&rhs)
Move constructor.
SG::WriteHandle::WriteHandle
WriteHandle(const WriteHandle &rhs)
Copy constructor.
SG::WriteHandle::WriteHandle
WriteHandle(SG::WriteHandleKey< T > &&key, const EventContext &ctx)=delete
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
SG::WriteHandle::operator=
WriteHandle & operator=(WriteHandle &&rhs)
Move operator.
SG::WriteHandle::WriteHandle
WriteHandle(const WriteHandleKey< T > &key, const EventContext &ctx)
Constructor from a WriteHandleKey and an explicit event context.
SG::WriteHandle::WriteHandle
WriteHandle(SG::WriteHandleKey< T > &&key)=delete
SG::WriteHandle::cachedPtr
pointer_type cachedPtr()
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::WriteHandle::WriteHandle
WriteHandle(const WriteHandleKey< T > &key)
Constructor from a WriteHandleKey.
SG::WriteHandle::recordNonConst
StatusCode recordNonConst(std::unique_ptr< T > data)
Record a non-const object to the store.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:382
SG::WriteHandle::operator*
reference_type operator*()
Dereference the pointer.
SG::WriteHandle::pointer_type
T * pointer_type
Definition: StoreGate/StoreGate/WriteHandle.h:75
SG::WriteHandle::WriteHandle
WriteHandle(const std::string &sgkey, const std::string &storename=StoreID::storeName(StoreID::EVENT_STORE))
Constructor specifying the key as a string.
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
SG::WriteHandle::const_pointer_type
const T * const_pointer_type
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::~WriteHandle
~WriteHandle()
Destructor.
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
SG::WriteHandle::WriteHandle
WriteHandle(const std::string &sgkey, const std::string &storename, const EventContext &ctx)
Constructor specifying the key as a string, with context.
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
python.Dumpers.typename
def typename(t)
Definition: Dumpers.py:194
SG::WriteHandle::operator->
pointer_type operator->()
Dereference the pointer.
SG::WriteHandle::checkedCachedPtr
pointer_type checkedCachedPtr()
Return the cached pointer directly.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::const_reference_type
const T & const_reference_type
Definition: StoreGate/StoreGate/WriteHandle.h:78
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
SG::WriteHandle::doPut
const_pointer_type doPut(const EventContext *ctx, U data, bool returnExisting, IProxyDict *&store) const
Helper for put.
SG::VarHandleBase::isConst
bool isConst() const
True if this handle has a proxy, and the proxy is const.
Definition: StoreGate/src/VarHandleBase.cxx:438
SG::WriteHandle::put
const_pointer_type put(std::unique_ptr< T > data, bool returnExisting=false) const
Record an object to the store.
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::DataObjectSharedPtr
Smart pointer to manage DataObject reference counts.
Definition: DataObjectSharedPtr.h:45
SG::WriteHandle::doRecord
StatusCode doRecord(U data, bool isConst, bool returnExisting)
Helper for record.
SG::DataProxy
Definition: DataProxy.h:45
SG::WriteHandle::WriteHandle
WriteHandle()
Default constructor.
StoreGateSvc.h
SG::WriteHandle::m_lockAuxPending
SG::DataProxy * m_lockAuxPending
If non-null, then we need to lock the associated aux store object when we're deleted.
Definition: StoreGate/StoreGate/WriteHandle.h:685
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77