ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
SG::WriteHandle< T > Class Template Reference

#include <WriteHandle.h>

Inheritance diagram for SG::WriteHandle< T >:
Collaboration diagram for SG::WriteHandle< T >:

Public Types

typedef T * pointer_type
 
typedef const T * const_pointer_type
 
typedef T & reference_type
 
typedef const T & const_reference_type
 

Public Member Functions

 WriteHandle ()
 Default constructor. More...
 
 WriteHandle (const std::string &sgkey, const std::string &storename=StoreID::storeName(StoreID::EVENT_STORE))
 Constructor with full arguments. More...
 
 WriteHandle (const WriteHandleKey< T > &key)
 Constructor from a WriteHandleKey. More...
 
 WriteHandle (const WriteHandleKey< T > &key, const EventContext &ctx)
 Constructor from a WriteHandleKey and an explicit event context. More...
 
 WriteHandle (const WriteHandle &rhs)
 Copy constructor. More...
 
 WriteHandle (WriteHandle &&rhs)
 Move constructor. More...
 
WriteHandleoperator= (const WriteHandle &rhs)
 Assignment operator. More...
 
WriteHandleoperator= (WriteHandle &&rhs)
 Move operator. More...
 
 ~WriteHandle ()
 Destructor. More...
 
pointer_type operator-> ()
 Dereference the pointer. More...
 
reference_type operator* ()
 Dereference the pointer. More...
 
const_pointer_type cptr () const
 Dereference the pointer. More...
 
pointer_type ptr ()
 Dereference the pointer. More...
 
pointer_type cachedPtr ()
 Return the cached pointer directly; no lookup. More...
 
virtual bool isValid () override final
 Can the handle be successfully dereferenced? More...
 
StatusCode record (std::unique_ptr< T > data)
 Record a const object to the store. More...
 
StatusCode recordNonConst (std::unique_ptr< T > data)
 Record a non-const object to the store. More...
 
template<class AUXSTORE >
StatusCode record (std::unique_ptr< T > data, std::unique_ptr< AUXSTORE > store)
 Record a const object and its auxiliary store to the store. More...
 
template<class AUXSTORE >
StatusCode recordNonConst (std::unique_ptr< T > data, std::unique_ptr< AUXSTORE > store)
 Record a non-const object and its auxiliary store to the store. More...
 
StatusCode record (SG::DataObjectSharedPtr< T > data)
 Record a const shared DataObject to the store. More...
 
StatusCode recordNonConst (SG::DataObjectSharedPtr< T > data)
 Record a non-const shared DataObject to the store. More...
 
const_pointer_type put (std::unique_ptr< T > data, bool returnExisting=false) const
 Record an object to the store. More...
 
const_pointer_type put (std::unique_ptr< const T > data, bool returnExisting=false) const
 Record an object to the store. More...
 
const_pointer_type put (std::unique_ptr< const ConstDataVector< T > > data, bool returnExisting=false) const
 Record an object to the store. More...
 
const_pointer_type put (const EventContext &ctx, std::unique_ptr< const ConstDataVector< T > > data, bool returnExisting=false) const
 Record an object to the store. More...
 
const_pointer_type put (const EventContext &ctx, std::unique_ptr< T > data, bool returnExisting=false) const
 Record an object to the store. More...
 
const_pointer_type put (const EventContext &ctx, std::unique_ptr< const T > data, bool returnExisting=false) const
 Record an object to the store. More...
 
const_pointer_type put (SG::DataObjectSharedPtr< T > data) const
 Record an object to the store. More...
 
const_pointer_type put (const EventContext &ctx, SG::DataObjectSharedPtr< T > data) const
 Record an object to the store. More...
 
template<class AUXSTORE >
const_pointer_type put (std::unique_ptr< T > data, std::unique_ptr< AUXSTORE > auxstore) const
 Record an object and its auxiliary store to the store. More...
 
template<class AUXSTORE >
const_pointer_type put (std::unique_ptr< const T > data, std::unique_ptr< const AUXSTORE > auxstore) const
 Record an object and its auxiliary store to the store. More...
 
template<class AUXSTORE >
const_pointer_type put (const EventContext &ctx, std::unique_ptr< T > data, std::unique_ptr< AUXSTORE > auxstore) const
 Record an object and its auxiliary store to the store. More...
 
template<class AUXSTORE >
const_pointer_type put (const EventContext &ctx, std::unique_ptr< const T > data, std::unique_ptr< const AUXSTORE > auxstore) const
 Record an object and its auxiliary store to the store. More...
 
WriteHandleoperator= (std::unique_ptr< T > data)
 Alternate notation for record. More...
 
StatusCode alias (const WriteHandleKey< T > &key)
 Make an alias. More...
 
template<class U >
StatusCode symLink (const WriteHandleKey< U > &key)
 Make an explicit link. More...
 
virtual const std::string & key () const override final
 Return the StoreGate ID for the referenced object. More...
 
const std::string & name () const
 Return the StoreGate ID for the referenced object. More...
 
std::string store () const
 Return the name of the store holding the object we are proxying. More...
 
bool isPresent () const
 Is the referenced object present in SG? More...
 
bool isInitialized () const
 Has a proxy been retrieved from SG? More...
 
virtual bool isSet () const override final
 Has a proxy been retrieved from SG? More...
 
bool isConst () const
 True if this handle has a proxy, and the proxy is const. More...
 
StatusCode initialize (bool used=true)
 Verify that the handle has been configured properly. More...
 
StatusCode setState ()
 Retrieve and cache all information managed by a handle. More...
 
virtual StatusCode setProxyDict (IProxyDict *store)
 Explicitly set the event store. More...
 
virtual void reset (bool hard) override
 Reset this handle. More...
 
