ATLAS Offline Software
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 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id: WriteHandle.h 797637 2017-02-17 02:32:11Z ssnyder $
15 #ifndef STOREGATE_SG_WRITEHANDLE_H
16 #define STOREGATE_SG_WRITEHANDLE_H 1
17 
18 
21 #include "StoreGate/StoreGateSvc.h" /* needed by clients */
22 #include "GaudiKernel/EventContext.h"
23 #include <string>
24 #include <memory> /*unique_ptr*/
25 
26 
27 template <class DV> class ConstDataVector;
28 
29 
30 namespace SG {
31 
32 
73 template <class T>
75  : public SG::VarHandleBase
76 {
77 public:
78  typedef T* pointer_type; // FIXME: better handling of
79  typedef const T* const_pointer_type; // qualified T type ?
80  typedef T& reference_type;
81  typedef const T& const_reference_type;
82 
83 
84  //************************************************************************
85  // Constructors, etc.
86  //
87 
88 
95 
96 
102  explicit WriteHandle(const std::string& sgkey,
103  const std::string& storename = StoreID::storeName(StoreID::EVENT_STORE));
104 
105 
113  explicit WriteHandle (const WriteHandleKey<T>& key);
114 
115 
127  explicit WriteHandle (const WriteHandleKey<T>& key, const EventContext& ctx);
128 
129 
133  WriteHandle( const WriteHandle& rhs );
134 
135 
140 
141 
146 
147 
152 
153 
160 
161 
162  //************************************************************************
163  // Deference. These all return only the cached pointer.
164  //
165 
166 
172 
173 
179 
180 
186 
187 
193 
194 
199 
200 
204  virtual bool isValid() override final;
205 
206 
207  //************************************************************************
208  // Record.
209  //
210 
211 
216  StatusCode record (std::unique_ptr<T> data);
217 
218 
223  StatusCode recordNonConst (std::unique_ptr<T> data);
224 
225 
231  template <class AUXSTORE>
232  StatusCode record (std::unique_ptr<T> data,
233  std::unique_ptr<AUXSTORE> store);
234 
235 
241  template <class AUXSTORE>
242  StatusCode recordNonConst (std::unique_ptr<T> data,
243  std::unique_ptr<AUXSTORE> store);
244 
245 
253 
254 
262 
263 
278  const_pointer_type put (std::unique_ptr<T> data,
279  bool returnExisting = false) const;
280 
281 
296  const_pointer_type put (std::unique_ptr<const T> data,
297  bool returnExisting = false) const;
298 
299 
315  bool returnExisting = false) const;
316 
317 
333  const_pointer_type put (const EventContext& ctx,
334  std::unique_ptr<const ConstDataVector<T> > data,
335  bool returnExisting = false) const;
336 
337 
353  const_pointer_type put (const EventContext& ctx,
354  std::unique_ptr<T> data,
355  bool returnExisting = false) const;
356 
357 
373  const_pointer_type put (const EventContext& ctx,
374  std::unique_ptr<const T> data,
375  bool returnExisting = false) const;
376 
377 
391 
392 
406  const_pointer_type put (const EventContext& ctx,
408 
409 
423  template <class AUXSTORE>
425  put (std::unique_ptr<T> data,
426  std::unique_ptr<AUXSTORE> auxstore) const;
427 
428 
445  template <class AUXSTORE>
447  put (std::unique_ptr<const T> data,
448  std::unique_ptr<const AUXSTORE> auxstore) const;
449 
450 
465  template <class AUXSTORE>
467  put (const EventContext& ctx,
468  std::unique_ptr<T> data,
469  std::unique_ptr<AUXSTORE> auxstore) const;
470 
471 
489  template <class AUXSTORE>
491  put (const EventContext& ctx,
492  std::unique_ptr<const T> data,
493  std::unique_ptr<const AUXSTORE> auxstore) const;
494 
495 
502  WriteHandle& operator=( std::unique_ptr<T> data );
503 
504 
515 
516 
544  template <class U>
546 
547 
548 private:
555 
556 
563  template <class U>
565  bool isConst,
566  bool returnExisting);
567 
568 
585  template <class U>
586  const_pointer_type doPut (const EventContext* ctx,
587  U data,
588  bool returnExisting,
589  IProxyDict* & store) const;
590 
591 
606  template <class AUXSTORE>
608  doPut (const EventContext* ctx,
609  std::unique_ptr<T> data,
610  std::unique_ptr<AUXSTORE> auxstore) const;
611 
612 
627  template <class AUXSTORE>
629  doPut (const EventContext* ctx,
630  std::unique_ptr<const T> data,
631  std::unique_ptr<const AUXSTORE> auxstore) const;
632 
633 
640  template <class AUXSTORE>
641  StatusCode
642  record (std::unique_ptr<T> data,
643  std::unique_ptr<AUXSTORE> auxstore,
644  bool isConst);
645 
646 
647 private:
663 };
664 
665 
673 template <class T>
675 
676 
688 template <class T>
690  const EventContext& ctx);
691 
692 
693 } /* namespace SG */
694 
695 
696 #include "StoreGate/WriteHandle.icc"
697 
698 
699 #ifndef NO_LEGACY_HANDLES
700 namespace SG {
701  template <class T>
703 }
704 #endif
705 #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
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::WriteHandle::reference_type
T & reference_type
Definition: StoreGate/StoreGate/WriteHandle.h:80
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::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
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::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:376
SG::WriteHandle::operator*
reference_type operator*()
Dereference the pointer.
SG::WriteHandle::pointer_type
T * pointer_type
Definition: StoreGate/StoreGate/WriteHandle.h:78
SG::WriteHandle::WriteHandle
WriteHandle(const std::string &sgkey, const std::string &storename=StoreID::storeName(StoreID::EVENT_STORE))
Constructor with full arguments.
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:79
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::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:76
SG::WriteHandle::const_reference_type
const T & const_reference_type
Definition: StoreGate/StoreGate/WriteHandle.h:81
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:432
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:662
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77