ATLAS Offline Software
Loading...
Searching...
No Matches
SG::VarHandleBase Class Referenceabstract

Base class for VarHandle types. More...

#include <VarHandleBase.h>

Inherits IResetable.

Inherited by SG::ReadHandle< xAOD::CaloClusterContainer >, SG::ReadHandle< IDC >, SG::ReadHandle< DataVector< xAOD::Electron_v1 > >, SG::ReadHandle< T_Cont >, SG::ReadHandle< McEventCollection >, SG::ReadHandle< DataVector< xAOD::TrackParticle_v1 > >, SG::ReadHandle< DataVector< Trk::Track > >, SG::ReadHandle< SpacePointContainer >, SG::ReadHandle< SpacePointOverlapCollection >, SG::ReadHandle< Trk::PRDtoTrackMap >, SG::ReadHandle< PixelGangedClusterAmbiguities >, SG::ReadHandle< DataVector< IParticle > >, SG::ReadHandle< DataVector< xAOD::Jet_v1 > >, SG::ReadHandle< TBEventInfo >, SG::ReadHandle< AthenaHitsVector< LArG4H6FrontHit > >, SG::ReadHandle< LArHitContainer >, SG::ReadHandle< LVL1::jTowerContainer >, SG::ReadHandle< MyDataObj >, SG::ReadHandle< VxContainer >, SG::UpdateHandle< IDCBackend >, SG::WriteHandle< xAOD::CaloClusterContainer >, SG::WriteHandle< CaloClusterCellLinkContainer >, SG::WriteHandle< IDC >, SG::WriteHandle< xAOD::AuxiliaryMeasurementContainer >, SG::WriteHandle< DecisionContainer >, SG::WriteHandle< AtlasHitsVector< AFP_TDSimHit > >, SG::WriteHandle< AtlasHitsVector< AFP_SIDSimHit > >, SG::WriteHandle< AtlasHitsVector< ALFA_Hit > >, SG::WriteHandle< AtlasHitsVector< ALFA_ODHit > >, SG::WriteHandle< AtlasHitsVector< CSCSimHit > >, SG::WriteHandle< CaloCellContainer >, SG::WriteHandle< Muon::MuonPrepDataContainer< MuonPrepDataCollection< PrdType > > >, SG::WriteHandle< HitContainerType >, SG::WriteHandle< AtlasHitsVector< TrackRecord > >, SG::WriteHandle< TBEventInfo >, SG::WriteHandle< AtlasHitsVector< GenericMuonSimHit > >, SG::WriteHandle< AtlasHitsVector< SiHit > >, SG::WriteHandle< HGTD_RDO_Container >, SG::WriteHandle< HGTD_ALTIROC_RDO_Container >, SG::WriteHandle< InDetSimDataCollection >, SG::WriteHandle< McEventCollection >, SG::WriteHandle< InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > >, SG::WriteHandle< CaloCalibrationHitContainer >, SG::WriteHandle< LArHitContainer >, SG::WriteHandle< AthenaHitsVector< LArG4H6FrontHit > >, SG::WriteHandle< AthenaHitsVector< LArG4H6WarmTCHit > >, SG::WriteHandle< TBTrack >, SG::WriteHandle< AtlasHitsVector< LUCID_SimHit > >, SG::WriteHandle< AtlasHitsVector< MDTSimHit > >, SG::WriteHandle< HijingEventParams >, SG::WriteHandle< AtlasHitsVector< MMSimHit > >, SG::WriteHandle< AtlasHitsVector< TileHit > >, SG::WriteHandle< DataVector< TgcStrip_v1 > >, SG::WriteHandle< DataVector< sTgcStripCluster_v1 > >, SG::WriteHandle< DataVector< sTgcWireHit_v1 > >, SG::WriteHandle< DataVector< sTgcPadHit_v1 > >, SG::WriteHandle< DataVector< xAOD::MuonSimHit_v1 > >, SG::WriteHandle< InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > >, SG::WriteHandle< AtlasHitsVector< RPCSimHit > >, SG::WriteHandle< DataVector< xAOD::CaloRings_v1 > >, SG::WriteHandle< DataVector< xAOD::RingSet_v1 > >, SG::WriteHandle< SG::ThinningDecision >, SG::WriteHandle< AtlasHitsVector< TGCSimHit > >, SG::WriteHandle< InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > >, SG::WriteHandle< TrigRoiDescriptorCollection >, SG::WriteHandle< DataVector< Particle_v1 > >, SG::WriteHandle< DataVector< xAOD::TrigMissingET_v1 > >, SG::WriteHandle< DataVector< TrigComposite_v1 > >, SG::WriteHandle< ZDC_SimFiberHit_Collection >, SG::WriteHandle< AtlasHitsVector< sTGCSimHit > >, SG::WriteHandle< DataVector< xAOD::Vertex_v1 > >, SG::WriteHandle< xAOD::VertexAuxContainer_v1 >, SG::ReadHandle< T >, SG::TypelessWriteHandle, SG::UpdateHandle< T >, and SG::WriteHandle< T >.

Collaboration diagram for SG::VarHandleBase:

Public Member Functions

 VarHandleBase (CLID clid, Gaudi::DataHandle::Mode mode)
 Constructor with default key.
 VarHandleBase (CLID clid, const std::string &sgkey, Gaudi::DataHandle::Mode mode, const std::string &storename, const EventContext *ctx)
 Constructor with full arguments.
 VarHandleBase (const VarHandleKey &key, const EventContext *ctx)
 Constructor from a VarHandleKey.
 VarHandleBase (SG::DataProxy *proxy, Gaudi::DataHandle::Mode mode)
 Constructor from a DataProxy.
 VarHandleBase (const VarHandleBase &rhs)
 Copy constructor.
 VarHandleBase (VarHandleBase &&rhs) noexcept
 Move constructor.
VarHandleBaseoperator= (const VarHandleBase &rhs)
 Assignment operator.
VarHandleBaseoperator= (VarHandleBase &&rhs) noexcept
 Move operator.
virtual ~VarHandleBase () override
 Destructor.
virtual const std::string & key () const override final
 Return the StoreGate ID for the referenced object.
const std::string & name () const
 Return the StoreGate ID for the referenced object.
std::string store () const
 Return the name of the store holding the object we are proxying.
virtual bool isValid ()=0
 Can the handle be successfully dereferenced?
bool isPresent () const
 Is the referenced object present in SG?
bool isInitialized () const
 Has a proxy been retrieved from SG?
virtual bool isSet () const override final
 Has a proxy been retrieved from SG?
bool isConst () const
 True if this handle has a proxy, and the proxy is const.
StatusCode initialize (bool used=true)
 Verify that the handle has been configured properly.
StatusCode setState ()
 Retrieve and cache all information managed by a handle.
virtual StatusCode setProxyDict (IProxyDict *store)
 Explicitly set the event store.
virtual void reset (bool hard) override
 Reset this handle.
virtual void finalReset () override final
 Reset this handle at the end of processing.
StatusCode setConst ()
 Set the 'const' bit for the bound proxy in the store.
CLID clid () const
 Return the class ID for the referenced object.
const ServiceHandle< IProxyDict > & storeHandle () const
 Return handle to the referenced store.
Gaudi::DataHandle::Mode mode () const
 Return the mode (read/write/update) for this handle.
const std::string & objKey () const
 Return the key string of the underlying DataObjID.
const DataObjID & fullKey () const
 Return the key as a DataObjID.
