ATLAS Offline Software
Loading...
Searching...
No Matches
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*/
11
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
24template <class DV> class ConstDataVector;
25
26
27namespace SG {
28
29
70template <class T>
72 : public SG::VarHandleBase
73{
74public:
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
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
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
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>
266 std::unique_ptr<AUXSTORE> store);
267
268
275 template <std::derived_from<DataObject> DOBJ>
276 requires std::convertible_to<DOBJ*, T*>
277 StatusCode record (SG::DataObjectSharedPtr<DOBJ> data);
278
279
286 template <std::derived_from<DataObject> DOBJ>
287 requires std::convertible_to<DOBJ*, T*>
289
290
306 bool returnExisting = false) const;
307
308
324 bool returnExisting = false) const;
325
326
342 bool returnExisting = false) const;
343
344
360 const_pointer_type put (const EventContext& ctx,
362 bool returnExisting = false) const;
363
364
380 const_pointer_type put (const EventContext& ctx,
381 std::unique_ptr<T> data,
382 bool returnExisting = false) const;
383
384
400 const_pointer_type put (const EventContext& ctx,
402 bool returnExisting = false) const;
403
404
417 template <std::derived_from<DataObject> DOBJ>
418 requires std::convertible_to<DOBJ*, T*>
420
421
435 template <std::derived_from<DataObject> DOBJ>
436 requires std::convertible_to<DOBJ*, T*>
437 const_pointer_type put (const EventContext& ctx,
439
440
454 template <class AUXSTORE>
457 std::unique_ptr<AUXSTORE> auxstore) const;
458
459
476 template <class AUXSTORE>
479 std::unique_ptr<const AUXSTORE> auxstore) const;
480
481
496 template <class AUXSTORE>
498 put (const EventContext& ctx,
499 std::unique_ptr<T> data,
500 std::unique_ptr<AUXSTORE> auxstore) const;
501
502
520 template <class AUXSTORE>
522 put (const EventContext& ctx,
524 std::unique_ptr<const AUXSTORE> auxstore) const;
525
526
533 WriteHandle& operator=( std::unique_ptr<T> data );
534
535
545 StatusCode alias (const WriteHandleKey<T>& key);
546
547
575 template <class U>
576 StatusCode symLink (const WriteHandleKey<U>& key);
577
578
579private:
586
587
594 template <class U>
595 StatusCode doRecord (U data,
596 bool isConst,
597 bool returnExisting);
598
599
616 template <class U>
617 const_pointer_type doPut (const EventContext* ctx,
618 U data,
619 bool returnExisting,
621
622
637 template <class AUXSTORE>
639 doPut (const EventContext* ctx,
640 std::unique_ptr<T> data,
641 std::unique_ptr<AUXSTORE> auxstore) const;
642
643
658 template <class AUXSTORE>
660 doPut (const EventContext* ctx,
662 std::unique_ptr<const AUXSTORE> auxstore) const;
663
664
671 template <class AUXSTORE>
672 StatusCode
674 std::unique_ptr<AUXSTORE> auxstore,
675 bool isConst);
676
677
678private:
694};
695
696
704template <class T>
706
707
719template <class T>
721 const EventContext& ctx);
722
723
724} /* namespace SG */
725
726
727#include "StoreGate/WriteHandle.icc"
728
729
730#endif //> !STOREGATE_SG_WRITEHANDLE_H
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Base class for VarHandle classes.
Property holding a SG store/key/clid from which a WriteHandle is made.
DataVector adapter that acts like it holds const pointers.
Base class for VarHandle types.
Property holding a SG store/key/clid from which a WriteHandle is made.
WriteHandle(const WriteHandle &rhs)
Copy constructor.
WriteHandle(const WriteHandleKey< T > &key)
Constructor from a WriteHandleKey.
const_pointer_type doPut(const EventContext *ctx, U data, bool returnExisting, IProxyDict *&store) const
const_pointer_type cptr() const
Dereference the pointer.
WriteHandle(SG::WriteHandleKey< T > &&key)=delete
WriteHandle(const std::string &sgkey, const EventContext &ctx)
Constructor specifying the key as a string, with context.
StatusCode symLink(const WriteHandleKey< U > &key)
WriteHandle()
Default constructor.
WriteHandle & operator=(const WriteHandle &rhs)
Assignment operator.
WriteHandle(const std::string &sgkey, const std::string &storename=StoreID::storeName(StoreID::EVENT_STORE))
Constructor specifying the key as a string.
~WriteHandle()
Destructor.
WriteHandle(SG::WriteHandleKey< T > &&key, const EventContext &ctx)=delete
pointer_type cachedPtr()
Return the cached pointer directly; no lookup.
WriteHandle & operator=(WriteHandle &&rhs)
Move operator.
WriteHandle(const std::string &sgkey, const std::string &storename, const EventContext &ctx)
Constructor specifying the key as a string, with context.
StatusCode record(std::unique_ptr< xAOD::CaloClusterContainer > data)
const_pointer_type put(std::unique_ptr< xAOD::CaloClusterContainer > data, bool returnExisting=false) const
StatusCode recordNonConst(std::unique_ptr< xAOD::CaloClusterContainer > data)
pointer_type operator->()
Dereference the pointer.
WriteHandle(WriteHandle &&rhs)
Move constructor.
WriteHandle(const WriteHandleKey< T > &key, const EventContext &ctx)
Constructor from a WriteHandleKey and an explicit event context.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode doRecord(U data, bool isConst, bool returnExisting)
reference_type operator*()
Dereference the pointer.
StatusCode alias(const WriteHandleKey< xAOD::CaloClusterContainer > &key)
pointer_type ptr()
Dereference the pointer.
@ EVENT_STORE
Definition StoreID.h:26
static const std::string & storeName(const StoreID::type &s)
Definition StoreID.cxx:77
STL class.
Forward declaration.
CxxUtils::RefCountedPtr< T > DataObjectSharedPtr
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
STL namespace.
#define private