ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
DataHeaderElement Class Reference

This class provides a persistent form for the TransientAddress. More...

#include <DataHeader.h>

Collaboration diagram for DataHeaderElement:

Public Types

using sgkey_t = SG::sgkey_t
 

Public Member Functions

 DataHeaderElement ()
 Default Constructor. More...
 
 DataHeaderElement (const DataHeaderElement &rhs)
 Copy Constructor. More...
 
 DataHeaderElement (const SG::TransientAddress *sgAddress, IOpaqueAddress *tokAddress, const std::string &pTag)
 Constructor. More...
 
 DataHeaderElement (const SG::DataProxy *proxy, IOpaqueAddress *tokAddress, const std::string &pTag)
 Constructor. More...
 
 DataHeaderElement (const CLID classID, const std::string &key, Token &&token)
 Constructor. More...
 
virtual ~DataHeaderElement ()
 Destructor. More...
 
DataHeaderElementoperator= (const DataHeaderElement &rhs)
 Assignment Operator. More...
 
CLID getPrimaryClassID () const
 
const std::set< CLIDgetClassIDs () const
 
const std::string & getKey () const
 
const std::vector< std::string > & getAlias () const
 
const TokengetToken () const
 
long getStorageType () const
 
const std::vector< sgkey_t > & getHashes () const
 
SG::TransientAddressgetAddress (unsigned long contextId=0) const
 
SG::TransientAddressgetAddress (const std::string &key, unsigned long contextId=0) const
 
void addHash (IStringPool *pool)
 Add new entry to hash map. More...
 
void dump (std::ostream &ostr) const
 

Private Member Functions

 DataHeaderElement (CLID clid, const std::string &name, const std::vector< CLID > &tClids, std::vector< std::string > &&alias, IOpaqueAddress *tadAddress, IOpaqueAddress *tokAddress, const std::string &pTag)
 Internal constructor. More...
 

Private Attributes

CLID m_pClid
 primary ClassID. More...
 
std::vector< CLIDm_clids
 vector of unsigned long to store ClassID's for symlinked container. More...
 
std::string m_key
 string with StoreGate key. More...
 
std::vector< std::string > m_alias
 vector of StoreGate alias string. More...
 
Token m_token
 Transient address token. More...
 
std::vector< sgkey_tm_hashes
 hash table for ElementLink host container keys. More...
 

Friends

class DataHeaderElementCnv_p3
 
class DataHeaderElementCnv_p4
 
class DataHeaderElementCnv_p5
 
class DataHeaderCnv_p6
 

Detailed Description

This class provides a persistent form for the TransientAddress.

Definition at line 37 of file DataHeader.h.

Member Typedef Documentation

◆ sgkey_t

Definition at line 39 of file DataHeader.h.

Constructor & Destructor Documentation

◆ DataHeaderElement() [1/6]

DataHeaderElement::DataHeaderElement ( )

Default Constructor.

Definition at line 19 of file DataHeader.cxx.

19  : m_pClid(0), m_clids(), m_key(), m_alias(), m_hashes() {
20 }

◆ DataHeaderElement() [2/6]

DataHeaderElement::DataHeaderElement ( const DataHeaderElement rhs)

Copy Constructor.

Definition at line 22 of file DataHeader.cxx.

22  : m_pClid(rhs.m_pClid),
23  m_clids(rhs.m_clids),
24  m_key(rhs.m_key),
25  m_alias(rhs.m_alias),
26  m_token(rhs.getToken()),
27  m_hashes(rhs.m_hashes) {
28 }

◆ DataHeaderElement() [3/6]

DataHeaderElement::DataHeaderElement ( const SG::TransientAddress sgAddress,
IOpaqueAddress *  tokAddress,
const std::string &  pTag 
)

Constructor.

Parameters
sgAddress[IN] pointer to TransientAddress for which a DataHeaderElement is created.
pTag[IN] string used as key element in DataHeader (SG key for DataObjects).

Definition at line 30 of file DataHeader.cxx.

32  : DataHeaderElement (sgAddress->clID(),
33  sgAddress->name(),
34  sgAddress->transientID(),
35  std::vector<std::string>(sgAddress->alias()),
36  sgAddress->address(),
37  tokAddress, pTag)
38 {
39 }

◆ DataHeaderElement() [4/6]

DataHeaderElement::DataHeaderElement ( const SG::DataProxy proxy,
IOpaqueAddress *  tokAddress,
const std::string &  pTag 
)

Constructor.