SG::VarHandleKeyvhKey ()
 Return a non-const reference to the HandleKey.
StatusCode assign (const std::string &sgkey)
 Update the underlying key from a string.

Protected Member Functions

StatusCode setState (SG::DataProxy *proxy)
 Set the state of the handle to a given proxy.
StatusCode setState (IProxyDict *store, const std::string &name)
 Set the state of a handle from a store and a key name.
StatusCode record_impl (std::unique_ptr< DataObject > dobj, void *dataPtr, bool allowMods, bool returnExisting)
 Helper to record an object in the event store.
const void * put_impl (const EventContext *ctx, std::unique_ptr< DataObject > dobj, const void *dataPtr, bool allowMods, bool returnExisting, IProxyDict *&store) const
 Helper to record an object in the event store.
void * typeless_dataPointer_impl (bool quiet)
 Retrieve an object from StoreGate.
void * typeless_dataPointer (bool quiet=defaultQuiet)
 Retrieve an object from StoreGate.
const void * typeless_cptr ()
 Retrieve an object from StoreGate as a const pointer.
void * typeless_ptr (bool quiet=defaultQuiet)
 Retrieve an object from StoreGate as non-const pointer.
const void * get_impl (const EventContext *ctx, bool quiet=defaultQuiet) const
StatusCode symLink_impl (CLID newClid, const std::string &newKey)
 Make a symlink or alias to the object currently referenced by this handle.
bool isPresent_impl (const std::string &key) const
 Is the referenced object present in SG?

Protected Attributes

void * m_ptr
 The object to which we are bound.
SG::DataProxym_proxy
 Proxy holding the object to which we are bound.
IProxyDictm_store
 Pointer to the store that owns the object.
bool m_storeWasSet
 True if the store was set explicitly via setProxyDict.

Private Member Functions

IProxyDictstoreFromHandle (const EventContext *ctx) const
 Return the store instance to use.
bool setStoreFromHandle (const EventContext *ctx)
 Initialize the store pointer from the store handle.
void resetProxy ()
 Clear the m_proxy field and release the old proxy.
void setProxy (SG::DataProxy *proxy)
 Set a new proxy.
void * typeless_dataPointer_fromProxy (SG::DataProxy *proxy, bool quiet) const
 Retrieve a pointer from a proxy.

Private Attributes

std::unique_ptr< VarHandleKeym_ownedKey
 An owned VarHandleKey.
const VarHandleKeym_key
 The associated key object.

Friends

void Athena_test::varHandleTest (SGTest::TestStore &)
void Athena_test::resetableTest (void)
void Athena_test::refCountTest (void)
std::ostream & operator<< (std::ostream &out, const VarHandleBase &o)
 Return the name of the store holding the object we are proxying.

Detailed Description

Base class for VarHandle types.

This is the base class for smart pointer types used to access objects in an IProxyDict (such as a StoreGateSvc). The handle types ReadHandle, WriteHandle, and UpdateHandle derive from this; see those classes for usage information.

This class references a VarHandleKey, which holds the CLID of the class we're referencing (which gets passed to the constructor of this class from the templated derived classes), the StoreGate key of the object we're referencing, and a handle to the event store. The key object can be passed to this object via the constructor; otherwise, we create and own a new VarHandleKey object.

In this class, we keep a pointer to the actual event store being used (may be thread-dependent), a pointer to the DataProxy for the referenced object, and a cached pointer to the object itself.

A handle object may be used as a algorithm/tool property directly. Because the handle caches state, however, this means that the component using it cannot be reentrant. In such a case, the handle will be reset when the current algorithm completes. In this case, the handle will be bound to the proxy.

The preferred way of using handles is to use a HandleKey object (one of ReadHandleKey<T>, WriteHandleKey<T>, UpdateHandleKey<T>) as the property, and to create a handle instance on the stack from the key object (and the event context, if available). In this case, the handle will not be bound to the proxy. A handle created in this way should not live beyond the end of the algorithm in which it was created.

Definition at line 82 of file StoreGate/StoreGate/VarHandleBase.h.

Constructor & Destructor Documentation

◆ VarHandleBase() [1/6]

SG::VarHandleBase::VarHandleBase ( CLID clid,
Gaudi::DataHandle::Mode mode )
explicit

Constructor with default key.

Parameters
clidCLID of the referenced class.
modeMode of this handle (read/write/update).

Definition at line 113 of file StoreGate/src/VarHandleBase.cxx.

113 :
114 IResetable(),
115 m_ptr(0),
116 m_proxy(0),
117 m_store(nullptr),
118 m_storeWasSet(false),
119 m_ownedKey (std::make_unique<VarHandleKey> (clid, "", mode)),
120 m_key (m_ownedKey.get())
121 {
122 m_ownedKey->setOwningHandle (this);
123#ifdef DEBUG_VHB
124 dbg::print(stderr, "VarHandleBase() {}\n", dbg::ptr(this));
125#endif
126 }
std::unique_ptr< VarHandleKey > m_ownedKey
An owned VarHandleKey.
bool m_storeWasSet
True if the store was set explicitly via setProxyDict.
IProxyDict * m_store
Pointer to the store that owns the object.
void * m_ptr
The object to which we are bound.
Gaudi::DataHandle::Mode mode() const
Return the mode (read/write/update) for this handle.
const VarHandleKey * m_key
The associated key object.
SG::DataProxy * m_proxy
Proxy holding the object to which we are bound.
CLID clid() const
Return the class ID for the referenced object.
void * ptr(T *p)
Definition SGImplSvc.cxx:74
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition SGImplSvc.cxx:70

◆ VarHandleBase() [2/6]

SG::VarHandleBase::VarHandleBase ( CLID clid,
const std::string & sgkey,
Gaudi::DataHandle::Mode mode,
const std::string & storename,
const EventContext * ctx )
explicit

Constructor with full arguments.

Parameters
clidCLID of the referenced class.
sgkeyStoreGate key of the referenced object.
modeMode of this handle (read/write/update).
storenameName of the referenced event store.
ctxThe event context to use, or nullptr.

Definition at line 137 of file StoreGate/src/VarHandleBase.cxx.

141 :
142 IResetable(),
143 m_ptr(NULL),
144 m_proxy(NULL),
145 m_store(nullptr),
146 m_storeWasSet(false),
147 m_ownedKey (std::make_unique<VarHandleKey> (clid, sgkey, mode, storename)),
148 m_key (m_ownedKey.get())
149 {
150 m_ownedKey->setOwningHandle (this);
151
152 if (ctx && !setStoreFromHandle(ctx)) {
153 throw SG::ExcHandleInitError (clid, sgkey, storename);
154 }
155 }
bool setStoreFromHandle(const EventContext *ctx)
Initialize the store pointer from the store handle.

◆ VarHandleBase() [3/6]

SG::VarHandleBase::VarHandleBase ( const VarHandleKey & key,
const EventContext * ctx )
explicit

Constructor from a VarHandleKey.

Parameters
keyThe key object holding the clid/key/store.
ctxThe event context to use, or nullptr.

This will raise an exception if the StoreGate key is blank, or if the event store cannot be found.

If the default event store has been requested, then the thread-specific store from ctx will be used. If ctx is null, then the current event context will be read.

Parameters
keyThe key object holding the clid/key/store.
ctxThe event context to use, or nullptr.

This will raise an exception if the StoreGate key is blank, or if the event store cannot be found.

Definition at line 45 of file AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx.

47 : m_key (&key)
48 {
49 }
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.