virtual void finalReset () override final
 Reset this handle at the end of processing. More...
 
StatusCode setConst ()
 Set the 'const' bit for the bound proxy in the store. More...
 
CLID clid () const
 Return the class ID for the referenced object. More...
 
const ServiceHandle< IProxyDict > & storeHandle () const
 Return handle to the referenced store. More...
 
Gaudi::DataHandle::Mode mode () const
 Return the mode (read/write/update) for this handle. More...
 
const std::string & objKey () const
 Return the key string of the underlying DataObjID. More...
 
const DataObjID & fullKey () const
 Return the key as a DataObjID. More...
 
SG::VarHandleKeyvhKey ()
 Return a non-const reference to the HandleKey. More...
 
StatusCode assign (const std::string &sgkey)
 Update the underlying key from a string. More...
 

Protected Member Functions

StatusCode setState (SG::DataProxy *proxy)
 Set the state of the handle to a given proxy. More...
 
StatusCode setState (IProxyDict *store, const std::string &name)
 Set the state of a handle from a store and a key name. More...
 
StatusCode record_impl (std::unique_ptr< DataObject > dobj, void *dataPtr, bool allowMods, bool returnExisting)
 Helper to record an object in the event store. More...
 
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. More...
 
virtual void * typeless_dataPointer_impl (bool quiet)
 Retrieve an object from StoreGate. More...
 
void * typeless_dataPointer (bool quiet=defaultQuiet)
 Retrieve an object from StoreGate. More...
 
const void * typeless_cptr ()
 Retrieve an object from StoreGate as a const pointer. More...
 
void * typeless_ptr (bool quiet=defaultQuiet)
 Retrieve an object from StoreGate as non-const pointer. More...
 
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. More...
 
bool isPresent_impl (const std::string &key) const
 Is the referenced object present in SG? More...
 

Protected Attributes

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

Private Member Functions

pointer_type checkedCachedPtr ()
 Return the cached pointer directly. More...
 
template<class U >
StatusCode doRecord (U data, bool isConst, bool returnExisting)
 Helper for record. More...
 
template<class U >
const_pointer_type doPut (const EventContext *ctx, U data, bool returnExisting, IProxyDict *&store) const
 Helper for put. More...
 
template<class AUXSTORE >
WriteHandle< T >::const_pointer_type doPut (const EventContext *ctx, std::unique_ptr< T > data, std::unique_ptr< AUXSTORE > auxstore) const
 Helper for recording an object and its auxiliary store to the store. More...
 
template<class AUXSTORE >
WriteHandle< T >::const_pointer_type doPut (const EventContext *ctx, std::unique_ptr< const T > data, std::unique_ptr< const AUXSTORE > auxstore) const
 Helper for recording an object and its auxiliary store to the store. More...
 
template<class AUXSTORE >
StatusCode record (std::unique_ptr< T > data, std::unique_ptr< AUXSTORE > auxstore, bool isConst)
 Record an object and its auxiliary store to the store. More...
 
IProxyDictstoreFromHandle (const EventContext *ctx) const
 Return the store instance to use. More...
 
bool setStoreFromHandle (const EventContext *ctx)
 Initialize the store pointer from the store handle. More...
 
void resetProxy ()
 Clear the m_proxy field and release the old proxy. More...
 
void setProxy (SG::DataProxy *proxy)
 Set a new proxy. More...
 
void * typeless_dataPointer_fromProxy (SG::DataProxy *proxy, bool quiet) const
 Retrieve a pointer from a proxy. More...
 

Private Attributes

SG::DataProxym_lockAuxPending = nullptr
 If non-null, then we need to lock the associated aux store object when we're deleted. More...
 
std::unique_ptr< VarHandleKeym_ownedKey
 An owned VarHandleKey. More...
 
const VarHandleKeym_key
 The associated key object. More...
 

Detailed Description

template<class T>
class SG::WriteHandle< T >

Definition at line 74 of file StoreGate/StoreGate/WriteHandle.h.

Member Typedef Documentation

◆ const_pointer_type

template<class T >
typedef const T* SG::WriteHandle< T >::const_pointer_type

Definition at line 79 of file StoreGate/StoreGate/WriteHandle.h.

◆ const_reference_type

template<class T >
typedef const T& SG::WriteHandle< T >::const_reference_type

Definition at line 81 of file StoreGate/StoreGate/WriteHandle.h.

◆ pointer_type

template<class T >
typedef T* SG::WriteHandle< T >::pointer_type

Definition at line 78 of file StoreGate/StoreGate/WriteHandle.h.

◆ reference_type

template<class T >
typedef T& SG::WriteHandle< T >::reference_type

Definition at line 80 of file StoreGate/StoreGate/WriteHandle.h.

Constructor & Destructor Documentation

◆ WriteHandle() [1/6]

template<class T >
SG::WriteHandle< T >::WriteHandle ( )

Default constructor.

The handle will not be usable until a non-blank key is assigned.

◆ WriteHandle() [2/6]

template<class T >
SG::WriteHandle< T >::WriteHandle ( const std::string &  sgkey,
const std::string &  storename = StoreID::storeName(StoreID::EVENT_STORE) 
)
explicit

Constructor with full arguments.

Parameters
sgkeyStoreGate key of the referenced object.
storenameName of the referenced event store.

◆ WriteHandle() [3/6]

template<class T >
SG::WriteHandle< T >::WriteHandle ( const WriteHandleKey< T > &  key)
explicit

Constructor from a WriteHandleKey.

Parameters
keyThe key object holding the clid/key/store.

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

◆ WriteHandle() [4/6]

template<class T >
SG::WriteHandle< T >::WriteHandle ( const WriteHandleKey< T > &  key,
const EventContext &  ctx 
)
explicit

Constructor from a WriteHandleKey and an explicit event context.

