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.
DataHeaderElement & operator= (const DataHeaderElement &rhs)
 Assignment Operator.
CLID getPrimaryClassID () const
const std::set< CLID > getClassIDs () const
const std::string & getKey () const
const std::vector< std::string > & getAlias () const
const Token * getToken () const
const std::vector< sgkey_t > & getHashes () const
SG::TransientAddress * getAddress (long storageType) const
SG::TransientAddress * getAddress (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< CLID > m_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_t > m_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 20 of file DataHeader.cxx.

20 : m_pClid(0), m_clids(), m_key(), m_alias(), m_hashes() {
21}
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 23 of file DataHeader.cxx.

23 : m_pClid(rhs.m_pClid),
24 m_clids(rhs.m_clids),
25 m_key(rhs.m_key),
26 m_alias(rhs.m_alias),
27 m_token(rhs.getToken()),
28 m_hashes(rhs.m_hashes) {
29}
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 31 of file DataHeader.cxx.

33 : DataHeaderElement (sgAddress->clID(),
34 sgAddress->name(),
35 sgAddress->transientID(),
36 std::vector<std::string>(sgAddress->alias()),
37 sgAddress->address(),
38 tokAddress, pTag)
39{
40}
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 42 of file DataHeader.cxx.

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

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

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

◆ ~DataHeaderElement()

DataHeaderElement::~DataHeaderElement ( )
virtual

Destructor.

Definition at line 90 of file DataHeader.cxx.

90 {
91}

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

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

Member Function Documentation

◆ addHash()

void DataHeaderElement::addHash ( IStringPool * pool)

Add new entry to hash map.

Definition at line 135 of file DataHeader.cxx.

135 {
136 if (!m_hashes.empty()) {
137 return;
138 }
139 std::set<CLID> clids = getClassIDs();
140 for (std::set<CLID>::iterator iter = clids.begin(), last = clids.end(); iter != last; ++iter) {
141 m_hashes.push_back(pool->stringToKey(m_key, *iter));
142 }
143}
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 173 of file DataHeader.cxx.

174{
175 using namespace std;
176 std::println (ostr, "SGKey: {}", getKey());
177 std::print (ostr, "CLID: {}", getPrimaryClassID());
178 if( getClassIDs().size() > 1 ) {
179 std::print (ostr, " ||");
180 for( auto& c : getClassIDs() ) std::print (ostr, " {}", c);
181 }
182 std::println();
183 if( getAlias().size() > 0 ) {
184 std::print (ostr, "Alias: ");
185 for( const std::string& a : getAlias() ) std::print (ostr, " {}", a);
186 std::println();
187 }
188 std::println (ostr, "Token: {}", m_token.toString());
189 if( m_hashes.size() ) {
190 std::print (ostr, "Hashes:");
191 for( auto h : m_hashes ) std::print (ostr, " {}", h);
192 std::println();
193 }
194}
static Double_t a
size_t size() const
Number of registered mappings.
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 145 of file DataHeader.cxx.

145 {
146 return getAddress(storageType, m_key);
147}
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 149 of file DataHeader.cxx.

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

122 {
123 return(m_alias);
124}

◆ getClassIDs()

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

Definition at line 112 of file DataHeader.cxx.

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

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

131 {
132 return(m_hashes);
133}

◆ getKey()

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

Definition at line 118 of file DataHeader.cxx.

118 {
119 return(m_key);
120}

◆ getPrimaryClassID()

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

Definition at line 105 of file DataHeader.cxx.

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

◆ getToken()

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

Definition at line 126 of file DataHeader.cxx.

126 {
127 return(&m_token);
128}

◆ operator=()

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

Assignment Operator.

Definition at line 93 of file DataHeader.cxx.

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

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