◆ VarHandleBase() [4/6]

SG::VarHandleBase::VarHandleBase ( SG::DataProxy * proxy,
Gaudi::DataHandle::Mode mode )
explicit

Constructor from a DataProxy.

Parameters
proxyThe proxy to which to bind.
modeMode of this handle (read/write/update).

This handle will be bound to the given proxy.

Definition at line 194 of file StoreGate/src/VarHandleBase.cxx.

196 : IResetable(),
197 m_ptr (nullptr),
198 m_proxy (nullptr),
199 m_store (proxy->store()),
200 m_storeWasSet (true),
201 m_ownedKey (std::make_unique<VarHandleKey> (proxy->clID(),
202 proxy->name(),
203 mode,
204 m_store ? m_store->name() : "")),
205 m_key (m_ownedKey.get())
206 {
207 m_ownedKey->setOwningHandle (this);
208 setProxy (proxy);
209 }
void setProxy(SG::DataProxy *proxy)
Set a new proxy.

◆ VarHandleBase() [5/6]

SG::VarHandleBase::VarHandleBase ( const VarHandleBase & rhs)

Copy constructor.

Definition at line 215 of file StoreGate/src/VarHandleBase.cxx.

215 :
216 IResetable(),
217 m_ptr(rhs.m_ptr),
218 m_proxy(nullptr),
219 m_store(rhs.m_store),
220 m_storeWasSet(rhs.m_storeWasSet)
221 {
222 if (rhs.m_ownedKey) {
223 m_ownedKey = std::make_unique<VarHandleKey> (*rhs.m_ownedKey);
224 m_ownedKey->setOwningHandle (this);
225 m_key = m_ownedKey.get();
226 }
227 else {
228 m_key = rhs.m_key;
229 }
230#ifdef DEBUG_VHB
231 dbg::print(stderr, "::VHB::copy constr from {} to {} with proxy={} => {}, key={}, store={}\n", dbg::ptr(&rhs), dbg::ptr(this), dbg::proxy(this->m_proxy), dbg::proxy(rhs.m_proxy), this->key(), dbg::store(this->m_store));
232#endif
233
234 setProxy (rhs.m_proxy);
235 }

◆ VarHandleBase() [6/6]

SG::VarHandleBase::VarHandleBase ( VarHandleBase && rhs)
noexcept

Move constructor.

Definition at line 241 of file StoreGate/src/VarHandleBase.cxx.

241 :
242 IResetable(),
243 m_ptr(rhs.m_ptr),
244 m_proxy(nullptr),
245 m_store(rhs.m_store),
246 m_storeWasSet(rhs.m_storeWasSet),
247 m_ownedKey (std::move (rhs.m_ownedKey)),
248 m_key (rhs.m_key)
249 {
250 if (m_ownedKey) {
251 m_ownedKey->setOwningHandle (this);
252 }
253 rhs.m_ptr=0;
254
255 if (rhs.m_proxy) {
256 if (m_ownedKey) {
257 rhs.m_proxy->unbindHandle (&rhs);
258 rhs.m_proxy->bindHandle(this);
259 }
260 m_proxy = rhs.m_proxy;
261 rhs.m_proxy=0; //no release: this has the ref now
262 }
263#ifdef DEBUG_VHB
264 dbg::print(stderr, "::VHB::move constr from {} to {} with proxy={}, key={}, store={}\n", dbg::ptr(&rhs), dbg::ptr(this), dbg::proxy(this->m_proxy), this->key(), dbg::store(this->m_store));
265#endif
266 }

◆ ~VarHandleBase()

SG::VarHandleBase::~VarHandleBase ( )
overridevirtual

Destructor.

Definition at line 337 of file StoreGate/src/VarHandleBase.cxx.

338 {
339#ifdef DEBUG_VHB
340 dbg::print(stderr, "::VHB:: DESTROY {} with ptr={}, proxy={}, key={}, store={}\n", dbg::ptr(this), dbg::ptr(this->m_ptr), dbg::proxy(this->m_proxy), this->key(), dbg::store(this->m_store));
341#endif
342
343 if (m_ownedKey) {
344 resetProxy();
345 }
346 m_ptr = 0;
347 }
void resetProxy()
Clear the m_proxy field and release the old proxy.

Member Function Documentation

◆ assign()

StatusCode SG::VarHandleBase::assign ( const std::string & sgkey)

Update the underlying key from a string.

If this handle was initialized from a HandleKey, then this doesn't work (since the HandleKey is const). ExcNonConstHandleKey will be thrown in that case.

See VarHandleKey::assign.

Definition at line 648 of file StoreGate/src/VarHandleBase.cxx.

649 {
650 return vhKey().assign (sgkey);
651 }
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
virtual StatusCode assign(const std::string &sgkey)
Change the key of the object to which we're referring.

◆ clid()

CLID SG::VarHandleBase::clid ( ) const

Return the class ID for the referenced object.

◆ finalReset()

void SG::VarHandleBase::finalReset ( )
finaloverridevirtual

Reset this handle at the end of processing.

hard If true, anything depending on the event store is cleared.

Same as reset(true);

Reimplemented from IResetable.

Definition at line 601 of file StoreGate/src/VarHandleBase.cxx.

601 {
602#ifdef DEBUG_VHB
603 dbg::print(stderr, "::VHB::finalReset {} with proxy={}, key={}, store={}\n", dbg::ptr(this), dbg::proxy(m_proxy), this->key(), dbg::store(this->m_store));
604#endif
605 reset (true);
606 }
virtual void reset(bool hard) override
Reset this handle.

◆ fullKey()

const DataObjID & SG::VarHandleBase::fullKey ( ) const

Return the key as a DataObjID.

◆ get_impl()

const void * SG::VarHandleBase::get_impl ( const EventContext * ctx,
bool quiet = defaultQuiet ) const
protected

Definition at line 890 of file StoreGate/src/VarHandleBase.cxx.

892 {
893 if (this->mode() != Gaudi::DataHandle::Reader) {
894 if (!quiet)
895 REPORT_ERROR (StatusCode::FAILURE)
896 << "get_impl called for a non-read handle.";
897 return nullptr;
898 }
899
900 if (this->key().empty()) {
901 if (!quiet)
902 REPORT_ERROR (StatusCode::FAILURE)
903 << "Cannot initialize a Read/Write/Update handle with a null key.";
904 return nullptr;
905 }
906
907 IProxyDict* store = storeFromHandle (ctx);
908 if (!store) {
909 if (!quiet)
910 REPORT_ERROR (StatusCode::FAILURE) << "No store.";
911 return nullptr;
912 }
913
914 SG::DataProxy* proxy = store->proxy_exact(m_key->hashedKey());
915 if (!proxy) {
916 proxy = store->proxy(this->clid(), this->key());
917 if (!proxy) {
918 if (!quiet)
919 REPORT_ERROR (StatusCode::FAILURE)
920 << "Cannot find proxy for "
921 << this->clid() << "/" << this->key();
922 return nullptr;
923 }
924 }
925
927 }
#define REPORT_ERROR(SC)
Report an error.
static const Attributes_t empty
IProxyDict * storeFromHandle(const EventContext *ctx) const
Return the store instance to use.
void * typeless_dataPointer_fromProxy(SG::DataProxy *proxy, bool quiet) const
Retrieve a pointer from a proxy.
std::string store() const
Return the name of the store holding the object we are proxying.

◆ initialize()

StatusCode SG::VarHandleBase::initialize ( bool used = true)