Parameters
proxy[IN] pointer to DataProxy for which a DataHeaderElement is created.
pTag[IN] string used as key element in DataHeader (SG key for DataObjects).

Definition at line 41 of file DataHeader.cxx.

43  : DataHeaderElement (proxy->clID(),
44  proxy->name(),
45  proxy->transientID(),
46  proxy->alias(),
47  proxy->address(),
48  tokAddress, pTag)
49 {
50 }

◆ DataHeaderElement() [5/6]

DataHeaderElement::DataHeaderElement ( const CLID  classID,
const std::string &  key,
Token &&  token 
)

Constructor.

Parameters
classID[IN] Primary ClassID of the DataObject for which a DataHeaderElement is created.
key[IN] SG Key of the DataObject for which a DataHeaderElement is created.
token[IN] Token of the DataObject for which a DataHeaderElement is created.

Definition at line 84 of file DataHeader.cxx.

86  : m_pClid(classID), m_clids(), m_key(key), m_alias(), m_token(std::move(token)), m_hashes() {
87 }

◆ ~DataHeaderElement()

DataHeaderElement::~DataHeaderElement ( )
virtual

Destructor.

Definition at line 89 of file DataHeader.cxx.

89  {
90 }

◆ DataHeaderElement() [6/6]

DataHeaderElement::DataHeaderElement ( CLID  clid,
const std::string &  name,
const std::vector< CLID > &  tClids,
std::vector< std::string > &&  alias,
IOpaqueAddress *  tadAddress,
IOpaqueAddress *  tokAddress,
const std::string &  pTag 
)
private

Internal constructor.

Definition at line 52 of file DataHeader.cxx.

59  : m_pClid(clid),
60  m_clids(tClids),
61  m_key((pTag.empty()) ? name : pTag),
62  m_alias(std::move(alias)),
63  m_hashes()
64 {
65  std::ranges::sort (m_clids);
66  const auto ret = std::ranges::unique (m_clids);
67  m_clids.erase (ret.begin(), ret.end());
68  std::erase (m_clids, m_pClid);
69  TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(tokAddress);
70  if (tokAddr != 0 && tokAddr->getToken() != 0) {
71  tokAddr->getToken()->setData (&m_token);
72  } else {
73  tokAddr = dynamic_cast<TokenAddress*>(tadAddress);
74  if (tokAddr != 0 && tokAddr->getToken() != 0) {
75  tokAddr->getToken()->setData (&m_token);
76  } else if (tokAddress != 0) {
77  m_token.fromString(*(tokAddress->par()));
78  } else if (tadAddress != 0) {
79  m_token.fromString(*(tadAddress->par()));
80  }
81  }
82 }

Member Function Documentation

◆ addHash()

void DataHeaderElement::addHash ( IStringPool pool)

Add new entry to hash map.

Definition at line 138 of file DataHeader.cxx.

138  {
139  if (!m_hashes.empty()) {
140  return;
141  }
142  std::set<CLID> clids = getClassIDs();
143  for (std::set<CLID>::iterator iter = clids.begin(), last = clids.end(); iter != last; ++iter) {
144  m_hashes.push_back(pool->stringToKey(m_key, *iter));
145  }
146 }

◆ dump()

void DataHeaderElement::dump ( std::ostream &  ostr) const

Definition at line 177 of file DataHeader.cxx.

178 {
179  using namespace std;
180  ostr << "SGKey: " << getKey() << endl;
181  ostr << "CLID: " << getPrimaryClassID();
182  if( getClassIDs().size() > 1 ) {
183  ostr << " ||";
184  for( auto& c : getClassIDs() ) ostr << " " << c;
185  }
186  ostr << std::endl;
187  if( getAlias().size() > 0 ) {
188  ostr << "Alias: ";
189  for( const std::string& a : getAlias() ) ostr << " " << a;
190  ostr << endl;
191  }
192  ostr << "Token: " << m_token.toString() << endl;
193  if( m_hashes.size() ) {
194  ostr << "Hashes:";
195  for( auto h : m_hashes ) ostr << " " << h;
196  ostr << endl;
197  }
198 }

◆ getAddress() [1/2]

SG::TransientAddress * DataHeaderElement::getAddress ( const std::string &  key,
unsigned long  contextId = 0 
) const
Returns
a pointer to the TransientAddress of the DataObject, with new transient key.

Definition at line 152 of file DataHeader.cxx.