Parameters
keyThe key object holding the clid/key.
ctxThe event context.

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 the event context will be used.

◆ WriteHandle() [5/6]

template<class T >
SG::WriteHandle< T >::WriteHandle ( const WriteHandle< T > &  rhs)

Copy constructor.

◆ WriteHandle() [6/6]

template<class T >
SG::WriteHandle< T >::WriteHandle ( WriteHandle< T > &&  rhs)

Move constructor.

◆ ~WriteHandle()

template<class T >
SG::WriteHandle< T >::~WriteHandle ( )

Destructor.

Lock an aux object if m_lockAuxPending is set.

Member Function Documentation

◆ alias()

template<class T >
StatusCode SG::WriteHandle< T >::alias ( const WriteHandleKey< T > &  key)

Make an alias.

Parameters
keyAlternate key by which the referenced object should be known.

The current handle should be valid and referencing an object (i.e., record should have been called on it).

The object will also be known by the name given in key.

◆ assign()

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

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 635 of file StoreGate/src/VarHandleBase.cxx.

636  {
637  return vhKey().assign (sgkey);
638  }

◆ cachedPtr()

template<class T >
pointer_type SG::WriteHandle< T >::cachedPtr ( )

Return the cached pointer directly; no lookup.

◆ checkedCachedPtr()

template<class T >
pointer_type SG::WriteHandle< T >::checkedCachedPtr ( )
private

Return the cached pointer directly.

If it is null, throw ExcNullWriteHandle.

◆ clid()

CLID SG::VarHandleBase::clid ( ) const
inherited

Return the class ID for the referenced object.

◆ cptr()

template<class T >
const_pointer_type SG::WriteHandle< T >::cptr ( ) const

Dereference the pointer.

Returns the cached pointer.

◆ doPut() [1/3]

template<class T >
template<class AUXSTORE >
WriteHandle<T>::const_pointer_type SG::WriteHandle< T >::doPut ( const EventContext *  ctx,
std::unique_ptr< const T >  data,
std::unique_ptr< const AUXSTORE >  auxstore 
) const
private

Helper for recording an object and its auxiliary store to the store.

Parameters
ctxThe event context, or nullptr to use the current context.
dataThe object to record.
auxstoreAuxiliary store object.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, and the objects passed in are destroyed.

◆ doPut() [2/3]

template<class T >
template<class AUXSTORE >
WriteHandle<T>::const_pointer_type SG::WriteHandle< T >::doPut ( const EventContext *  ctx,
std::unique_ptr< T >  data,
std::unique_ptr< AUXSTORE >  auxstore 
) const
private

Helper for recording an object and its auxiliary store to the store.

Parameters
ctxThe event context, or nullptr to use the current context.
dataThe object to record.
auxstoreAuxiliary store object.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, and the objects passed in are destroyed.

◆ doPut() [3/3]

template<class T >
template<class U >
const_pointer_type SG::WriteHandle< T >::doPut ( const EventContext *  ctx,
data,
bool  returnExisting,
IProxyDict *&  store 
) const
private

Helper for put.

Parameters
ctxThe event context, or nullptr to use the current context.
dataThe object to record.
returnExistingAllow an existing object.
[out]storeThe store being used.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ doRecord()

template<class T >
template<class U >
StatusCode SG::WriteHandle< T >::doRecord ( data,
bool  isConst,
bool  returnExisting 
)
private

Helper for record.

Parameters
dataThe object to record.
isConstIf true, record the object as const.
returnExistingAllow an existing object.

◆ finalReset()

void SG::VarHandleBase::finalReset ( )
finaloverridevirtualinherited

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 583 of file StoreGate/src/VarHandleBase.cxx.

583  {
584 #ifdef DEBUG_VHB
585  std::cerr << "::VHB::finalReset("
586  << "ptr=" << this->m_ptr << ", "
587  << "proxy=" << this->m_proxy << ", "
588  << "key=" <<this->key()
589  << ")..."
590  << std::endl;
591 #endif
592  reset (true);
593  }

◆ fullKey()

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

Return the key as a DataObjID.

◆ get_impl()

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

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

888  {
889  if (this->mode() != Gaudi::DataHandle::Reader) {
890  if (!quiet)
891  REPORT_ERROR (StatusCode::FAILURE)
892  << "get_impl called for a non-read handle.";
893  return nullptr;
894  }
895 
896  if (this->key().empty()) {
897  if (!quiet)
898  REPORT_ERROR (StatusCode::FAILURE)
899  << "Cannot initialize a Read/Write/Update handle with a null key.";
900  return nullptr;
901  }
902 
904  if (!store) {
905  if (!quiet)
906  REPORT_ERROR (StatusCode::FAILURE) << "No store.";
907  return nullptr;
908  }
909 
910  SG::DataProxy* proxy = store->proxy (this->clid(), this->key());
911  if (!proxy) {
912  if (!quiet)
913  REPORT_ERROR (StatusCode::FAILURE)
914  << "Cannot find proxy for "
915  << this->clid() << "/" << this->key();
916  return nullptr;
917  }
918 
919  return typeless_dataPointer_fromProxy (proxy, quiet);
920  }

◆ initialize()

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

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 465 of file StoreGate/src/VarHandleBase.cxx.

466  {
467  if (!used) {
468  if (m_ownedKey) {
469  CHECK( m_ownedKey->initialize (used) );
470  }
471  return StatusCode::SUCCESS;
472  }
473 
474  if (!m_store) {
475  if (m_ownedKey) {
476  CHECK( m_ownedKey->initialize() );
477  }
478  m_store = &*(this->storeHandle());
479  m_storeWasSet = false;
480  }
481 
482  if (!m_store) {
483  return StatusCode::FAILURE;
484  }
485 
486  return StatusCode::SUCCESS;
487  }