Verify that the handle has been configured properly.

Parameters
usedIf false, then this handle is not to be used. Instead of normal initialization, the key will be cleared.

This will return failure if the key is blank or if the event store cannot be found.

Definition at line 458 of file StoreGate/src/VarHandleBase.cxx.

459 {
460 if (!used) {
461 if (m_ownedKey) {
462 CHECK( m_ownedKey->initialize (used) );
463 }
464 return StatusCode::SUCCESS;
465 }
466
467 if (!m_store) {
468 if (m_ownedKey) {
469 CHECK( m_ownedKey->initialize() );
470 }
471 m_store = &*(this->storeHandle());
472 m_storeWasSet = false;
473 }
474
475 if (!m_store) {
476 return StatusCode::FAILURE;
477 }
478
479 return StatusCode::SUCCESS;
480 }
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.

◆ isConst()

bool SG::VarHandleBase::isConst ( ) const

True if this handle has a proxy, and the proxy is const.

Refers to the state of the proxy, not of the handle.

Definition at line 438 of file StoreGate/src/VarHandleBase.cxx.

439 {
440#ifdef DEBUG_VHB
441 dbg::print(stderr, "::VHB::isConst({}, proxy={}) const\n", dbg::ptr(this), dbg::proxy(m_proxy));
442#endif
443 return 0 != m_proxy
444 ? m_proxy->isConst()
445 : false;
446 }

◆ isInitialized()

bool SG::VarHandleBase::isInitialized ( ) const

Has a proxy been retrieved from SG?

(Weaker test than isValid, but does not touch the disk.)

Definition at line 412 of file StoreGate/src/VarHandleBase.cxx.

413 {
414#ifdef DEBUG_VHB
415 dbg::print(stderr, "::VHB::isInitialized({}, proxy={}) const\n", dbg::ptr(this), dbg::proxy(m_proxy));
416#endif
417 return (0 != m_proxy);
418 }

◆ isPresent()

bool SG::VarHandleBase::isPresent ( ) const

Is the referenced object present in SG?

Const method; the handle does not change as a result of this.

Definition at line 400 of file StoreGate/src/VarHandleBase.cxx.

401 {
402 return isPresent_impl (key());
403 }
bool isPresent_impl(const std::string &key) const
Is the referenced object present in SG?

◆ isPresent_impl()

bool SG::VarHandleBase::isPresent_impl ( const std::string & key) const
protected

Is the referenced object present in SG?

Parameters
keySG key to test.

Const method; the handle does not change as a result of this.

Definition at line 1115 of file StoreGate/src/VarHandleBase.cxx.

1116 {
1117 const DataProxy* proxy = m_proxy;
1118 if (!proxy) {
1119 const IProxyDict* store = m_store;
1120 if (!store)
1121 store = this->storeHandle().get();
1122 if (store)
1123 proxy = store->proxy(this->clid(), key);
1124 }
1125 if (proxy) {
1126 return proxy->isValid();
1127 }
1128 return false;
1129 }

◆ isSet()

bool SG::VarHandleBase::isSet ( ) const
finaloverridevirtual

Has a proxy been retrieved from SG?

Same as isInitialized; this is an interface required by IResetable.

Implements IResetable.

Definition at line 426 of file StoreGate/src/VarHandleBase.cxx.

427 {
428 return isInitialized();
429 }
bool isInitialized() const
Has a proxy been retrieved from SG?

◆ isValid()

virtual bool SG::VarHandleBase::isValid ( )
pure virtual

Can the handle be successfully dereferenced?

Non-const method; the handle may cache information as a result of this.

Implemented in SG::ReadHandle< T >, SG::ReadHandle< AthenaHitsVector< LArG4H6FrontHit > >, SG::ReadHandle< DataVector< IParticle > >, SG::ReadHandle< DataVector< Trk::Track > >, SG::ReadHandle< DataVector< xAOD::Electron_v1 > >, SG::ReadHandle< DataVector< xAOD::Jet_v1 > >, SG::ReadHandle< DataVector< xAOD::TrackParticle_v1 > >, SG::ReadHandle< IDC >, SG::ReadHandle< LArHitContainer >, SG::ReadHandle< LVL1::jTowerContainer >, SG::ReadHandle< McEventCollection >, SG::ReadHandle< MyDataObj >, SG::ReadHandle< PixelGangedClusterAmbiguities >, SG::ReadHandle< SpacePointContainer >, SG::ReadHandle< SpacePointOverlapCollection >, SG::ReadHandle< T_Cont >, SG::ReadHandle< TBEventInfo >, SG::ReadHandle< Trk::PRDtoTrackMap >, SG::ReadHandle< VxContainer >, SG::ReadHandle< xAOD::CaloClusterContainer >, SG::TypelessWriteHandle, SG::UpdateHandle< T >, SG::UpdateHandle< IDCBackend >, SG::WriteHandle< T >, SG::WriteHandle< AthenaHitsVector< LArG4H6FrontHit > >, SG::WriteHandle< AthenaHitsVector< LArG4H6WarmTCHit > >, SG::WriteHandle< AtlasHitsVector< AFP_SIDSimHit > >, SG::WriteHandle< AtlasHitsVector< AFP_TDSimHit > >, SG::WriteHandle< AtlasHitsVector< ALFA_Hit > >, SG::WriteHandle< AtlasHitsVector< ALFA_ODHit > >, SG::WriteHandle< AtlasHitsVector< CSCSimHit > >, SG::WriteHandle< AtlasHitsVector< GenericMuonSimHit > >, SG::WriteHandle< AtlasHitsVector< LUCID_SimHit > >, SG::WriteHandle< AtlasHitsVector< MDTSimHit > >, SG::WriteHandle< AtlasHitsVector< MMSimHit > >, SG::WriteHandle< AtlasHitsVector< RPCSimHit > >, SG::WriteHandle< AtlasHitsVector< SiHit > >, SG::WriteHandle< AtlasHitsVector< sTGCSimHit > >, SG::WriteHandle< AtlasHitsVector< TGCSimHit > >, SG::WriteHandle< AtlasHitsVector< TileHit > >, SG::WriteHandle< AtlasHitsVector< TrackRecord > >, SG::WriteHandle< CaloCalibrationHitContainer >, SG::WriteHandle< CaloCellContainer >, SG::WriteHandle< CaloClusterCellLinkContainer >, SG::WriteHandle< DataVector< Particle_v1 > >, SG::WriteHandle< DataVector< sTgcPadHit_v1 > >, SG::WriteHandle< DataVector< sTgcStripCluster_v1 > >, SG::WriteHandle< DataVector< sTgcWireHit_v1 > >, SG::WriteHandle< DataVector< TgcStrip_v1 > >, SG::WriteHandle< DataVector< TrigComposite_v1 > >, SG::WriteHandle< DataVector< xAOD::CaloRings_v1 > >, SG::WriteHandle< DataVector< xAOD::MuonSimHit_v1 > >, SG::WriteHandle< DataVector< xAOD::RingSet_v1 > >, SG::WriteHandle< DataVector< xAOD::TrigMissingET_v1 > >, SG::WriteHandle< DataVector< xAOD::Vertex_v1 > >, SG::WriteHandle< DecisionContainer >, SG::WriteHandle< HGTD_ALTIROC_RDO_Container >, SG::WriteHandle< HGTD_RDO_Container >, SG::WriteHandle< HijingEventParams >, SG::WriteHandle< HitContainerType >, SG::WriteHandle< IDC >, SG::WriteHandle< InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > >, SG::WriteHandle< InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > >, SG::WriteHandle< InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > >, SG::WriteHandle< InDetSimDataCollection >, SG::WriteHandle< LArHitContainer >, SG::WriteHandle< McEventCollection >, SG::WriteHandle< Muon::MuonPrepDataContainer< MuonPrepDataCollection< PrdType > > >, SG::WriteHandle< SG::ThinningDecision >, SG::WriteHandle< TBEventInfo >, SG::WriteHandle< TBTrack >, SG::WriteHandle< TrigRoiDescriptorCollection >, SG::WriteHandle< xAOD::AuxiliaryMeasurementContainer >, SG::WriteHandle< xAOD::CaloClusterContainer >, SG::WriteHandle< xAOD::VertexAuxContainer_v1 >, and SG::WriteHandle< ZDC_SimFiberHit_Collection >.