153  {
154  CLID primaryClID = getPrimaryClassID();
155  TokenAddress* tokAdd = new TokenAddress(this->getStorageType(), primaryClID, "", m_key, contextId , &m_token);
156  SG::TransientAddress* sgAddress = new SG::TransientAddress(primaryClID, key, tokAdd, m_clids);
157  if (!m_hashes.empty()) {
158  // If we have the sgkey corresponding to the primary clid, record
159  // it in the address. This will allow us to do lookups later by sgkey
160  // rather than by name.
161  // But be careful: the key for the primary clid is not necessarily
162  // the first one in m_hashes. The keys in m_hashes correspond to
163  // all the CLIDs in ascending order. m_clids holds all CLIDs
164  // _except_ for the primary one, in sorted order.
165  // So we want to find the index at which the primary CLID would
166  // be inserted into m_clids to keep it sorted. We could do this
167  // using std::upper_bound. However, in the common cases, we only
168  // have about 2 entries in m_clids. In that case, it's faster
169  // to just do a linear search.
170  auto it = std::ranges::find_if (m_clids, std::bind_front(std::less<int>{}, primaryClID));
171  sgAddress->setSGKey (m_hashes[it - m_clids.begin()]);
172  }
173  sgAddress->setAlias(m_alias);
174  return(sgAddress);
175 }

◆ getAddress() [2/2]

SG::TransientAddress * DataHeaderElement::getAddress ( unsigned long  contextId = 0) const
Returns
a pointer to the TransientAddress of the DataObject.

Definition at line 148 of file DataHeader.cxx.

148  {
149  return(getAddress(m_key, contextId));
150 }

◆ getAlias()

const std::vector< std::string > & DataHeaderElement::getAlias ( ) const
Returns
StoreGate alias string vector.

Definition at line 121 of file DataHeader.cxx.

121  {
122  return(m_alias);
123 }

◆ getClassIDs()

const std::set< CLID > DataHeaderElement::getClassIDs ( ) const
Returns
a set of all ClassIDs (primary and symlinked).

Definition at line 111 of file DataHeader.cxx.

111  {
112  std::set<CLID> allClids (m_clids.begin(), m_clids.end());
113  allClids.insert(m_pClid);
114  return(allClids);
115 }

◆ getHashes()

const std::vector< DataHeaderElement::sgkey_t > & DataHeaderElement::getHashes ( ) const
Returns
the list of hash codes. In 1-1 correspondence with the CLID set.

Definition at line 134 of file DataHeader.cxx.

134  {
135  return(m_hashes);
136 }

◆ getKey()

const std::string & DataHeaderElement::getKey ( ) const
Returns
StoreGate key string.

Definition at line 117 of file DataHeader.cxx.

117  {
118  return(m_key);
119 }

◆ getPrimaryClassID()

CLID DataHeaderElement::getPrimaryClassID ( ) const
Returns
primary ClassID.

Definition at line 104 of file DataHeader.cxx.

104  {
105  if (m_pClid > 0) {
106  return(m_pClid);
107  }
108  return(m_clids.front());
109 }

◆ getStorageType()

long DataHeaderElement::getStorageType ( ) const
Returns
StorageType needed to read the DataObject (depends on technology).

Definition at line 129 of file DataHeader.cxx.

129  {
130  return(POOL_StorageType);
131 }

◆ getToken()

const Token * DataHeaderElement::getToken ( ) const
Returns
token by pointer (and give away ownership).

Definition at line 125 of file DataHeader.cxx.

125  {
126  return(&m_token);
127 }

◆ operator=()

DataHeaderElement & DataHeaderElement::operator= ( const DataHeaderElement rhs)

Assignment Operator.

Definition at line 92 of file DataHeader.cxx.

92  {
93  if (this != &rhs) {
94  m_pClid = rhs.m_pClid;
95  m_clids = rhs.m_clids;
96  m_key = rhs.m_key;
97  m_alias = rhs.m_alias;
98  rhs.getToken()->setData(&m_token);
99  m_hashes = rhs.m_hashes;
100  }
101  return(*this);
102 }

Friends And Related Function Documentation

◆ DataHeaderCnv_p6

friend class DataHeaderCnv_p6
friend

Definition at line 97 of file DataHeader.h.

◆ DataHeaderElementCnv_p3

friend class DataHeaderElementCnv_p3
friend

Definition at line 94 of file DataHeader.h.

◆ DataHeaderElementCnv_p4

friend class DataHeaderElementCnv_p4
friend

Definition at line 95 of file DataHeader.h.

◆ DataHeaderElementCnv_p5

friend class DataHeaderElementCnv_p5
friend

