ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
DataLinkBase Class Referenceabstract

Type-independent part of DataLink; holds the persistent state. More...

#include <DataLinkBase.h>

Inherited by DataLink< STORABLE >, DataLink< ActsTrk::TrackContainer >, DataLink< ALFA_DigitCollection >, DataLink< ALFA_LocRecCorrEvCollection >, DataLink< ALFA_LocRecCorrODEvCollection >, DataLink< ALFA_LocRecEvCollection >, DataLink< ALFA_LocRecODEvCollection >, DataLink< ALFA_ODDigitCollection >, DataLink< ALFA_RawDataContainer >, DataLink< Analysis::TauDetailsContainer >, DataLink< AthExIParticles >, DataLink< CaloCellContainer >, DataLink< CaloClusterContainer >, DataLink< CaloTowerContainer >, DataLink< DataVector >, DataLink< DataVector< Muon::MuonPatternCombination > >, DataLink< DOBJ >, DataLink< egDetailContainer >, DataLink< ExampleHitContainer >, DataLink< HLT::HLTResult >, DataLink< INav4MomAssocs >, DataLink< INav4MomToTrackParticleAssocs >, DataLink< JetKeyDescriptor >, DataLink< JetMomentMap >, DataLink< Rec::TrackParticleContainer >, DataLink< SG::AuxVectorBase >, DataLink< SG::IConstAuxStore >, DataLink< SGTutorial::MyDataObj >, DataLink< T >, DataLink< TrackParticleAssocs >, DataLink< TrigInDetTrackCollection >, DataLink< VxContainer >, DataLink< xAOD::TrackJacobianAuxContainer_v1 >, DataLink< xAOD::TrackMeasurementAuxContainer_v1 >, DataLink< xAOD::TrackParametersAuxContainer_v1 >, DataLink< xAOD::TrackStateAuxContainer_v1 >, and DataLink< xAOD::TrackSurfaceAuxContainer_v1 >.

Collaboration diagram for DataLinkBase:

Public Types

typedef SG::DataProxyHolder::sgkey_t sgkey_t
 Type of hashed keys. More...
 
typedef SG::DataProxyHolder::ID_type ID_type
 Type of string keys. More...
 
typedef SG::DataProxyHolder::pointer_t pointer_t
 
typedef SG::DataProxyHolder::const_pointer_t const_pointer_t
 
typedef SG::DataProxyHolder::castfn_t castfn_t
 Function casting from a SG::DataProxy to a pointer. More...
 

Public Member Functions

bool isDefault () const
 Test to see if we're in the default state. More...
 
const ID_typedataID () const
 Return the SG key that we reference, as a string. More...
 
sgkey_t key () const
 Return the SG key that we reference, as a hash. More...
 
void clear ()
 Clear the link (make it null). More...
 
SG::DataProxyproxy (bool nothrow=false) const
 Return the DataProxy for this link. More...
 
IProxyDictsource () const
 Return the data source for this reference. More...
 
bool toTransient (IProxyDict *sg=0)
 Finish initialization after link has been read. More...
 
bool toTransient (const EventContext &ctx)
 Finish initialization after link has been read. More...
 
bool toTransient (const ID_type &dataID, CLID link_clid, IProxyDict *sg=0)
 Finish initialization like the link as just been read from root, but with a specified key. More...
 
bool toTransient (const ID_type &dataID, CLID link_clid, const EventContext &ctx)
 Finish initialization like the link as just been read from root, but with a specified key. More...
 
bool toPersistent ()
 Prepare this link for writing. More...
 
bool toPersistentNoRemap ()
 Prepare this link for writing. More...
 
bool operator== (const DataLinkBase &other) const
 Compare for equality. More...
 
bool operator!= (const DataLinkBase &other) const
 Compare for inequality. More...
 
 DataLinkBase (uint32_t key=0)
 Default constructor. More...
 
virtual ~DataLinkBase ()
 Destructor. More...
 
uint32_t persKey () const
 Get the key/identifier of the referenced container. More...
 
void setPersKey (uint32_t key)
 Set the key/identifier of the referenced container. More...
 
bool isDefault () const
 Test if the link is in the default state. More...
 
void clear ()
 Clear the link (make it null) More...
 
virtual bool toTransient ()=0
 Reset the object's internal cache. More...
 