◆ key()

const std::string & SG::VarHandleBase::key ( ) const
finaloverridevirtual

Return the StoreGate ID for the referenced object.

This is defined in VarHandleKey. We need to redefine it here because it's also in IResetable. (Otherwise there would be an ambiguity.)

Implements IResetable.

Definition at line 64 of file AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx.

65 {
66 return m_key->key();
67 }

◆ mode()

Gaudi::DataHandle::Mode SG::VarHandleBase::mode ( ) const

Return the mode (read/write/update) for this handle.

◆ name()

const std::string & SG::VarHandleBase::name ( ) const

Return the StoreGate ID for the referenced object.

A synonym for key().

Definition at line 75 of file AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx.

76 {
77 return this->key();
78 }

◆ objKey()

const std::string & SG::VarHandleBase::objKey ( ) const

Return the key string of the underlying DataObjID.

Compared to key(), this will be prefixed with the store name.

◆ operator=() [1/2]

VarHandleBase & SG::VarHandleBase::operator= ( const VarHandleBase & rhs)

Assignment operator.

Definition at line 273 of file StoreGate/src/VarHandleBase.cxx.

274 {
275 if (this != &rhs) {
276 if (rhs.m_ownedKey) {
277 m_ownedKey = std::make_unique<VarHandleKey> (*rhs.m_ownedKey);
278 m_ownedKey->setOwningHandle (this);
279 m_key = m_ownedKey.get();
280 }
281 else {
282 m_key = rhs.m_key;
283 m_ownedKey.reset();
284 }
285
286 m_ptr = rhs.m_ptr;
287 m_store = rhs.m_store;
288 m_storeWasSet = rhs.m_storeWasSet;
289 setProxy (rhs.m_proxy);
290 }
291#ifdef DEBUG_VHB
292 dbg::print(stderr, "::VHB::assignment from {} to {} with proxy={}, key={}, store={}\n", dbg::ptr(&rhs), dbg::ptr(this), dbg::proxy(this->m_proxy), this->key(), dbg::store(this->m_store));
293#endif
294 return *this;
295 }

◆ operator=() [2/2]

VarHandleBase & SG::VarHandleBase::operator= ( VarHandleBase && rhs)
noexcept

Move operator.

Definition at line 302 of file StoreGate/src/VarHandleBase.cxx.

303 {
304 if (this != &rhs) {
305 m_ownedKey = std::move (rhs.m_ownedKey);
306 if (m_ownedKey) {
307 m_ownedKey->setOwningHandle (this);
308 }
309 m_key = rhs.m_key;
310
311 m_ptr = rhs.m_ptr;
312 m_store = rhs.m_store;
313 m_storeWasSet = rhs.m_storeWasSet;
314
315 rhs.m_ptr=0;
316
317 resetProxy();
318 if (rhs.m_proxy) {
319 if (m_ownedKey) {
320 rhs.m_proxy->unbindHandle (&rhs);
321 rhs.m_proxy->bindHandle (this);
322 }
323 m_proxy = rhs.m_proxy;
324 rhs.m_proxy=0; //no release: this has the ref now
325 }
326 }
327#ifdef DEBUG_VHB
328 dbg::print(stderr, "::VHB:: move assign from {} to {} with proxy={}, key={}, store={}\n", dbg::ptr(&rhs), dbg::ptr(this), dbg::proxy(this->m_proxy), this->key(), dbg::store(this->m_store));
329#endif
330 return *this;
331 }

◆ put_impl()

const void * SG::VarHandleBase::put_impl ( const EventContext * ctx,
std::unique_ptr< DataObject > dobj,
const void * dataPtr,
bool allowMods,
bool returnExisting,
IProxyDict *& store ) const
protected

Helper to record an object in the event store.

Unlike record, put does not change the handle and does not cache the pointer in the handle.

Parameters
ctxThe event context, or nullptr to use the current context.
dobjThe wrapped data object (DataBucket) to record.
dataPtrPointer to the transient object itself.
allowModsIf false, record the object as const.
returnExistingAllow an existing object.
[out]storeThe store being used.

Returns the object placed in the store, or nullptr if there was an error. If there was already an object in the store with the given key, then return null, unless returnExisting is true, in which case return success. In either case, dobj is destroyed.

Definition at line 792 of file StoreGate/src/VarHandleBase.cxx.

798 {
799 if (this->name().empty()) {
800 REPORT_ERROR (StatusCode::FAILURE) << "Attempt to record an object with a null key";
801 return nullptr;
802 }
803
804 store = storeFromHandle (ctx);
805 if (!store) {
806 REPORT_ERROR (StatusCode::FAILURE) << "No store.";
807 return nullptr;
808 }
809 if (!dobj) {
810 REPORT_ERROR (StatusCode::FAILURE) << "Attempt to record null pointer.";
811 return nullptr;
812 }
813
814 SG::DataObjectSharedPtr<DataObject> sptr (std::move (dobj));
815 unsigned int initRefCount = sptr->refCount();
816 SG::DataProxy* new_proxy =
817 store->recordObject (sptr, this->name(), allowMods, returnExisting);
818 if (!new_proxy) {
819 REPORT_ERROR (StatusCode::FAILURE) << "recordObject failed";
820 return nullptr;
821 }
822
823 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->isValid()) {
824 // If the reference count hasn't changed, then we've returned an existing
825 // object rather than recording a new one. Retrieve the pointer.
826 dataPtr = typeless_dataPointer_fromProxy (new_proxy, true);
827 }
828
829 return dataPtr;
830 }
bool isValid() const
called by destructor
const std::string & name() const
Return the StoreGate ID for the referenced object.
CxxUtils::RefCountedPtr< T > DataObjectSharedPtr

◆ record_impl()

StatusCode SG::VarHandleBase::record_impl ( std::unique_ptr< DataObject > dobj,
void * dataPtr,
bool allowMods,
bool returnExisting )
protected

Helper to record an object in the event store.

Parameters
Thewrapped data object (DataBucket) to record.
dataPtrPointer to the transient object itself.
allowModsIf false, record the object as const.
returnExistingAllow an existing object.

If there is already an existing object with our key, then return failure, unless returnExisting is true, in which case return success. In either case, dobj is destroyed.

Definition at line 719 of file StoreGate/src/VarHandleBase.cxx.

