ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
ByteStreamCnvSvc
src
ByteStreamMetadataTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
9
10
#include "
ByteStreamMetadataTool.h
"
11
12
#include "
ByteStreamData/ByteStreamMetadataContainer.h
"
13
#include "
StoreGate/StoreGateSvc.h
"
14
15
16
/******************************************************************************/
17
ByteStreamMetadataTool::ByteStreamMetadataTool
(
18
const
std::string&
type
,
19
const
std::string& name,
20
const
IInterface* parent)
21
: base_class(
type
, name, parent)
22
,
m_metadataStore
(
"StoreGateSvc/MetaDataStore"
, name)
23
,
m_inputStore
(
"StoreGateSvc/InputMetaDataStore"
, name)
24
{
25
}
26
27
28
/******************************************************************************/
29
ByteStreamMetadataTool::~ByteStreamMetadataTool
()
30
{}
31
32
33
/******************************************************************************/
34
StatusCode
35
ByteStreamMetadataTool::initialize
()
36
{
37
ATH_MSG_INFO
(
"Initializing"
);
38
39
ATH_CHECK
(
m_metadataStore
.retrieve());
40
ATH_CHECK
(
m_inputStore
.retrieve());
41
42
return
StatusCode::SUCCESS;
43
}
44
45
46
/******************************************************************************/
47
StatusCode
48
ByteStreamMetadataTool::beginInputFile
(
const
SG::SourceID
&)
49
{
50
std::set<std::string> keys =
keysFromInput
();
51
52
std::vector<std::unique_ptr<ByteStreamMetadata> > copy;
53
std::set<std::string> transGuids;
54
55
56
for
(
const
auto
& key : keys) {
57
ATH_MSG_DEBUG
(
"Processing Input ByteStreamMetadata, key = "
<< key);
58
copy.clear();
59
60
if
(
m_inputStore
->contains<
ByteStreamMetadata
>(key)) {
61
62
std::list<SG::ObjectWithVersion<ByteStreamMetadata> > allVersions;
63
ATH_CHECK
(
m_inputStore
->retrieveAllVersions(allVersions, key));
64
65
for
(
SG::ObjectWithVersion<ByteStreamMetadata>
& obj : allVersions)
66
copy.push_back(std::make_unique<ByteStreamMetadata>(*obj.dataObject));
67
68
}
69
70
71
if
(
m_inputStore
->contains<
ByteStreamMetadataContainer
>(key)) {
72
73
std::list<SG::ObjectWithVersion<ByteStreamMetadataContainer> > allVersions;
74
ATH_CHECK
(
m_inputStore
->retrieveAllVersions(allVersions, key));
75
76
for
(
SG::ObjectWithVersion<ByteStreamMetadataContainer>
& obj : allVersions)
77
for
(
const
ByteStreamMetadata
* md : *obj.dataObject)
78
copy.push_back(std::make_unique<ByteStreamMetadata>(*md));
79
}
80
81
82
if
(!copy.empty()) {
83
84
transGuids.clear();
85
// Check for existing container
86
ByteStreamMetadataContainer
* bsmdc =
nullptr
;
87
88
if
(
m_metadataStore
->contains<
ByteStreamMetadataContainer
>(key)) {
89
90
ATH_MSG_DEBUG
(
"Pre-existing ByteStreamMetadataContainer found"
);
91
ATH_CHECK
(
m_metadataStore
->retrieve(bsmdc, key));
92
93
for
(
const
auto
bsmd : *bsmdc)
94
transGuids.insert(bsmd->getGuid());
95
96
}
else
{
97
98
bsmdc =
new
ByteStreamMetadataContainer
;
99
ATH_CHECK
(
m_metadataStore
->record(bsmdc, key));
100
101
}
102
103
for
(
auto
& pBSMD : copy) {
104
// Only insert new metadata records (with GUID not yet in container)
105
if
(transGuids.insert(pBSMD->getGuid()).second)
106
bsmdc->
push_back
(std::move(pBSMD));
107
}
108
}
109
}
110
111
return
StatusCode::SUCCESS;
112
}
113
114
115
116
/******************************************************************************/
117
inline
118
std::set<std::string>
119
ByteStreamMetadataTool::keysFromInput
()
const
120
{
121
std::vector<std::string> vKeys;
122
std::set<std::string> keys;
123
124
m_inputStore
->keys<
ByteStreamMetadata
>(vKeys);
125
keys.insert(vKeys.begin(), vKeys.end());
126
127
m_inputStore
->keys<
ByteStreamMetadataContainer
>(vKeys);
128
keys.insert(vKeys.begin(), vKeys.end());
129
130
return
keys;
131
}
132
133
134
/******************************************************************************/
135
StatusCode
136
ByteStreamMetadataTool::endInputFile
(
const
SG::SourceID
&)
137
{
138
return
StatusCode::SUCCESS;
139
}
140
141
142
StatusCode
143
ByteStreamMetadataTool::metaDataStop
()
144
{
145
return
StatusCode::SUCCESS;
146
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ByteStreamMetadataContainer.h
This file contains the class definition for the ByteStreamMetadataContainer class.
ByteStreamMetadataTool.h
This file contains the class definition for the ByteStreamMetadataTool class.
StoreGateSvc.h
ByteStreamMetadataContainer
This class is the StoreGate data object for bytestream metadata.
Definition
ByteStreamMetadataContainer.h:22
ByteStreamMetadataTool::beginInputFile
virtual StatusCode beginInputFile(const SG::SourceID &) override
Incident service handle listening for BeginInputFile and EndInputFile.
Definition
ByteStreamMetadataTool.cxx:48
ByteStreamMetadataTool::ByteStreamMetadataTool
ByteStreamMetadataTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Service Constructor.
Definition
ByteStreamMetadataTool.cxx:17
ByteStreamMetadataTool::~ByteStreamMetadataTool
virtual ~ByteStreamMetadataTool()
Destructor.
Definition
ByteStreamMetadataTool.cxx:29
ByteStreamMetadataTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition
ByteStreamMetadataTool.cxx:35
ByteStreamMetadataTool::m_inputStore
ServiceHandle< StoreGateSvc > m_inputStore
Definition
ByteStreamMetadataTool.h:49
ByteStreamMetadataTool::endInputFile
virtual StatusCode endInputFile(const SG::SourceID &) override
Definition
ByteStreamMetadataTool.cxx:136
ByteStreamMetadataTool::metaDataStop
virtual StatusCode metaDataStop() override
Definition
ByteStreamMetadataTool.cxx:143
ByteStreamMetadataTool::m_metadataStore
ServiceHandle< StoreGateSvc > m_metadataStore
Definition
ByteStreamMetadataTool.h:48
ByteStreamMetadataTool::keysFromInput
std::set< std::string > keysFromInput() const
Definition
ByteStreamMetadataTool.cxx:119
ByteStreamMetadata
This class is the StoreGate data object for bytestream metadata.
Definition
ByteStreamMetadata.h:25
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::ObjectWithVersion
associate a data object with its VersionedKey The object is held by a ReadHandle to delay its retriev...
Definition
SGObjectWithVersion.h:20
SG::SourceID
std::string SourceID
Definition
AthenaKernel/AthenaKernel/SourceID.h:25
type
Generated on
for ATLAS Offline Software by
1.17.0