ATLAS Offline Software
DataHeader_p6.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "CxxUtils/MD5.h"
9 
10 #include <uuid/uuid.h>
11 
13  m_dbRecords(rhs.m_dbRecords), m_objRecords(rhs.m_objRecords),
14  m_objAlias(rhs.m_objAlias), m_objSymLinks(rhs.m_objSymLinks),
15  m_objHashes(rhs.m_objHashes), m_version(rhs.m_version),
16  m_modified(rhs.m_modified), m_token()
17 {
18  setToken(rhs.m_token);
19 }
20 
22 {
23  if (&rhs != this) {
26  m_objAlias = rhs.m_objAlias;
29  m_version = rhs.m_version;
30  m_modified = rhs.m_modified;
31  setToken(rhs.m_token);
32  }
33  return *this;
34 }
35 
37 { }
38 
39 
40 unsigned int DataHeaderForm_p6::insertDb(const DbRecord& rec) {
41  unsigned int index = 0U;
42  for (std::vector<DbRecord>::const_iterator iter = m_dbRecords.begin(), last = m_dbRecords.end();
43  iter != last; ++iter, ++index) {
44  if (*iter == rec) break;
45  }
46  if (index == m_dbRecords.size()) {
47  m_dbRecords.push_back(rec);
48  m_modified = true;
49  }
50  return(index);
51 }
52 
53 std::size_t DataHeaderForm_p6::sizeDb() const {
54  return(m_dbRecords.size());
55 }
56 
58  return m_dbRecords[index].fid;
59 }
60 
61 unsigned int DataHeaderForm_p6::getDbTech(unsigned int index) const {
62  return m_dbRecords[index].tech;
63 }
64 
65 unsigned int DataHeaderForm_p6::insertObj(const ObjRecord& rec,
66  const std::set<std::string>& aliases, bool doAliasFiltering,
67  const std::set<unsigned int>& symLinks,
68  const std::vector<sgkey_t>& hashes)
69 {
70  unsigned int index = 0U;
71  for (std::vector<ObjRecord>::const_iterator iter = m_objRecords.begin(), last = m_objRecords.end();
72  iter != last; ++iter, ++index) {
73  if (*iter == rec) break;
74  }
75  std::vector<std::string> alias( aliases.cbegin(), aliases.cend() );
76  std::vector<unsigned int> symlinks( symLinks.begin(), symLinks.end() );
77  if (index != m_objRecords.size()) {
78  // found matching object record, check if all the info is the same
79  if( m_objSymLinks[index] != symlinks ) {
80  m_objSymLinks[index] = std::move(symlinks);
81  m_modified = true;
82  }
83  if( m_objHashes[index] != hashes ) {
85  m_modified = true;
86  }
87  if( (!doAliasFiltering or m_modified) and m_objAlias[index] != alias ) {
88  m_objAlias[index] = std::move(alias);
89  m_modified = true;
90  }
91  return index;
92  }
93  // enter a new record
94  m_objRecords.push_back( rec );
95  m_objAlias.push_back( std::move(alias) );
96  m_objSymLinks.push_back( std::move(symlinks) );
97  m_objHashes.push_back( hashes );
98  m_modified = true;
99  return m_objRecords.size() - 1;
100 }
101 
102 std::size_t DataHeaderForm_p6::sizeObj() const {
103  return(m_objRecords.size());
104 }
105 
106 std::string DataHeaderForm_p6::getObjContainer(unsigned int index) const {
107  return m_objRecords[index].cont;
108 }
109 
110 std::string DataHeaderForm_p6::getObjKey(unsigned int index) const {
111  return m_objRecords[index].key;
112 }
113 
114 unsigned int DataHeaderForm_p6::getObjType(unsigned int index) const {
115  return m_objRecords[index].clid;
116 }
117 
119  return m_objRecords[index].guid;
120 }
121 
122 std::set<std::string> DataHeaderForm_p6::getObjAlias(unsigned int index) const {
123  return(std::set<std::string>(m_objAlias[index].begin(), m_objAlias[index].end()));
124 }
125 
126 std::set<unsigned int> DataHeaderForm_p6::getObjSymLinks(unsigned int index) const {
127  return(std::set<unsigned int>(m_objSymLinks[index].begin(), m_objSymLinks[index].end()));
128 }
129 
130 std::vector<DataHeaderForm_p6::sgkey_t>
132  return(m_objHashes[index]);
133 }
134 
136  return m_modified;
137 }
138 
140  m_modified = false;
141 }
142 
143 void DataHeaderForm_p6::setToken( const std::string& tok )
144 {
145  m_token = tok;
146 }
147 
148 const std::string& DataHeaderForm_p6::getToken() const {
149  return m_token;
150 }
151 
152 void DataHeaderForm_p6::resize(unsigned int size) {
153  m_objRecords.reserve( size );
154  m_objAlias.reserve( size );
155  m_objSymLinks.reserve( size );
156  m_objHashes.reserve( size );
157 }
158 
159 
160 
161 //---------------------------------------------------------------------
162 
163 const std::string& DataHeader_p6::dhFormToken() const {
164  return(m_dhFormToken);
165 }
166 
167 void DataHeader_p6::setDhFormToken(const std::string& formToken) {
168  m_dhFormToken = formToken;
169 }
170 
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
DataHeaderForm_p6
This class provides storage for the constant fields of the persistent DataHeader class.
Definition: DataHeader_p6.h:27
DataHeaderForm_p6::isModified
bool isModified() const
Definition: DataHeader_p6.cxx:135
DataHeaderForm_p6::m_objHashes
std::vector< std::vector< sgkey_t > > m_objHashes
Definition: DataHeader_p6.h:95
DataHeaderForm_p6::operator=
DataHeaderForm_p6 & operator=(const DataHeaderForm_p6 &rhs)
Definition: DataHeader_p6.cxx:21
index
Definition: index.py:1
DataHeader_p6::m_dhFormToken
std::string m_dhFormToken
Definition: DataHeader_p6.h:141
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
DataHeaderForm_p6::DbRecord
Definition: DataHeader_p6.h:33
DataHeaderForm_p6::DataHeaderForm_p6
DataHeaderForm_p6()
Definition: DataHeader_p6.h:55
DataHeaderForm_p6::m_dbRecords
std::vector< DbRecord > m_dbRecords
Definition: DataHeader_p6.h:91
DataHeader_p6::setDhFormToken
void setDhFormToken(const std::string &formToken)
Definition: DataHeader_p6.cxx:167
MD5.h
solar's public-domain MD5, wrapped for C++.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
DataHeaderForm_p6::m_token
std::string m_token
Reference to self in the persistent storage.
Definition: DataHeader_p6.h:106
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DataHeaderForm_p6::getObjType
unsigned int getObjType(unsigned int index) const
Definition: DataHeader_p6.cxx:114
DataHeaderForm_p6::m_objRecords
std::vector< ObjRecord > m_objRecords
Definition: DataHeader_p6.h:92
DataHeaderForm_p6::getObjContainer
std::string getObjContainer(unsigned int index) const
Definition: DataHeader_p6.cxx:106
DataHeaderForm_p6::getToken
const std::string & getToken() const
Definition: DataHeader_p6.cxx:148
DataHeader_p6::dhFormToken
const std::string & dhFormToken() const
Definition: DataHeader_p6.cxx:163
DataHeaderForm_p6::getObjClassId
Guid getObjClassId(unsigned int index) const
Definition: DataHeader_p6.cxx:118
DataHeaderForm_p6::getDbGuid
Guid getDbGuid(unsigned int index) const
Definition: DataHeader_p6.cxx:57
DataHeader_p6.h
This file contains the class definitions for the DataHeader_p6 and DataHeaderForm_p6.
COOLRates.alias
alias
Definition: COOLRates.py:1172
DataHeaderForm_p6::~DataHeaderForm_p6
~DataHeaderForm_p6()
Definition: DataHeader_p6.cxx:36
DataHeaderForm_p6::insertObj
unsigned int insertObj(const ObjRecord &rec, const std::set< std::string > &alias=std::set< std::string >(), bool doAliasFiletering=true, const std::set< unsigned int > &symLinks=std::set< unsigned int >(), const std::vector< sgkey_t > &hashes=std::vector< sgkey_t >())
Definition: DataHeader_p6.cxx:65
DataHeaderForm_p6::getObjSymLinks
std::set< unsigned int > getObjSymLinks(unsigned int index) const
Definition: DataHeader_p6.cxx:126
DataHeaderForm_p6::clearModified
void clearModified()
Definition: DataHeader_p6.cxx:139
DataHeaderForm_p6::sizeDb
std::size_t sizeDb() const
Definition: DataHeader_p6.cxx:53
DataHeaderForm_p6::m_objAlias
std::vector< std::vector< std::string > > m_objAlias
Definition: DataHeader_p6.h:93
DataHeaderForm_p6::getObjHashes
std::vector< sgkey_t > getObjHashes(unsigned int index) const
Definition: DataHeader_p6.cxx:131
DataHeaderForm_p6::setToken
void setToken(const std::string &tok)
Definition: DataHeader_p6.cxx:143
DataHeaderForm_p6::sizeObj
std::size_t sizeObj() const
Definition: DataHeader_p6.cxx:102
DeMoScan.index
string index
Definition: DeMoScan.py:364
DataHeaderForm_p6::m_modified
bool m_modified
indicates that the last event was somehow different and a new DHForm needs to be written
Definition: DataHeader_p6.h:104
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
DataHeaderForm_p6::resize
void resize(unsigned int size)
Definition: DataHeader_p6.cxx:152
DataHeaderForm_p6::getObjKey
std::string getObjKey(unsigned int index) const
Definition: DataHeader_p6.cxx:110
DataHeaderForm_p6::m_objSymLinks
std::vector< std::vector< unsigned int > > m_objSymLinks
Definition: DataHeader_p6.h:94
DataHeaderForm_p6::getDbTech
unsigned int getDbTech(unsigned int index) const
Definition: DataHeader_p6.cxx:61
DataHeaderForm_p6::insertDb
unsigned int insertDb(const DbRecord &rec)
Definition: DataHeader_p6.cxx:40
DataHeaderForm_p6::m_version
unsigned m_version
Subversion of DHForm_p6 for small changes of data encoding.
Definition: DataHeader_p6.h:98
Token.h
This file contains the class definition for the Token class (migrated from POOL).
DataHeaderForm_p6::getObjAlias
std::set< std::string > getObjAlias(unsigned int index) const
Definition: DataHeader_p6.cxx:122
DataHeaderForm_p6::ObjRecord
Definition: DataHeader_p6.h:39