Protected Member Functions

 DataLinkBase ()
 Default constructor. More...
 
 DataLinkBase (const_pointer_t obj, CLID link_clid, IProxyDict *sg)
 Constructor from pointer to object. More...
 
 DataLinkBase (const ID_type &dataID, CLID link_clid, IProxyDict *sg)
 Constructor from a string key. More...
 
 DataLinkBase (sgkey_t key, CLID link_clid, IProxyDict *sg)
 Constructor from a hashed key. More...
 
 DataLinkBase (sgkey_t key, const SG::DataProxyHolder &holder)
 Constructor from a hashed key and a proxy holder object. More...
 
void toStorableObject (const_pointer_t obj, CLID clid_in, IProxyDict *sg)
 Set the link to an object given by a pointer. More...
 
void toIdentifiedObject (const ID_type &dataID, CLID clid, IProxyDict *sg)
 Set the link to an object given by a string key. More...
 
void toIdentifiedObject (sgkey_t key, CLID clid, IProxyDict *sg)
 Set the link to an object given by a hashed key. More...
 
void * storableBase (castfn_t *castfn, const CLID &clid, bool isConst) const
 Return a pointer to the currently-referenced object. More...
 
void throwInvalidLink () const
 Throw a ExcInvalidLink exception for this link. More...
 

Protected Attributes

uint32_t m_persKey
 Key/identifier of the referenced object. More...
 
bool m_isDirectIO
 A transient variable signalling when direct I/O is happening. More...
 

Private Attributes

sgkey_t m_persKey
 The hashed key for this link. More...
 
SG::DataProxyHolder m_proxy
 SG proxy for this link. More...
 

Friends

class ElementLinkBase
 
template<class INDEXING_POLICY >
class SG::GenericElementLinkBase
 
class DataLinkBase_test
 For component testing. More...
 

Detailed Description

Type-independent part of DataLink; holds the persistent state.

The persistent state for a DataLink is the hashed SG key, stored here as m_persKey. The transient member m_proxy contains the data proxy pointer.

Definition at line 38 of file AthLinks/DataLinkBase.h.

Member Typedef Documentation

◆ castfn_t

typedef SG::DataProxyHolder::castfn_t DataLinkBase::castfn_t

Function casting from a SG::DataProxy to a pointer.

Definition at line 51 of file AthLinks/DataLinkBase.h.

◆ const_pointer_t

Definition at line 48 of file AthLinks/DataLinkBase.h.

◆ ID_type

Type of string keys.

Definition at line 45 of file AthLinks/DataLinkBase.h.

◆ pointer_t

Definition at line 47 of file AthLinks/DataLinkBase.h.

◆ sgkey_t

Type of hashed keys.

Definition at line 42 of file AthLinks/DataLinkBase.h.

Constructor & Destructor Documentation

◆ DataLinkBase() [1/6]

DataLinkBase::DataLinkBase ( )
protected

Default constructor.

◆ DataLinkBase() [2/6]

DataLinkBase::DataLinkBase ( const_pointer_t  obj,
CLID  link_clid,
IProxyDict sg 
)
protected

Constructor from pointer to object.

Parameters
objPointer to the object.
link_clidCLID of the link being set.
sgAssociated store.

If sg is 0, we take the global default.

May throw ExcCLIDMismatch.

◆ DataLinkBase() [3/6]

DataLinkBase::DataLinkBase ( const ID_type dataID,
CLID  link_clid,
IProxyDict sg 
)
protected

Constructor from a string key.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
sgAssociated store.

If sg is 0, we take the global default.

◆ DataLinkBase() [4/6]

DataLinkBase::DataLinkBase ( sgkey_t  key,
CLID  link_clid,
IProxyDict sg 
)
protected

Constructor from a hashed key.

Parameters
keyHashed key of the object.
link_clidCLID of the link being set.
sgAssociated store.

If sg is 0, we take the global default.

May throw ExcCLIDMismatch.

◆ DataLinkBase() [5/6]

DataLinkBase::DataLinkBase ( sgkey_t  key,
const SG::DataProxyHolder holder 
)
protected

Constructor from a hashed key and a proxy holder object.

Used internally for EL -> DL conversion.

Parameters
keyHashed key of the object.
holderInternal holder object for the proxy.

◆ DataLinkBase() [6/6]

DataLinkBase::DataLinkBase ( uint32_t  key = 0)

Default constructor.

Definition at line 8 of file DataLinkBase.cxx.