◆ isConst()

bool SG::VarHandleBase::isConst ( ) const
inherited

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 437 of file StoreGate/src/VarHandleBase.cxx.

438  {
439 #ifdef DEBUG_VHB
440  std::cerr << "::VHB::isConst("
441  << this
442  << ", proxy" << m_proxy;
443  if (m_proxy) {
444  std::cerr
445  << " -- isValid: " << m_proxy->isValid()
446  << " -- isConst: " << m_proxy->isConst();
447  }
448  std::cerr << ") const\n";
449 #endif
450  return 0 != m_proxy
451  ? m_proxy->isConst()
452  : false;
453  }

◆ isInitialized()

bool SG::VarHandleBase::isInitialized ( ) const
inherited

Has a proxy been retrieved from SG?

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

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

410  {
411 #ifdef DEBUG_VHB
412  std::cerr << "::VHB::isInitialized("
413  << this
414  << ", proxy" << m_proxy << ") const\n";
415 #endif
416  return (0 != m_proxy);
417  }

◆ isPresent()

bool SG::VarHandleBase::isPresent ( ) const
inherited

Is the referenced object present in SG?

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

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

398  {
399  return isPresent_impl (key());
400  }

◆ isPresent_impl()

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

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 1108 of file StoreGate/src/VarHandleBase.cxx.

1109  {
1110  const DataProxy* proxy = m_proxy;
1111  if (!proxy) {
1112  const IProxyDict* store = m_store;
1113  if (!store)
1114  store = this->storeHandle().get();
1115  if (store)
1116  proxy = store->proxy(this->clid(), key);
1117  }
1118  if (proxy) {
1119  return proxy->isValid();
1120  }
1121  return false;
1122  }

◆ isSet()

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

Has a proxy been retrieved from SG?

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

Implements IResetable.

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

426  {
427  return isInitialized();
428  }

◆ isValid()

template<class T >
virtual bool SG::WriteHandle< T >::isValid ( )
finaloverridevirtual

Can the handle be successfully dereferenced?

Implements SG::VarHandleBase.

◆ key()

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

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
inherited

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

◆ name()

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

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
inherited

Return the key string of the underlying DataObjID.

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

◆ operator*()

template<class T >
reference_type SG::WriteHandle< T >::operator* ( )

Dereference the pointer.

Returns the cached pointer. Throws ExcNullWriteHandle if null.

◆ operator->()

template<class T >
pointer_type SG::WriteHandle< T >::operator-> ( )

Dereference the pointer.

Returns the cached pointer. Throws ExcNullWriteHandle if null.

◆ operator=() [1/3]

template<class T >
WriteHandle& SG::WriteHandle< T >::operator= ( const WriteHandle< T > &  rhs)

Assignment operator.

◆ operator=() [2/3]

template<class T >
WriteHandle& SG::WriteHandle< T >::operator= ( std::unique_ptr< T >  data)

Alternate notation for record.

Records a non-const object.

Parameters
dataObject to record.

Throws an exception on failure.

◆ operator=() [3/3]

template<class T >
WriteHandle& SG::WriteHandle< T >::operator= ( WriteHandle< T > &&  rhs)

Move operator.

◆ ptr()

template<class T >
pointer_type SG::WriteHandle< T >::ptr ( )

Dereference the pointer.

Returns the cached pointer.

