ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
14
15
16/******************************************************************************/
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/******************************************************************************/
31
32
33/******************************************************************************/
34StatusCode
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/******************************************************************************/
47StatusCode
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 const ByteStreamMetadata* obj = nullptr;
62 ATH_CHECK(m_inputStore->retrieve(obj, key));
63 copy.push_back(std::make_unique<ByteStreamMetadata>(*obj));
64 }
65
66 if(m_inputStore->contains<ByteStreamMetadataContainer>(key)) {
67 const ByteStreamMetadataContainer* obj = nullptr;
68 ATH_CHECK(m_inputStore->retrieve(obj, key));
69 for(const ByteStreamMetadata* md : *obj)
70 copy.push_back(std::make_unique<ByteStreamMetadata>(*md));
71 }
72
73
74 if(!copy.empty()) {
75
76 transGuids.clear();
77 // Check for existing container
78 ByteStreamMetadataContainer* bsmdc = nullptr;
79
80 if (m_metadataStore->contains<ByteStreamMetadataContainer>(key)) {
81
82 ATH_MSG_DEBUG("Pre-existing ByteStreamMetadataContainer found");
83 ATH_CHECK(m_metadataStore->retrieve(bsmdc, key));
84
85 for (const auto bsmd : *bsmdc)
86 transGuids.insert(bsmd->getGuid());
87
88 } else {
89
91 ATH_CHECK(m_metadataStore->record(bsmdc, key));
92
93 }
94
95 for(auto& pBSMD : copy) {
96 // Only insert new metadata records (with GUID not yet in container)
97 if(transGuids.insert(pBSMD->getGuid()).second)
98 bsmdc->push_back(std::move(pBSMD));
99 }
100 }
101 }
102
103 return StatusCode::SUCCESS;
104}
105
106
107
108/******************************************************************************/
109inline
110std::set<std::string>
112{
113 std::vector<std::string> vKeys;
114 std::set<std::string> keys;
115
116 m_inputStore->keys<ByteStreamMetadata>(vKeys);
117 keys.insert(vKeys.begin(), vKeys.end());
118
120 keys.insert(vKeys.begin(), vKeys.end());
121
122 return keys;
123}
124
125
126/******************************************************************************/
127StatusCode
129{
130 return StatusCode::SUCCESS;
131}
132
133
134StatusCode
136{
137 return StatusCode::SUCCESS;
138}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
This file contains the class definition for the ByteStreamMetadataContainer class.
This file contains the class definition for the ByteStreamMetadataTool class.
This class is the StoreGate data object for bytestream metadata.
virtual StatusCode beginInputFile(const SG::SourceID &) override
Incident service handle listening for BeginInputFile and EndInputFile.
ByteStreamMetadataTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Service Constructor.
virtual ~ByteStreamMetadataTool()
Destructor.
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
ServiceHandle< StoreGateSvc > m_inputStore
virtual StatusCode endInputFile(const SG::SourceID &) override
virtual StatusCode metaDataStop() override
ServiceHandle< StoreGateSvc > m_metadataStore
std::set< std::string > keysFromInput() const
This class is the StoreGate data object for bytestream metadata.
value_type push_back(value_type pElem)
Add an element to the end of the collection.