9  : m_persKey( key ), m_isDirectIO( false ) {
10 
11 }

◆ ~DataLinkBase()

virtual DataLinkBase::~DataLinkBase ( )
inlinevirtual

Destructor.

Definition at line 32 of file A/AthLinks/DataLinkBase.h.

32 {}

Member Function Documentation

◆ clear() [1/2]

void DataLinkBase::clear ( )

Clear the link (make it null)

◆ clear() [2/2]

void DataLinkBase::clear ( )

Clear the link (make it null).

Definition at line 36 of file DataLinkBase.cxx.

36  {
37 
38  m_persKey = 0;
39  return;
40 }

◆ dataID()

const ID_type& DataLinkBase::dataID ( ) const

Return the SG key that we reference, as a string.

Returns a null string on failure.

◆ isDefault() [1/2]

bool DataLinkBase::isDefault ( ) const

Test if the link is in the default state.

◆ isDefault() [2/2]

bool DataLinkBase::isDefault ( ) const

Test to see if we're in the default state.

Definition at line 31 of file DataLinkBase.cxx.

31  {
32 
33  return ( m_persKey == 0 );
34 }

◆ key()

sgkey_t DataLinkBase::key ( ) const

Return the SG key that we reference, as a hash.

Returns 0 on failure.

◆ operator!=()

bool DataLinkBase::operator!= ( const DataLinkBase other) const

Compare for inequality.

◆ operator==()

bool DataLinkBase::operator== ( const DataLinkBase other) const

Compare for equality.

◆ persKey()

uint32_t DataLinkBase::persKey ( ) const

Get the key/identifier of the referenced container.

Definition at line 13 of file DataLinkBase.cxx.

13  {
14 
15  return m_persKey;
16 }

◆ proxy()

SG::DataProxy* DataLinkBase::proxy ( bool  nothrow = false) const

Return the DataProxy for this link.

Parameters
nothrowIf true, return 0 on failure instead of throwing an exception.

If this is a null link, we return 0. If we're directly referencing an object that's not in StoreGate, either return 0 or throw ExcPointerNotInSG, depending on nothrow. Otherwise, return the proxy for the object we're referencing.

◆ setPersKey()

void DataLinkBase::setPersKey ( uint32_t  key)

Set the key/identifier of the referenced container.

Definition at line 18 of file DataLinkBase.cxx.

18  {
19 
20  // Check if we're actually changing anything:
21  if( m_persKey == key ) return;
22  // Store the new key:
23  m_persKey = key;
24 
25  // Reset the internal cache:
26  toTransient();
27 
28  return;
29 }

◆ source()

IProxyDict* DataLinkBase::source ( ) const

Return the data source for this reference.

◆ storableBase()

void* DataLinkBase::storableBase ( castfn_t castfn,
const CLID clid,
bool  isConst 
) const
protected

Return a pointer to the currently-referenced object.

Parameters
castfnFunction to do the cast from data proxy to object. If 0, use a dynamic cast.
clidThe CLID of the desired object. This is used to determine how the returned pointer is to be converted.
isConstTrue if the returned object will be treated as const.
Returns
A pointer to an object of the type given by clid, or null on a failure (or if the reference is null).

◆ throwInvalidLink()

void DataLinkBase::throwInvalidLink ( ) const
protected

Throw a ExcInvalidLink exception for this link.

Parameters
sgkeyThe hashed key for this link.

This will fill in parameters for the exception message from the proxy.

◆ toIdentifiedObject() [1/2]

void DataLinkBase::toIdentifiedObject ( const ID_type dataID,
CLID  clid,
IProxyDict sg 
)
protected

Set the link to an object given by a string key.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
sgAssociated store.
Returns
The SG key for this object.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

◆ toIdentifiedObject() [2/2]

void DataLinkBase::toIdentifiedObject ( sgkey_t  key,
CLID  clid,
IProxyDict sg 
)
protected

Set the link to an object given by a hashed key.

Parameters
keyHashed key of the object.
link_clidCLID of the link being set.
sgAssociated store.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

May throw ExcCLIDMismatch.

◆ toPersistent()

bool DataLinkBase::toPersistent ( )

Prepare this link for writing.

One of the toPersistent methods should be called before trying to write the link with root.

Ensures the hashed SG key to be saved is correct. If this link is referencing an object not in SG, we throw ExcPointerNotInSG.