723 {
724 if (!m_store) {
725 if (m_ownedKey) {
726 CHECK (m_ownedKey->initialize());
727 }
728 m_store = &*(this->storeHandle());
729 m_storeWasSet = false;
730 }
731
732 if (this->name().empty()) {
733 REPORT_ERROR (StatusCode::FAILURE) << "Attempt to record an object with a null key";
734 return StatusCode::FAILURE;
735 }
736 if (!dobj) {
737 REPORT_ERROR (StatusCode::FAILURE) << "Attempt to record null pointer";
738 return StatusCode::FAILURE;
739 }
740
741 SG::DataObjectSharedPtr<DataObject> sptr (dobj.release());
742 unsigned int initRefCount = sptr->refCount();
743 SG::DataProxy* new_proxy =
744 m_store->recordObject (sptr, this->name(), allowMods, returnExisting);
745 if (!new_proxy) {
746 REPORT_ERROR (StatusCode::FAILURE) << "recordObject failed";
747 resetProxy();
748 return StatusCode::FAILURE;
749 }
750 if (m_proxy != new_proxy) {
751 CHECK (this->setState (new_proxy));
752 }
753
754 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->isValid()) {
755 // If the reference count hasn't changed, then we've returned an existing
756 // object rather than recording a new one. Retrieve the pointer, making
757 // sure that it isn't const.
758 if (m_proxy->isConst()) {
759 REPORT_ERROR (StatusCode::FAILURE)
760 << "Found an existing const object from recordOrRetrieve.";
761 return StatusCode::FAILURE;
762 }
764 if (!allowMods)
765 CHECK( setConst() );
766 }
767 else
768 m_ptr=(void*)dataPtr;
769
770 return StatusCode::SUCCESS;
771 }
StatusCode setState()
Retrieve and cache all information managed by a handle.
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
void * typeless_dataPointer_impl(bool quiet)
Retrieve an object from StoreGate.

◆ reset()

void SG::VarHandleBase::reset ( bool hard)
overridevirtual

Reset this handle.

Parameters
hardIf true, anything depending on the event store is cleared.

If the handle stays associated with a given event store, then hard=false. In that case, we clear the cached pointer; the proxy is also dropped if it is reset only. If hard=true, then we always drop the proxy and in addition clear the cached pointer to the event store.

Implements IResetable.

Reimplemented in SG::UpdateHandle< T >, and SG::UpdateHandle< IDCBackend >.

Definition at line 576 of file StoreGate/src/VarHandleBase.cxx.

576 {
577#ifdef DEBUG_VHB
578 dbg::print(stderr, "::VHB::reset {} with proxy={}, key={}, store={} (hard={})\n", dbg::ptr(this), dbg::proxy(m_proxy), this->key(), dbg::store(this->m_store), hard);
579#endif
580 m_ptr = 0;
581
582 if (hard) {
583 m_store = 0;
584 m_storeWasSet = false;
585 }
586
587 //if the proxy is not resetOnly then release it as it will become invalid
588 // Also release on a hard reset.
589 if (0 != m_proxy && (!m_proxy->isResetOnly() || hard)) {
590 resetProxy();
591 }
592 }

◆ resetProxy()

void SG::VarHandleBase::resetProxy ( )
private

Clear the m_proxy field and release the old proxy.

Definition at line 1018 of file StoreGate/src/VarHandleBase.cxx.

1019 {
1020 if (m_proxy) {
1021 if (m_ownedKey) {
1022 m_proxy->unbindHandle(this);
1023 m_proxy->release();
1024 }
1025 m_proxy = nullptr;
1026 }
1027 }

◆ setConst()

StatusCode SG::VarHandleBase::setConst ( )

Set the 'const' bit for the bound proxy in the store.

Definition at line 612 of file StoreGate/src/VarHandleBase.cxx.

613 {
614 if (typeless_dataPointer()) {
615 m_proxy->setConst();
616 return StatusCode::SUCCESS;
617 }
618 return StatusCode::FAILURE;
619 }
void * typeless_dataPointer(bool quiet=defaultQuiet)
Retrieve an object from StoreGate.

◆ setProxy()

void SG::VarHandleBase::setProxy ( SG::DataProxy * proxy)
private

Set a new proxy.

Release any old one first.

Parameters
proxyThe new proxy.

Definition at line 1034 of file StoreGate/src/VarHandleBase.cxx.

1035 {
1036 resetProxy();
1037 if (proxy) {
1038 if (m_ownedKey) {
1039 proxy->addRef();
1040 proxy->bindHandle (this);
1041 }
1042 m_proxy = proxy;
1043 }
1044 }

◆ setProxyDict()

StatusCode SG::VarHandleBase::setProxyDict ( IProxyDict * store)
virtual

Explicitly set the event store.

Parameters
storeThe new event store.

This implicitly does a reset().

Reimplemented in SG::WriteDecorHandle< container_t, xAOD::CaloRingsLinks >, SG::WriteDecorHandle< DataVector< IParticle >, float >, SG::WriteDecorHandle< DataVector< IParticle >, uint32_t >, SG::WriteDecorHandle< DataVector< xAOD::Electron_v1 >, float >, SG::WriteDecorHandle< DataVector< xAOD::Electron_v1 >, int >, SG::WriteDecorHandle< DataVector< xAOD::Jet_v1 >, float >, SG::WriteDecorHandle< DataVector< xAOD::Jet_v1 >, std::vector< float > >, SG::WriteDecorHandle< DataVector< xAOD::Jet_v1 >, std::vector< int > >, SG::WriteDecorHandle< DataVector< xAOD::TrackParticle_v1 >, float >, SG::WriteDecorHandle< DataVector< xAOD::TrackParticle_v1 >, std::vector< bool > >, SG::WriteDecorHandle< DataVector< xAOD::TrackParticle_v1 >, std::vector< float > >, SG::WriteDecorHandle< DataVector< xAOD::TrackParticle_v1 >, std::vector< int > >, SG::WriteDecorHandle< PrdCont_t, bool >, SG::WriteDecorHandle< PrdCont_t, SegLinkVec_t >, SG::WriteDecorHandle< xAOD::CaloClusterContainer, std::vector< ElementLink< xAOD::CaloClusterContainer > > >, SG::WriteDecorHandle< xAOD::IParticleContainer, float >, SG::WriteDecorHandle< xAOD::IParticleContainer, short >, SG::WriteDecorHandle< xAOD::JetContainer, float >, SG::WriteDecorHandle< xAOD::JetContainer, int >, SG::WriteDecorHandle< xAOD::MuonSegmentContainer, float >, SG::WriteDecorHandle< xAOD::MuonSegmentContainer, HitLinkVec_t >, SG::WriteDecorHandle< xAOD::MuonSegmentContainer, SegPars_t >, and SG::WriteDecorHandle< xAOD::TrackParticleContainer, bool >.

Definition at line 557 of file StoreGate/src/VarHandleBase.cxx.

558 {
559 reset(true);
560 m_store = store;
561 m_storeWasSet = true;
562 return StatusCode::SUCCESS;
563 }

◆ setState() [1/3]

StatusCode SG::VarHandleBase::setState ( )

Retrieve and cache all information managed by a handle.

This will retrieve and cache the associated DataProxy.

Note for the case of a WriteHandle that has not yet been written to, the proxy may not exist. We return Success in that case; however, isInitialized will still return false.

Definition at line 493 of file StoreGate/src/VarHandleBase.cxx.