◆ put() [1/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( const EventContext &  ctx,
SG::DataObjectSharedPtr< T >  data 
) const

Record an object to the store.

Parameters
ctxThe event context to use.
dataThe object to record.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. Returns the object placed in the store, or nullptr if there was an error.

The event store takes shared ownership of the object.

◆ put() [2/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( const EventContext &  ctx,
std::unique_ptr< const ConstDataVector< T > >  data,
bool  returnExisting = false 
) const

Record an object to the store.

Parameters
ctxThe event context to use.
dataThe object to record.
returnExistingAllow an existing object?

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ put() [3/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( const EventContext &  ctx,
std::unique_ptr< const T >  data,
bool  returnExisting = false 
) const

Record an object to the store.

Parameters
ctxThe event context to use.
dataThe object to record.
returnExistingAllow an existing object?

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ put() [4/12]

template<class T >
template<class AUXSTORE >
const_pointer_type SG::WriteHandle< T >::put ( const EventContext &  ctx,
std::unique_ptr< const T >  data,
std::unique_ptr< const AUXSTORE >  auxstore 
) const

Record an object and its auxiliary store to the store.

Parameters
ctxThe event context to use.
dataThe object to record.
auxstoreAuxiliary store object.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, and the objects passed in are destroyed.

Unlike the version taking unique_ptr<T>, this does not alter the store pointer of data.

◆ put() [5/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( const EventContext &  ctx,
std::unique_ptr< T >  data,
bool  returnExisting = false 
) const

Record an object to the store.

Parameters
ctxThe event context to use.
dataThe object to record.
returnExistingAllow an existing object?

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ put() [6/12]

template<class T >
template<class AUXSTORE >
const_pointer_type SG::WriteHandle< T >::put ( const EventContext &  ctx,
std::unique_ptr< T >  data,
std::unique_ptr< AUXSTORE >  auxstore 
) const

Record an object and its auxiliary store to the store.

Parameters
ctxThe event context to use.
dataThe object to record.
auxstoreAuxiliary store object.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, and the objects passed in are destroyed.

◆ put() [7/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( SG::DataObjectSharedPtr< T >  data) const

Record an object to the store.

Parameters
dataThe object to record.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. Returns the object placed in the store, or nullptr if there was an error.

The event store takes shared ownership of the object.

◆ put() [8/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( std::unique_ptr< const ConstDataVector< T > >  data,
bool  returnExisting = false 
) const

Record an object to the store.

Parameters
dataThe object to record.
returnExistingAllow an existing object?

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ put() [9/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( std::unique_ptr< const T >  data,
bool  returnExisting = false 
) const

Record an object to the store.

Parameters
dataThe object to record.
returnExistingAllow an existing object?

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ put() [10/12]

template<class T >
template<class AUXSTORE >
const_pointer_type SG::WriteHandle< T >::put ( std::unique_ptr< const T >  data,
std::unique_ptr< const AUXSTORE >  auxstore 
) const

Record an object and its auxiliary store to the store.

Parameters
dataThe object to record.
auxstoreAuxiliary store object.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, and the objects passed in are destroyed.

Unlike the version taking unique_ptr<T>, this does not alter the store pointer of data.

◆ put() [11/12]

template<class T >
const_pointer_type SG::WriteHandle< T >::put ( std::unique_ptr< T >  data,
bool  returnExisting = false 
) const

Record an object to the store.

Parameters
dataThe object to record.
returnExistingAllow an existing object?

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, data is destroyed.

◆ put() [12/12]

template<class T >
template<class AUXSTORE >
const_pointer_type SG::WriteHandle< T >::put ( std::unique_ptr< T >  data,
std::unique_ptr< AUXSTORE >  auxstore 
) const

Record an object and its auxiliary store to the store.

Parameters
dataThe object to record.
auxstoreAuxiliary store object.

Unlike record(), this does not change the handle object. That means that one will not be able to get the object back by dereferencing the handle. 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, and the objects passed in are destroyed.

◆ 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
protectedinherited

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 784 of file StoreGate/src/VarHandleBase.cxx.

790  {
791  if (this->name().empty()) {
792  REPORT_ERROR (StatusCode::FAILURE) << "Attempt to record an object with a null key";
793  return nullptr;
794  }
795 
796  store = storeFromHandle (ctx);
797  if (!store) {
798  REPORT_ERROR (StatusCode::FAILURE) << "No store.";
799  return nullptr;
800  }
801 
802  SG::DataObjectSharedPtr<DataObject> sptr (std::move (dobj));
803  unsigned int initRefCount = sptr->refCount();
804  SG::DataProxy* new_proxy =
805  store->recordObject (sptr, this->name(), allowMods, returnExisting);
806  if (!new_proxy) {
807  REPORT_ERROR (StatusCode::FAILURE) << "recordObject failed";
808  return nullptr;
809  }
810 
811  if (new_proxy && initRefCount == sptr->refCount() && new_proxy->isValid()) {
812  // If the reference count hasn't changed, then we've returned an existing
813  // object rather than recording a new one. Retrieve the pointer.
814  dataPtr = typeless_dataPointer_fromProxy (new_proxy, true);
815  }
816 
817  return dataPtr;
818  }

◆ record() [1/4]

template<class T >
StatusCode SG::WriteHandle< T >::record ( SG::DataObjectSharedPtr< T >  data)

Record a const shared DataObject to the store.

Parameters
dataThe object to record.

The event store takes shared ownership of the object.

◆ record() [2/4]

template<class T >
StatusCode SG::WriteHandle< T >::record ( std::unique_ptr< T >  data)

Record a const object to the store.

Parameters
dataThe object to record.

◆ record() [3/4]

template<class T >
template<class AUXSTORE >
StatusCode SG::WriteHandle< T >::record ( std::unique_ptr< T >  data,
std::unique_ptr< AUXSTORE >  auxstore,
bool  isConst 
)
private

Record an object and its auxiliary store to the store.

Parameters
dataThe object to record.
auxstoreAuxiliary store object.
isConstIf true, record the objects as const.

◆ record() [4/4]

template<class T >
template<class AUXSTORE >
StatusCode SG::WriteHandle< T >::record ( std::unique_ptr< T >  data,
std::unique_ptr< AUXSTORE >  store 
)

Record a const object and its auxiliary store to the store.

Parameters
dataThe object to record.
auxstoreAuxiliary store object.

◆ record_impl()

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

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 715 of file StoreGate/src/VarHandleBase.cxx.

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

◆ recordNonConst() [1/3]

template<class T >
StatusCode SG::WriteHandle< T >::recordNonConst ( SG::DataObjectSharedPtr< T >  data)

Record a non-const shared DataObject to the store.

Parameters
dataThe object to record.

The event store takes shared ownership of the object.

◆ recordNonConst() [2/3]

template<class T >
StatusCode SG::WriteHandle< T >::recordNonConst ( std::unique_ptr< T >  data)

Record a non-const object to the store.

Parameters
dataThe object to record.

◆ recordNonConst() [3/3]

template<class T >
template<class AUXSTORE >
StatusCode SG::WriteHandle< T >::recordNonConst ( std::unique_ptr< T >  data,
std::unique_ptr< AUXSTORE >  store 
)

Record a non-const object and its auxiliary store to the store.

Parameters
dataThe object to record.
auxstoreAuxiliary store object.

◆ reset()

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

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 >.

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

553  {
554 #ifdef DEBUG_VHB
555  std::cerr << "::VHB::reset("
556  << "ptr=" << this->m_ptr << ", "
557  << "proxy=" << this->m_proxy << ", "
558  << "key=" <<this->key()
559  << ")..."
560  << std::endl;
561 #endif
562  m_ptr = 0;
563 
564  if (hard) {
565  m_store = 0;
566  m_storeWasSet = false;
567  }
568 
569  //if the proxy is not resetOnly then release it as it will become invalid
570  // Also release on a hard reset.
571  if (0 != m_proxy && (!m_proxy->isResetOnly() || hard)) {
572  resetProxy();
573  }
574  }

◆ resetProxy()

void SG::VarHandleBase::resetProxy ( )
privateinherited

Clear the m_proxy field and release the old proxy.

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

1012  {
1013  if (m_proxy) {
1014  if (m_ownedKey) {
1015  m_proxy->unbindHandle(this);
1016  m_proxy->release();
1017  }
1018  m_proxy = nullptr;
1019  }
1020  }

◆ setConst()

StatusCode SG::VarHandleBase::setConst ( )
inherited

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

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

600  {
601  if (typeless_dataPointer()) {
602  m_proxy->setConst();
603  return StatusCode::SUCCESS;
604  }
605  return StatusCode::FAILURE;
606  }

◆ setProxy()

void SG::VarHandleBase::setProxy ( SG::DataProxy proxy)
privateinherited

Set a new proxy.

Release any old one first.

Parameters
proxyThe new proxy.

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

1028  {
1029  resetProxy();
1030  if (proxy) {
1031  if (m_ownedKey) {
1032  proxy->addRef();
1033  proxy->bindHandle (this);
1034  }
1035  m_proxy = proxy;
1036  }
1037  }

◆ setProxyDict()

StatusCode SG::VarHandleBase::setProxyDict ( IProxyDict store)
virtualinherited

Explicitly set the event store.

Parameters
storeThe new event store.

This implicitly does a reset().

Reimplemented in SG::WriteDecorHandle< DataVector, int >, SG::WriteDecorHandle< DataVector, float >, SG::WriteDecorHandle< DataVector, std::vector< float > >, SG::WriteDecorHandle< DataVector, std::vector< int > >, SG::WriteDecorHandle< DataVector, std::vector< bool > >, and SG::WriteDecorHandle< DataVector, uint32_t >.

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

535  {
536  reset(true);
537  m_store = store;
538  m_storeWasSet = true;
539  return StatusCode::SUCCESS;
540  }

◆ setState() [1/3]

StatusCode SG::VarHandleBase::setState ( )
inherited

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 500 of file StoreGate/src/VarHandleBase.cxx.

501  {
502  CHECK( initialize() );
503  if (!m_storeWasSet) {
504  IProxyDict* store = storeFromHandle (nullptr);
505  if (store) m_store = store;
506  }
507 
509  if (!proxy) {
510  proxy = m_store->proxy(this->clid(), this->key());
511  }
512  StatusCode sc = this->setState(proxy);
513 
514  // Failure to find the proxy is ok in the case of a @c WriteHandle
515  // that has not yet been written to.
516  if (sc.isFailure() && mode() == Gaudi::DataHandle::Writer && m_ptr == nullptr)
517  return StatusCode::SUCCESS;
518 
519  return sc;
520  }

◆ setState() [2/3]

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

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 685 of file StoreGate/src/VarHandleBase.cxx.

686  {
687  if (0 == store) {
688  return StatusCode::FAILURE;
689  }
690 #ifdef DEBUG_VHB
691  std::cerr << "::VHB::setState("
692  << store->name() << ", "
693  << key
694  << ") const\n";
695 #endif
696  CLID cid = this->clid();
697  SG::DataProxy* proxy = store->proxy(cid, key);
698  // std::cerr << "::VHB:: -- clid=[" << cid << "] proxy=[" << proxy << "]\n";
699  return this->setState(proxy);
700  }

◆ setState() [3/3]

StatusCode SG::VarHandleBase::setState ( SG::DataProxy proxy)
protectedinherited

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 653 of file StoreGate/src/VarHandleBase.cxx.

654  {
655 #ifdef DEBUG_VHB
656  std::cerr << "::VHB::setState("
657  << proxy;
658  if (0 != proxy) {
659  std::cerr << " -- isValid: " << proxy->isValid()
660  << " -- isConst: " << proxy->isConst();
661  }
662  std::cerr << ") const\n";
663 #endif
664  if (0 == proxy || !proxy->isValid()) {
665  return StatusCode::FAILURE;
666  }
667 
668  if (m_proxy != proxy) {
669  // We're changing proxies. Release the old and bind to the new.
670  setProxy (proxy);
671  // Clear cached pointer.
672  m_ptr=0;
673  }
674 
675  return StatusCode::SUCCESS;
676  }

◆ setStoreFromHandle()

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

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 994 of file StoreGate/src/VarHandleBase.cxx.

995  {
996  if (m_ownedKey) {
997  if (m_ownedKey->initialize().isFailure()) {
998  return false;
999  }
1000  }
1001  m_store = storeFromHandle (ctx);
1002  m_storeWasSet = (ctx && m_store ==
1003  Atlas::getExtendedEventContext(*ctx).proxy());
1004  return true;
1005  }

◆ store()

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

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

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

380  {
381  if (m_store)
382  return m_store->name();
383  return this->storeHandle().name();
384  }

◆ storeFromHandle()

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

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 964 of file StoreGate/src/VarHandleBase.cxx.

965  {
966  if (m_key->isEventStore()) {
967  if (ctx)
968  return Atlas::getExtendedEventContext(*ctx).proxy();
969  if (m_storeWasSet && m_store) return m_store;
970 
971  if ( Atlas::hasExtendedEventContext (Gaudi::Hive::currentContext()) ) {
972  return Atlas::getExtendedEventContext (Gaudi::Hive::currentContext()).proxy();
973  } else {
974  return nullptr;
975  }
976  }
977 
978  if (m_storeWasSet && m_store) return m_store;
980  if (!store)
981  store = &*this->storeHandle();
982 
983  return store->hiveProxyDict();
984  }

◆ storeHandle()

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

Return handle to the referenced store.

◆ symLink()

template<class T >
template<class U >
StatusCode SG::WriteHandle< T >::symLink ( const WriteHandleKey< U > &  key)

Make an explicit link.

Parameters
keyAlternate clid by which the referenced object should be known. The SG key must match the key of the current handle.

You should generally not be using this!

The current handle should be valid and referencing an object (i.e., record should have been called on it).

This makes a symlink: the object will be retrievable as a different type.

Note that if T and @U are related via SG_BASE and/or DATAVECTOR_BASE, then you shouldn't need to explicitly make a symlink; that should happen automatically.

If a U* is not convertable to a T* via C++ rules, then you likely will be, at best, relying on undefined behavior. You will probably get warnings from the undefined behavior sanitizer when if you try to dereference the U*.

This usage is here mainly to assist in migrating some existing patterns to MT. You should think several times before using in new code.

◆ symLink_impl()

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

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 933 of file StoreGate/src/VarHandleBase.cxx.

935  {
936  if (!m_ptr || !m_store) {
937  REPORT_ERROR (StatusCode::FAILURE) << "symlink: Handle not valid.";
938  return StatusCode::FAILURE;
939  }
940 
941  SG::DataObjectSharedPtr<DataObject> obj (new SymlinkDataObject (newClid, m_ptr));
942  SG::DataProxy* prox = m_store->recordObject (obj, newKey, false, true);
943  if (!prox)
944  return StatusCode::FAILURE;
945  return StatusCode::SUCCESS;
946  }

◆ typeless_cptr()

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

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)
protectedinherited

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
privateinherited

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 1048 of file StoreGate/src/VarHandleBase.cxx.

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

◆ typeless_dataPointer_impl()

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

Retrieve an object from StoreGate.

Parameters
quietIf true, suppress failure messages.

Reimplemented in SG::WriteDecorHandle< DataVector, int >, SG::WriteDecorHandle< DataVector, float >, SG::WriteDecorHandle< DataVector, std::vector< float > >, SG::WriteDecorHandle< DataVector, std::vector< int > >, SG::WriteDecorHandle< DataVector, std::vector< bool > >, and SG::WriteDecorHandle< DataVector, uint32_t >.

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

827  {
828 #ifdef DEBUG_VHB
829  std::cerr << "::VHB::typeless_dataPointer_impl("
830  << this
831  << ",ptr=" << this->m_ptr
832  << ",proxy=" << this->m_proxy << ", ";
833  if (m_proxy) {
834  std::cerr << " -- isValid: " << m_proxy->isValid()
835  << " -- isConst: " << m_proxy->isConst();
836  }
837  std::cerr << ", key=" <<this->key() << ")...\n";
838 #endif
839 
840  // First check for cached pointer.
841  if (0 != m_ptr)
842  return m_ptr;
843 
844  if (0 == m_proxy) {
845  // No proxy, need to look it up.
846  if (this->setState().isFailure() || !m_proxy) {
847  if (!quiet) {
848  REPORT_MESSAGE(MSG::WARNING)
849  << "could not get proxy for key " << key();
850  if (this->mode() != Gaudi::DataHandle::Reader) {
851  REPORT_MESSAGE(MSG::WARNING)<< " try using a ReadHandle";
852  }
853  } //quiet
854  return 0;
855  } //setstate
856  } //m_proxy
857 
859  return m_ptr;
860  }

◆ typeless_ptr()

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

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 869 of file StoreGate/src/VarHandleBase.cxx.

870  {
871  void* p = typeless_dataPointer(quiet);
872  if (p != nullptr && isConst())
873  throw SG::ExcConstObject (clid(), key(), store());
874  return p;
875  }

◆ vhKey()

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

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 616 of file StoreGate/src/VarHandleBase.cxx.

617  {
618  if (!m_ownedKey) {
620  m_key->storeHandle().name());
621  }
622  return *m_ownedKey;
623  }

Member Data Documentation

◆ m_key

const VarHandleKey* SG::VarHandleBase::m_key
privateinherited

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 523 of file StoreGate/StoreGate/VarHandleBase.h.

◆ m_lockAuxPending

template<class T >
SG::DataProxy* SG::WriteHandle< T >::m_lockAuxPending = nullptr
private

If non-null, then we need to lock the associated aux store object when we're deleted.

This is set when we record an object along with the associated aux const with the const flag set (the default). Recall that for a const record, we want to support the semantics that you can get a non-const pointer back from the handle as long as it exists, to finish initialization of the object. For an aux store, though, just getting back a non-const pointer is not sufficient, since the store will have been locked at the time of the record, preventing changes to the store.

So if we're meant to record a const aux store object, we don't actually set it const on the record, but instead set this and do the setConst in the destructor.

Definition at line 662 of file StoreGate/StoreGate/WriteHandle.h.

◆ m_ownedKey

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

An owned VarHandleKey.

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

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

◆ m_proxy

SG::DataProxy* SG::VarHandleBase::m_proxy
protectedinherited

Proxy holding the object to which we are bound.

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

◆ m_ptr

void* SG::VarHandleBase::m_ptr
protectedinherited

The object to which we are bound.

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

◆ m_store

IProxyDict* SG::VarHandleBase::m_store
protectedinherited

Pointer to the store that owns the object.

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

◆ m_storeWasSet

bool SG::VarHandleBase::m_storeWasSet
protectedinherited

True if the store was set explicitly via setProxyDict.

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


The documentation for this class was generated from the following file:
used
common.sgkey
def sgkey(tool)
Definition: common.py:1028
REPORT_ERROR
#define REPORT_ERROR(SC)
Report an error.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:355
IProxyDict::proxy
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::DataProxy::isConst
bool isConst() const
Check if it is a const object.
SG::VarHandleBase::storeFromHandle
IProxyDict * storeFromHandle(const EventContext *ctx) const
Return the store instance to use.
Definition: StoreGate/src/VarHandleBase.cxx:964
SG::VarHandleBase::m_ownedKey
std::unique_ptr< VarHandleKey > m_ownedKey
An owned VarHandleKey.
Definition: StoreGate/StoreGate/VarHandleBase.h:518
SG::VarHandleBase::typeless_dataPointer
void * typeless_dataPointer(bool quiet=defaultQuiet)
Retrieve an object from StoreGate.
DataBucketBase
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Definition: DataBucketBase.h:24
quiet
bool quiet
Definition: TrigGlobEffCorrValidation.cxx:170
SG::VarHandleKey::storeHandle
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::VarHandleBase::setState
StatusCode setState()
Retrieve and cache all information managed by a handle.
Definition: StoreGate/src/VarHandleBase.cxx:500
DataBucketBase::object
virtual void * object()=0
SG::VarHandleBase::clid
CLID clid() const
Return the class ID for the referenced object.
SG::VarHandleBase::typeless_dataPointer_impl
virtual void * typeless_dataPointer_impl(bool quiet)
Retrieve an object from StoreGate.
Definition: StoreGate/src/VarHandleBase.cxx:826
Atlas::hasExtendedEventContext
bool hasExtendedEventContext(const EventContext &ctx)
Test whether a context object has an extended context installed.
Definition: ExtendedEventContext.cxx:23
SG::DataProxy::isValid
bool isValid() const
called by destructor
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
SG::VarHandleBase::setConst
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
Definition: StoreGate/src/VarHandleBase.cxx:599
SG::DataProxy::unbindHandle
void unbindHandle(IResetable *ir)
Definition: DataProxy.cxx:293
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition: ExtendedEventContext.cxx:32
IProxyDict::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const =0
Get proxy given a hashed key+clid.
SG::VarHandleBase::resetProxy
void resetProxy()
Clear the m_proxy field and release the old proxy.
Definition: StoreGate/src/VarHandleBase.cxx:1011
SG::VarHandleKey::assign
virtual StatusCode assign(const std::string &sgkey)
Change the key of the object to which we're referring.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:88
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::VarHandleBase::m_key
const VarHandleKey * m_key
The associated key object.
Definition: StoreGate/StoreGate/VarHandleBase.h:523
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:379
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:31
SG::VarHandleKey::isEventStore
bool isEventStore() const
Does this key reference the primary event store?
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SG::VarHandleBase::m_proxy
SG::DataProxy * m_proxy
Proxy holding the object to which we are bound.
Definition: StoreGate/StoreGate/VarHandleBase.h:505
SG::ExcConstObject
Exception — Tried to retrieve non-const pointer to const object.
Definition: Control/StoreGate/StoreGate/exceptions.h:134
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::VarHandleBase::isInitialized
bool isInitialized() const
Has a proxy been retrieved from SG?
Definition: StoreGate/src/VarHandleBase.cxx:409
SG::DataProxy::release
virtual unsigned long release() override final
release reference to object
Definition: DataProxy.cxx:320
SG::VarHandleBase::mode
Gaudi::DataHandle::Mode mode() const
Return the mode (read/write/update) for this handle.
SG::VarHandleBase::isPresent_impl
bool isPresent_impl(const std::string &key) const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:1108
SG::VarHandleBase::reset
virtual void reset(bool hard) override
Reset this handle.
Definition: StoreGate/src/VarHandleBase.cxx:553
SG::VarHandleBase::typeless_dataPointer_fromProxy
void * typeless_dataPointer_fromProxy(SG::DataProxy *proxy, bool quiet) const
Retrieve a pointer from a proxy.
Definition: StoreGate/src/VarHandleBase.cxx:1048
SG::VarHandleKey::clid
CLID clid() const
Return the class ID for the referenced object.
Definition: StoreGate/src/VarHandleKey.cxx:177
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
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
SG::throwExcNonConstHandleKey
void throwExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNonConstHandleKey exception.
Definition: Control/StoreGate/src/exceptions.cxx:337
SG::VarHandleBase::storeHandle
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
SG::Storable_cast
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:47
SG::DataProxy::setConst
void setConst()
Mark this object as const.
Definition: DataProxy.cxx:204
SG::VarHandleKey::hashedKey
SG::sgkey_t hashedKey() const
Return the hashed StoreGate key.
SG::VarHandleBase::initialize
StatusCode initialize(bool used=true)
Verify that the handle has been configured properly.
Definition: StoreGate/src/VarHandleBase.cxx:465
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
SG::VarHandleBase::m_storeWasSet
bool m_storeWasSet
True if the store was set explicitly via setProxyDict.
Definition: StoreGate/StoreGate/VarHandleBase.h:511
SG::VarHandleBase::m_ptr
void * m_ptr
The object to which we are bound.
Definition: StoreGate/StoreGate/VarHandleBase.h:502
IProxyDict::recordObject
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting)=0
Record an object in the store.
SG::DataProxy::isResetOnly
bool isResetOnly() const
Check reset only:
SG::VarHandleBase::isConst
bool isConst() const
True if this handle has a proxy, and the proxy is const.
Definition: StoreGate/src/VarHandleBase.cxx:437
SG::DataObjectSharedPtr
Smart pointer to manage DataObject reference counts.
Definition: DataObjectSharedPtr.h:46
python.PyAthena.obj
obj
Definition: PyAthena.py:135
SG::VarHandleBase::m_store
IProxyDict * m_store
Pointer to the store that owns the object.
Definition: StoreGate/StoreGate/VarHandleBase.h:508
SG::DataProxy
Definition: DataProxy.h:44
IProxyDict::hiveProxyDict
virtual IProxyDict * hiveProxyDict() override
Return the current event-slot-specific store.
Definition: IProxyDict.cxx:83
SG::VarHandleBase::setProxy
void setProxy(SG::DataProxy *proxy)
Set a new proxy.
Definition: StoreGate/src/VarHandleBase.cxx:1027