Definition at line 96 of file DataHeader.h.

Member Data Documentation

◆ m_alias

std::vector<std::string> DataHeaderElement::m_alias
private

vector of StoreGate alias string.

Definition at line 114 of file DataHeader.h.

◆ m_clids

std::vector<CLID> DataHeaderElement::m_clids
private

vector of unsigned long to store ClassID's for symlinked container.

Definition at line 110 of file DataHeader.h.

◆ m_hashes

std::vector<sgkey_t> DataHeaderElement::m_hashes
private

hash table for ElementLink host container keys.

Definition at line 118 of file DataHeader.h.

◆ m_key

std::string DataHeaderElement::m_key
private

string with StoreGate key.

Definition at line 112 of file DataHeader.h.

◆ m_pClid

CLID DataHeaderElement::m_pClid
private

primary ClassID.

Definition at line 108 of file DataHeader.h.

◆ m_token

Token DataHeaderElement::m_token
private

Transient address token.

Definition at line 116 of file DataHeader.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
createLinkingScheme.iter
iter
Definition: createLinkingScheme.py:62
DataHeaderElement::m_key
std::string m_key
string with StoreGate key.
Definition: DataHeader.h:112
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:407
DataHeaderElement::m_alias
std::vector< std::string > m_alias
vector of StoreGate alias string.
Definition: DataHeader.h:114
DataHeaderElement::m_token
Token m_token
Transient address token.
Definition: DataHeader.h:116
DataHeaderElement::m_pClid
CLID m_pClid
primary ClassID.
Definition: DataHeader.h:108
pool
pool namespace
Definition: libname.h:15
SG::TransientAddress::setAlias
void setAlias(const std::string &key)
set alias'
Definition: TransientAddress.h:260
skel.it
it
Definition: skel.GENtoEVGEN.py:407
SG::TransientAddress
Definition: TransientAddress.h:32
TokenAddress
This class provides a Generic Transient Address for POOL tokens.
Definition: TokenAddress.h:23
SG::TransientAddress::name
const std::string & name() const
Get the primary (hashed) SG key.
Definition: TransientAddress.h:217
DataHeaderElement::getKey
const std::string & getKey() const
Definition: DataHeader.cxx:117
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Token::fromString
Token & fromString(const std::string &from)
Build from the string representation of a token.
Definition: Token.cxx:148
DataHeaderElement::getAlias
const std::vector< std::string > & getAlias() const
Definition: DataHeader.cxx:121
SG::TransientAddress::alias
const TransientAliasSet & alias() const
set the clearAddress flag: IOA will not be deleted in proxy
Definition: TransientAddress.h:301
h
extractSporadic.h
list h
Definition: extractSporadic.py:96
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:210
COOLRates.alias
alias
Definition: COOLRates.py:1172
DataHeaderElement::DataHeaderElement
DataHeaderElement()
Default Constructor.
Definition: DataHeader.cxx:19
TokenAddress::getToken
Token * getToken()
Definition: TokenAddress.cxx:15
jobOptions.pTag
string pTag
Definition: jobOptions.py:28
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
DataHeaderElement::getClassIDs
const std::set< CLID > getClassIDs() const
Definition: DataHeader.cxx:111
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DataHeaderElement::getPrimaryClassID
CLID getPrimaryClassID() const
Definition: DataHeader.cxx:104
Token::toString
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition: Token.cxx:129
DataHeaderElement::getStorageType
long getStorageType() const
Definition: DataHeader.cxx:129
DataHeaderElement::m_hashes
std::vector< sgkey_t > m_hashes
hash table for ElementLink host container keys.
Definition: DataHeader.h:118
DataHeaderElement::m_clids
std::vector< CLID > m_clids
vector of unsigned long to store ClassID's for symlinked container.
Definition: DataHeader.h:110
DataHeaderElement::getAddress
SG::TransientAddress * getAddress(unsigned long contextId=0) const
Definition: DataHeader.cxx:148
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::TransientAddress::setSGKey
void setSGKey(sgkey_t sgkey)
check if it is a transient ID (primary or symLinked):
Definition: TransientAddress.h:238
Token::setData
const Token & setData(Token *pToken) const
Set all the data part of the token.
Definition: Token.cxx:209
DataHeaderElement::getToken
const Token * getToken() const
Definition: DataHeader.cxx:125
python.compressB64.c
def c
Definition: compressB64.py:93
SG::TransientAddress::transientID
bool transientID(CLID id) const
set transient CLID's
Definition: TransientAddress.h:245
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37