If the target of the link has been remapped, then the link will be updated with the remapped hash key.

Returns true.

◆ toPersistentNoRemap()

bool DataLinkBase::toPersistentNoRemap ( )

Prepare this link for writing.

One of the toPersistent methods should be called before trying to write the link with root.

Ensures the hashed SG key to be saved is correct. If this link is referencing an object not in SG, we throw ExcPointerNotInSG.

This version does not perform link remapping.

Returns true.

◆ toStorableObject()

void DataLinkBase::toStorableObject ( const_pointer_t  obj,
CLID  clid_in,
IProxyDict sg 
)
protected

Set the link to an object given by a pointer.

Parameters
objPointer to the object.
link_clidCLID of the link being set.
sgAssociated store.
Returns
The SG key for this object.

If sg is 0, then we take the store from whatever the link's currently set to. If the link has no current store, then we take the global default.

May throw ExcCLIDMismatch.

◆ toTransient() [1/5]

virtual bool DataLinkBase::toTransient ( )
pure virtual

◆ toTransient() [2/5]

bool DataLinkBase::toTransient ( const EventContext &  ctx)

Finish initialization after link has been read.

Parameters
ctxEvent context for this link.

This should be called after a link has been read by root in order to set the proxy pointer. Returns true.

◆ toTransient() [3/5]

bool DataLinkBase::toTransient ( const ID_type dataID,
CLID  link_clid,
const EventContext &  ctx 
)

Finish initialization like the link as just been read from root, but with a specified key.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
ctxEvent context for this link.

The link should be clear before this is called. Returns true.

◆ toTransient() [4/5]

bool DataLinkBase::toTransient ( const ID_type dataID,
CLID  link_clid,
IProxyDict sg = 0 
)

Finish initialization like the link as just been read from root, but with a specified key.

Parameters
dataIDKey of the object.
link_clidCLID of the link being set.
sgAssociated store.

The link should be clear before this is called. Returns true.

If sg is 0, then we use the global default store.

◆ toTransient() [5/5]

bool DataLinkBase::toTransient ( IProxyDict sg = 0)

Finish initialization after link has been read.

Parameters
sgAssociated store.

This should be called after a link has been read by root in order to set the proxy pointer. Returns true.

If sg is 0, then we use the global default store.

Friends And Related Function Documentation

◆ DataLinkBase_test

friend class DataLinkBase_test
friend

For component testing.

Definition at line 210 of file AthLinks/DataLinkBase.h.

◆ ElementLinkBase

friend class ElementLinkBase
friend

Definition at line 206 of file AthLinks/DataLinkBase.h.

◆ SG::GenericElementLinkBase

template<class INDEXING_POLICY >
friend class SG::GenericElementLinkBase
friend

Definition at line 207 of file AthLinks/DataLinkBase.h.

Member Data Documentation

◆ m_isDirectIO

bool DataLinkBase::m_isDirectIO
protected

A transient variable signalling when direct I/O is happening.

This flag is used exclusively by the DataLink<>::toTransient() function to know when it should take the persistent data stored in this object into account. That function may be called in normal P->T conversions as well, in which case using the data from this class would just reset the object to its default state.

Definition at line 60 of file A/AthLinks/DataLinkBase.h.

◆ m_persKey [1/2]

uint32_t DataLinkBase::m_persKey
protected

Key/identifier of the referenced object.

Definition at line 50 of file A/AthLinks/DataLinkBase.h.

◆ m_persKey [2/2]

sgkey_t DataLinkBase::m_persKey
private

The hashed key for this link.

Definition at line 343 of file AthLinks/DataLinkBase.h.

◆ m_proxy

SG::DataProxyHolder DataLinkBase::m_proxy
private

SG proxy for this link.

Definition at line 346 of file AthLinks/DataLinkBase.h.


The documentation for this class was generated from the following files:
DataLinkBase::m_persKey
sgkey_t m_persKey
The hashed key for this link.
Definition: AthLinks/DataLinkBase.h:343
DataLinkBase::m_isDirectIO
bool m_isDirectIO
A transient variable signalling when direct I/O is happening.
Definition: A/AthLinks/DataLinkBase.h:60
DataLinkBase::key
sgkey_t key() const
Return the SG key that we reference, as a hash.
DataLinkBase::toTransient
virtual bool toTransient()=0
Reset the object's internal cache.