494 {
495 CHECK( initialize() );
496 if (!m_storeWasSet) {
497 IProxyDict* store = storeFromHandle (nullptr);
498 if (store) m_store = store;
499 }
500
501#ifdef DEBUG_VHB
502 dbg::print(stderr, "::VHB:: setState() on {} with key={} ({}) and store={} (CLID: {})\n", dbg::ptr(this), this->key(), m_key->hashedKey(), dbg::store(m_store), this->clid());
503#endif
504
505 SG::DataProxy* proxy = m_store->proxy_exact (m_key->hashedKey());
506 if (!proxy) {
507#ifdef DEBUG_VHB
508 dbg::print(stderr, "::VHB:: setState() on {} ==> null proxy!\n", dbg::ptr(this));
509#endif
510 proxy = m_store->proxy(this->clid(), this->key());
511 }
512
513 if (!proxy) {
514#ifdef DEBUG_VHB
515 dbg::print(stderr, "::VHB:: setState() on {} ==> STILL null proxy!\n", dbg::ptr(this));
516#endif
517 }
518 else if (!proxy->isValid()) {
519#ifdef DEBUG_VHB
520 dbg::print(stderr, "::VHB:: setState() on {} ==> proxy not valid! Dumping Store\n", dbg::ptr(this));
521 if (!m_store) {
522 dbg::print(stderr, "::VHB:: setState() on {} ==> m_store is a nullptr\n", dbg::ptr(this));
523 }
524 else {
525 SGImplSvc* stor = dynamic_cast<SGImplSvc*>(m_store);
526 if (!stor) {
527 dbg::print(stderr, "::VHB:: setState() on {} ==> m_store points not to an SGImplSvc but to a {}\n", dbg::ptr(this), boost::core::demangle(typeid(*m_store).name()));
528 }
529 else {
530 dbg::print(stderr, "\n{}\n", stor->dump());
531 }
532 }
533#endif
534 }
535 StatusCode sc = this->setState(proxy);
536
537 // Failure to find the proxy is ok in the case of a @c WriteHandle
538 // that has not yet been written to.
539 if (sc.isFailure() && mode() == Gaudi::DataHandle::Writer && m_ptr == nullptr)
540 return StatusCode::SUCCESS;
541
542 return sc;
543 }
static Double_t sc
std::string dump() const
dump objects in store.
::StatusCode StatusCode
StatusCode definition for legacy code.
void initialize()

◆ setState() [2/3]

StatusCode SG::VarHandleBase::setState ( IProxyDict * store,
const std::string & key )
protected

Set the state of a handle from a store and a key name.

Parameters
storeThe event store to access.
nameThe StoreGate key to search for.

Fails if no such object is recorded.

Parameters
storeThe event store to access.
nameThe StoreGate key to search for.

Definition at line 692 of file StoreGate/src/VarHandleBase.cxx.

693 {
694 if (0 == store) {
695 return StatusCode::FAILURE;
696 }
697#ifdef DEBUG_VHB
698 dbg::print(stderr, "::VHB::setState({}, store={}, key={}) const\n", dbg::ptr(this), dbg::store(store), key);
699#endif
700 CLID cid = this->clid();
701 SG::DataProxy* proxy = store->proxy(cid, key);
702 // std::cerr << "::VHB:: -- clid=[" << cid << "] proxy=[" << proxy << "]\n";
703 return this->setState(proxy);
704 }
uint32_t CLID
The Class ID type.

◆ setState() [3/3]

StatusCode SG::VarHandleBase::setState ( SG::DataProxy * proxy)
protected

Set the state of the handle to a given proxy.

Parameters
proxyThe proxy to set.

The proxy must be valid; otherwise FAILURE will be returned.

Definition at line 666 of file StoreGate/src/VarHandleBase.cxx.

667 {
668#ifdef DEBUG_VHB
669 dbg::print(stderr, "::VHB::setState({}, proxy={}) const\n", dbg::ptr(this), dbg::proxy(proxy));
670#endif
671 if (0 == proxy || !proxy->isValid()) {
672 return StatusCode::FAILURE;
673 }
674
675 if (m_proxy != proxy) {
676 // We're changing proxies. Release the old and bind to the new.
677 setProxy (proxy);
678 // Clear cached pointer.
679 m_ptr=0;
680 }
681
682 return StatusCode::SUCCESS;
683 }

◆ setStoreFromHandle()

bool SG::VarHandleBase::setStoreFromHandle ( const EventContext * ctx)
private

Initialize the store pointer from the store handle.

Also checks that the key is valid.

Parameters
ctxThe current event context, or nullptr.

Returns true on success.

Definition at line 1001 of file StoreGate/src/VarHandleBase.cxx.

1002 {
1003 if (m_ownedKey) {
1004 if (m_ownedKey->initialize().isFailure()) {
1005 return false;
1006 }
1007 }
1008 m_store = storeFromHandle (ctx);
1009 m_storeWasSet = (ctx && m_store ==
1010 Atlas::getExtendedEventContext(*ctx).proxy());
1011 return true;
1012 }
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.

◆ store()

std::string SG::VarHandleBase::store ( ) const

Return the name of the store holding the object we are proxying.

Definition at line 382 of file StoreGate/src/VarHandleBase.cxx.

383 {
384 if (m_store)
385 return m_store->name();
386 return this->storeHandle().name();
387 }

◆ storeFromHandle()

IProxyDict * SG::VarHandleBase::storeFromHandle ( const EventContext * ctx) const
private

Return the store instance to use.

Parameters
ctxThe current event context, or nullptr.
ctxThe current event context, or nullptr.

If we're referencing the default event store, pick the specific store to use in this order:

  • Store associated with an explicitly-provided context.
  • A store explicitly set via setProxyDict.
  • Store associated with the current context.

For another store:

  • A store explicitly set via setProxyDict.
  • The store retrieved from the handle, resolved to the current slot if it's a hive store.

Definition at line 971 of file StoreGate/src/VarHandleBase.cxx.

972 {
973 if (m_key->isEventStore()) {
974 if (ctx)
975 return Atlas::getExtendedEventContext(*ctx).proxy();
976 if (m_storeWasSet && m_store) return m_store;
977
978 if ( Atlas::hasExtendedEventContext (Gaudi::Hive::currentContext()) ) {
979 return Atlas::getExtendedEventContext (Gaudi::Hive::currentContext()).proxy();
980 } else {
981 return nullptr;
982 }
983 }
984
985 if (m_storeWasSet && m_store) return m_store;
986 IProxyDict* store = m_store;
987 if (!store)
988 store = &*this->storeHandle();
989
990 return store->hiveProxyDict();
991 }
bool hasExtendedEventContext(const EventContext &ctx)
Test whether a context object has an extended context installed.

◆ storeHandle()

const ServiceHandle< IProxyDict > & SG::VarHandleBase::storeHandle ( ) const

Return handle to the referenced store.

◆ symLink_impl()

StatusCode SG::VarHandleBase::symLink_impl ( CLID newClid,
const std::string & newKey )
protected

Make a symlink or alias to the object currently referenced by this handle.

Parameters
newClidCLID of link.
newKeySG key of link.

If newClid matches the existing clid, then make an alias. If newKey matches the existing key, then make a symlink. If neither match, it's an error.

Definition at line 940 of file StoreGate/src/VarHandleBase.cxx.

942 {
943 if (!m_ptr || !m_store) {
944 REPORT_ERROR (StatusCode::FAILURE) << "symlink: Handle not valid.";
945 return StatusCode::FAILURE;
946 }
947
948 SG::DataObjectSharedPtr<DataObject> obj (new SymlinkDataObject (newClid, m_ptr));
949 SG::DataProxy* prox = m_store->recordObject (obj, newKey, false, true);
950 if (!prox)
951 return StatusCode::FAILURE;
952 return StatusCode::SUCCESS;
953 }

