ATLAS Offline Software
Loading...
Searching...
No Matches
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.
 DataHeaderElement (const DataHeaderElement &rhs)
 Copy Constructor.
 DataHeaderElement (const SG::TransientAddress *sgAddress, IOpaqueAddress *tokAddress, const std::string &pTag)
 Constructor.
 DataHeaderElement (const SG::DataProxy *proxy, IOpaqueAddress *tokAddress, const std::string &pTag)
 Constructor.
 DataHeaderElement (const CLID classID, const std::string &key, Token &&token)
 Constructor.
virtual ~DataHeaderElement ()
 Destructor.
DataHeaderElementoperator= (const DataHeaderElement &rhs)
 Assignment Operator.
CLID getPrimaryClassID () const
const std::set< CLIDgetClassIDs () const
const std::string & getKey () const
const std::vector< std::string > & getAlias () const
const TokengetToken () const
const std::vector< sgkey_t > & getHashes () const
SG::TransientAddressgetAddress (long storageType) const
SG::TransientAddressgetAddress (long storageType, const std::string &key) const
void addHash (IStringPool *pool)
 Add new entry to hash map.
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.

Private Attributes

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

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}
CLID m_pClid
primary ClassID.
Definition DataHeader.h:105
std::string m_key
string with StoreGate key.
Definition DataHeader.h:109
std::vector< std::string > m_alias
vector of StoreGate alias string.
Definition DataHeader.h:111
std::vector< CLID > m_clids
vector of unsigned long to store ClassID's for symlinked container.
Definition DataHeader.h:107
std::vector< sgkey_t > m_hashes
hash table for ElementLink host container keys.
Definition DataHeader.h:115

◆ 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}
const Token * getToken() const
Token m_token
Transient address token.
Definition DataHeader.h:113

◆ 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()
Default Constructor.
CLID clID() const
Retrieve string key:
const std::string & name() const
Get the primary (hashed) SG key.
bool transientID(CLID id) const
set transient CLID's
const TransientAliasSet & alias() const
set the clearAddress flag: IOA will not be deleted in proxy

◆ 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}
Token * getToken()
const Token & setData(Token *pToken) const
Set all the data part of the token.
Definition Token.cxx:225

Member Function Documentation

◆ addHash()

void DataHeaderElement::addHash ( IStringPool * pool)

Add new entry to hash map.

Definition at line 134 of file DataHeader.cxx.

134 {
135 if (!m_hashes.empty()) {
136 return;
137 }
138 std::set<CLID> clids = getClassIDs();
139 for (std::set<CLID>::iterator iter = clids.begin(), last = clids.end(); iter != last; ++iter) {
140 m_hashes.push_back(pool->stringToKey(m_key, *iter));
141 }
142}
const std::set< CLID > getClassIDs() const
virtual sgkey_t stringToKey(const std::string &str, CLID clid)=0
Find the key for a string/CLID pair.

◆ dump()

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

Definition at line 172 of file DataHeader.cxx.

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

◆ getAddress() [1/2]

SG::TransientAddress * DataHeaderElement::getAddress ( long storageType) const
Returns
a pointer to the TransientAddress of the DataObject.

Definition at line 144 of file DataHeader.cxx.

144 {
145 return getAddress(storageType, m_key);
146}
SG::TransientAddress * getAddress(long storageType) const

◆ getAddress() [2/2]

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

Definition at line 148 of file DataHeader.cxx.

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

◆ 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 130 of file DataHeader.cxx.

130 {
131 return(m_hashes);
132}

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

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

◆ DataHeaderCnv_p6

friend class DataHeaderCnv_p6
friend

Definition at line 94 of file DataHeader.h.

◆ DataHeaderElementCnv_p3

friend class DataHeaderElementCnv_p3
friend

Definition at line 91 of file DataHeader.h.

◆ DataHeaderElementCnv_p4

friend class DataHeaderElementCnv_p4
friend

Definition at line 92 of file DataHeader.h.

◆ DataHeaderElementCnv_p5

friend class DataHeaderElementCnv_p5
friend

Definition at line 93 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 111 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 107 of file DataHeader.h.

◆ m_hashes

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

hash table for ElementLink host container keys.

Definition at line 115 of file DataHeader.h.

◆ m_key

std::string DataHeaderElement::m_key
private

string with StoreGate key.

Definition at line 109 of file DataHeader.h.

◆ m_pClid

CLID DataHeaderElement::m_pClid
private

primary ClassID.

Definition at line 105 of file DataHeader.h.

◆ m_token

Token DataHeaderElement::m_token
private

Transient address token.

Definition at line 113 of file DataHeader.h.


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