ATLAS Offline Software
DataProxyHolder.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-2024 CERN for the benefit of the ATLAS collaboration
5 */
14 #ifndef ATHLINKS_DATAPROXYHOLDER_H
15 #define ATHLINKS_DATAPROXYHOLDER_H
16 
17 
18 #include "CxxUtils/sgkey_t.h"
20 #include "SGTools/DataProxy.h"
22 #include "AthenaKernel/RCUObject.h"
24 #include <string>
25 #include <unordered_map>
26 
27 
28 namespace SG {
29 
30 
31 class ThinningCache;
32 
33 
61 {
62 public:
65 
67  using ID_type = std::string;
68 
70  using pointer_t = void*;
71  using const_pointer_t = const void*;
72 
74  typedef void* castfn_t (SG::DataProxy*);
75 
76 
83 
84 
95  template <class FROM_STORABLE, class TO_STORABLE>
96  DataProxyHolder (const DataProxyHolder& other, FROM_STORABLE*, TO_STORABLE*);
97 
98 
99  DataProxyHolder (const DataProxyHolder&) = default;
101 
102 
106  void clear();
107 
108 
128  CLID link_clid,
129  IProxyDict* sg);
130 
131 
149  CLID link_clid,
150  IProxyDict* sg);
151 
152 
170  CLID link_clid,
171  IProxyDict* sg);
172 
173 
177  bool isDefault() const;
178 
179 
185  const ID_type& dataID() const;
186 
187 
199  void* storableBase (castfn_t* castfn, CLID clid, bool isConst) const;
200 
201 
202 
215  SG::DataProxy* proxy (bool nothrow = false) const;
216 
217 
225  IProxyDict* source() const;
226 
227 
239  void toTransient (sgkey_t sgkey, IProxyDict* sg = 0);
240 
241 
256  CLID link_clid,
257  IProxyDict* sg = 0);
258 
259 
276 
277 
299 
300 
322 
323 
342  template <class T>
343  bool toPersistent (sgkey_t& sgkey, const T& /*index*/);
344 
345 
358  static
359  bool thin (sgkey_t& sgkey, size_t& index,
360  const SG::ThinningCache* thinningCache);
361 
362 
366  bool operator== (const DataProxyHolder& other) const;
367 
368 
375  void throwInvalidLink (sgkey_t sgkey) const;
376 
377 
378 private:
384  bool isObjpointer() const;
385 
386 
393 
394 
402 
403 
415  SG::DataProxy* proxy1 (bool nothrow) const;
416 
417 
425 
426 
437  bool tryRemap (sgkey_t& sgkey, size_t& index);
438 
439 
443 };
444 
445 
446 } // namespace SG
447 
448 
450 
451 
452 #endif // not ATHLINKS_DATAPROXYHOLDER_H
common.sgkey
def sgkey(tool)
Definition: common.py:1028
CurrentEventStore.h
Hold a pointer to the current event store.
SG::DataProxyHolder::storeObjpointer
void storeObjpointer(const_pointer_t p)
Store a direct pointer to an object.
RCUObject.h
read-copy-update (RCU) style synchronization for Athena.
SG::DataProxyHolder::objpointer
pointer_t objpointer() const
Return a pointer to the object we're pointing at directly.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::DataProxyHolder::DataProxyHolder
DataProxyHolder(const DataProxyHolder &other, FROM_STORABLE *, TO_STORABLE *)
Constructor from a holder referencing a different type.
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
SG::DataProxyHolder::thin
static bool thin(sgkey_t &sgkey, size_t &index, const SG::ThinningCache *thinningCache)
Adjust for thinning, with explicitly provided thinning cache.
Definition: DataProxyHolder.cxx:506
SG::DataProxyHolder::DataProxyHolder
DataProxyHolder()
Default constructor.
DataProxyHolder.icc
SG::DataProxyHolder::isObjpointer
bool isObjpointer() const
Test to see if we're pointing directly at an object.
SG::DataProxyHolder::proxy1
SG::DataProxy * proxy1(bool nothrow) const
Helper for proxy(), for the case of a direct object pointer.
Definition: DataProxyHolder.cxx:570
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
SG::DataProxyHolder::sgkey_t
SG::sgkey_t sgkey_t
Type of hashed keys.
Definition: DataProxyHolder.h:64
SG::DataProxyHolder::storableBase
void * storableBase(castfn_t *castfn, CLID clid, bool isConst) const
Return a pointer to the currently-referenced object.
Definition: DataProxyHolder.cxx:250
SG::DataProxyHolder::DataProxyHolder
DataProxyHolder(const DataProxyHolder &)=default
SG::DataProxyHolder::toTransient
void toTransient(sgkey_t sgkey, IProxyDict *sg=0)
Finish initialization after link has been read.
Definition: DataProxyHolder.cxx:325
SG::DataProxyHolder::operator=
DataProxyHolder & operator=(const DataProxyHolder &)=default
SG::DataProxyHolder::toPersistentNoRemap
void toPersistentNoRemap(sgkey_t &sgkey)
Prepare this link for writing.
Definition: DataProxyHolder.cxx:394
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::DataProxyHolder::toPersistent
bool toPersistent(sgkey_t &sgkey, const T &)
Prepare this link for writing.
IStringPool.h
Abstract interface for looking up strings/CLIDs in a pool.
SG::DataProxyHolder
Manage DataProxy reference in ElementLink/DataLink.
Definition: DataProxyHolder.h:61
SG::DataProxyHolder::ID_type
std::string ID_type
Type of string keys.
Definition: DataProxyHolder.h:67
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::DataProxyHolder::toIdentifiedObject
sgkey_t toIdentifiedObject(const ID_type &dataID, CLID link_clid, IProxyDict *sg)
Set the link to an object given by a string key.
Definition: DataProxyHolder.cxx:124
SG::DataProxyHolder::source
IProxyDict * source() const
Return the data source for this reference.
Definition: DataProxyHolder.cxx:304
SG::DataProxyHolder::castfn_t
void * castfn_t(SG::DataProxy *)
Function casting from a SG::DataProxy to a pointer.
Definition: DataProxyHolder.h:74
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
SG::DataProxyHolder::isDefault
bool isDefault() const
Test to see if this is a null link.
SG::DataProxyHolder::tryRemap
bool tryRemap(sgkey_t &sgkey, size_t &index)
Test to see if the link has been remapped.
Definition: DataProxyHolder.cxx:475
SG::DataProxyHolder::clear
void clear()
Reset the link to null.
SG::DataProxyHolder::operator==
bool operator==(const DataProxyHolder &other) const
Compare for equality.
Definition: DataProxyHolder.cxx:585
sgkey_t.h
Define the type used for hashed StoreGate key+CLID pairs.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::DataProxyHolder::throwInvalidLink
void throwInvalidLink(sgkey_t sgkey) const
Throw a ExcInvalidLink exception for this link.
Definition: DataProxyHolder.cxx:546
SG::DataProxyHolder::source1
IProxyDict * source1()
Return the data source for this reference.
SG::DataProxyHolder::const_pointer_t
const void * const_pointer_t
Definition: DataProxyHolder.h:71
SG::DataProxyHolder::toStorableObject
sgkey_t toStorableObject(const_pointer_t obj, CLID link_clid, IProxyDict *sg)
Set the link to an object given by a pointer.
Definition: DataProxyHolder.cxx:59
SG::DataProxyHolder::dataID
const ID_type & dataID() const
Return the SG key that we reference, as a string.
Definition: DataProxyHolder.cxx:228
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy
Definition: DataProxy.h:45
SG::ThinningCache
Cache thinning decisions for converters.
Definition: ThinningCache.h:48
SG::DataProxyHolder::pointer_t
void * pointer_t
Generic pointer type.
Definition: DataProxyHolder.h:70
SG::DataProxyHolder::toPersistent
bool toPersistent(sgkey_t &sgkey, uint64_t &index)
Prepare this link for writing.
Definition: DataProxyHolder.cxx:423
SG::DataProxyHolder::proxy
SG::DataProxy * proxy(bool nothrow=false) const
Return the DataProxy for this link.
SG::DataProxyHolder::m_proxy
SG::DataProxy * m_proxy
The DataProxy referring to our object, if the LSB is clear; pointer to the object which we're referen...
Definition: DataProxyHolder.h:442
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
DataProxy.h