◆ typeless_cptr()

const void * SG::VarHandleBase::typeless_cptr ( )
protected

Retrieve an object from StoreGate as a const pointer.

Same as typeless_dataPointer with the return value converted to const.

◆ typeless_dataPointer()

void * SG::VarHandleBase::typeless_dataPointer ( bool quiet = defaultQuiet)
protected

Retrieve an object from StoreGate.

Parameters
quietIf true, suppress failure messages.

Inline method: first check cached pointer, then call the _impl method.

◆ typeless_dataPointer_fromProxy()

void * SG::VarHandleBase::typeless_dataPointer_fromProxy ( SG::DataProxy * proxy,
bool quiet ) const
private

Retrieve a pointer from a proxy.

Parameters
proxyThe proxy object.
quietIf true, suppress failure messages.

Warning — doesn't enforce const rules; the caller must do that.

Definition at line 1055 of file StoreGate/src/VarHandleBase.cxx.

1057 {
1058 if (!proxy || !proxy->isValid()) {
1059 // invalid proxy
1060 if (!quiet) {
1061 REPORT_MESSAGE(MSG::WARNING)
1062 << "Proxy "
1063 << " [" << (proxy != 0 ? proxy->clID() : 0)
1064 << "/" << (proxy != 0
1065 ? proxy->name()
1066 : std::string("<N/A>"))
1067 << "] is in an invalid state";
1068 } //quiet
1069 return nullptr;
1070 }
1071
1072 DataObject* dobj = proxy->accessData();
1073 if (!dobj) {
1074 // invalid dobj
1075 if (!quiet) {
1076 REPORT_MESSAGE(MSG::WARNING)
1077 << "this proxy " << MSG::hex << proxy
1078 << MSG::dec << " has a NULL data object ptr";
1079 }
1080 return nullptr;
1081 }
1082
1083 const CLID clid = this->clid();
1084 void* ptr = SG::Storable_cast(dobj, clid, nullptr, true, proxy);
1085 if (ptr)
1086 return ptr;
1087
1088 // If ptr is null, probably the clid we gave wasn't the clid
1089 // the object was stored with, nor it inherits from it.
1090 // before giving up, let's check its transient CLIDs
1091 DataBucketBase *dbb = 0;
1092 if (proxy->transientID(clid) &&
1093 0 != (dbb = dynamic_cast<DataBucketBase*>(dobj))) {
1094 // it is a symlink after all.
1095 // Let's hard cast (and keep our fingers Xed)
1096 ptr = static_cast<void*>(dbb->object());
1097 } else {
1098 if (!quiet) {
1099 REPORT_MESSAGE(MSG::WARNING)
1100 << "Request for an invalid object; requested CLID = "
1101 << clid
1102 << ", proxy primary ID is " << proxy->clID();
1103 }
1104 } // try symlink -- endif
1105 return ptr;
1106 }
#define REPORT_MESSAGE(LVL)
Report a message.
virtual void * object()=0
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)

◆ typeless_dataPointer_impl()

void * SG::VarHandleBase::typeless_dataPointer_impl ( bool quiet)
protected

Retrieve an object from StoreGate.

Parameters
quietIf true, suppress failure messages.

Definition at line 838 of file StoreGate/src/VarHandleBase.cxx.

839 {
840#ifdef DEBUG_VHB
841 dbg::print(stderr, "::VHB::typeless_dataPointer_impl({}, ptr={}, proxy={}, key={}, store={})\n", dbg::ptr(this), dbg::ptr(this->m_ptr), dbg::proxy(this->m_proxy), this->key(), dbg::store(this->m_store));
842#endif
843
844 // First check for cached pointer.
845 if (0 != m_ptr)
846 return m_ptr;
847
848 if (0 == m_proxy) {
849 // No proxy, need to look it up.
850 if (this->setState().isFailure() || !m_proxy) {
851 if (!quiet) {
852 REPORT_MESSAGE(MSG::WARNING)
853 << "could not get proxy for key " << key();
854 if (this->mode() != Gaudi::DataHandle::Reader) {
855 REPORT_MESSAGE(MSG::WARNING)<< " try using a ReadHandle";
856 }
857 } //quiet
858 return 0;
859 } //setstate
860 } //m_proxy
861
863 return m_ptr;
864 }

◆ typeless_ptr()

void * SG::VarHandleBase::typeless_ptr ( bool quiet = defaultQuiet)
protected

Retrieve an object from StoreGate as non-const pointer.

Calls typeless_dataPointer, then raises an exception if the proxy is marked as const.

Definition at line 873 of file StoreGate/src/VarHandleBase.cxx.

874 {
876 if (p != nullptr && isConst())
877 throw SG::ExcConstObject (clid(), key(), store());
878 return p;
879 }
bool isConst() const
True if this handle has a proxy, and the proxy is const.

◆ vhKey()

SG::VarHandleKey & SG::VarHandleBase::vhKey ( )

Return a non-const reference to the HandleKey.

If this handle was initialized from a HandleKey, then this doesn't work (since the HandleKey is const). ExcNonConstHandleKey will be thrown in that case.

Definition at line 629 of file StoreGate/src/VarHandleBase.cxx.

630 {
631 if (!m_ownedKey) {
632 throwExcNonConstHandleKey (m_key->clid(), m_key->key(),
633 m_key->storeHandle().name());
634 }
635 return *m_ownedKey;
636 }
void throwExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNonConstHandleKey exception.

◆ Athena_test::refCountTest

void Athena_test::refCountTest ( void )
friend

◆ Athena_test::resetableTest

void Athena_test::resetableTest ( void )
friend

◆ Athena_test::varHandleTest

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const VarHandleBase & o )
friend

Return the name of the store holding the object we are proxying.

Output stream.

Output stream.

Parameters
outStream to which to write.
oObject to write.
outStream to which to write.
oObject to write.

Definition at line 107 of file AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx.

108 {
109 out << "VarHandleBase @" << &o
110 // << " store=" <<o.store()
111 << ", key=" <<o.key();
112 return out;
113 }

Member Data Documentation

◆ m_key

const VarHandleKey* SG::VarHandleBase::m_key
private

The associated key object.

If we were initialized from a key object, then this points at that. Otherwise, it points at the same object as m_ownedKey.

Definition at line 525 of file StoreGate/StoreGate/VarHandleBase.h.

◆ m_ownedKey

std::unique_ptr<VarHandleKey> SG::VarHandleBase::m_ownedKey
private

An owned VarHandleKey.

This is set in the case where a VarHandle is not initialized from a key object.

Definition at line 520 of file StoreGate/StoreGate/VarHandleBase.h.

◆ m_proxy

SG::DataProxy* SG::VarHandleBase::m_proxy
protected

Proxy holding the object to which we are bound.

Definition at line 507 of file StoreGate/StoreGate/VarHandleBase.h.

◆ m_ptr

void* SG::VarHandleBase::m_ptr
protected

The object to which we are bound.

Definition at line 504 of file StoreGate/StoreGate/VarHandleBase.h.

◆ m_store

IProxyDict* SG::VarHandleBase::m_store
protected

Pointer to the store that owns the object.

Definition at line 510 of file StoreGate/StoreGate/VarHandleBase.h.

◆ m_storeWasSet

bool SG::VarHandleBase::m_storeWasSet
protected

True if the store was set explicitly via setProxyDict.

Definition at line 513 of file StoreGate/StoreGate/VarHandleBase.h.


The documentation for this class was generated from the following files: