PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
podio::SIOFileTOCRecord Class Reference

#include <SIOBlock.h>

Public Types

using PositionType = sio_helpers::position_type
 

Public Member Functions

void addRecord (const std::string &name, PositionType startPos)
 
size_t getNRecords (const std::string &name) const
 
PositionType getPosition (const std::string &name, unsigned iEntry=0) const
 
std::vector< std::string_view > getRecordNames () const
 

Friends

struct SIOFileTOCRecordBlock
 

Detailed Description

Definition at line 285 of file SIOBlock.h.

Member Typedef Documentation

◆ PositionType

Member Function Documentation

◆ addRecord()

void podio::SIOFileTOCRecord::addRecord ( const std::string &  name,
PositionType  startPos 
)

Definition at line 184 of file SIOBlock.cc.

184 {
185 auto it =
186 std::find_if(m_recordMap.begin(), m_recordMap.end(), [&name](const auto& entry) { return entry.first == name; });
187
188 if (it == m_recordMap.end()) {
189 m_recordMap.push_back({name, {startPos}});
190 } else {
191 it->second.push_back(startPos);
192 }
193}

Referenced by podio::SIOFrameWriter::finish(), podio::SIOWriter::finish(), podio::SIOWriter::writeEvent(), and podio::SIOFrameWriter::writeFrame().

◆ getNRecords()

size_t podio::SIOFileTOCRecord::getNRecords ( const std::string &  name) const

Definition at line 195 of file SIOBlock.cc.

195 {
196 const auto it = std::find_if(m_recordMap.cbegin(), m_recordMap.cend(),
197 [&name](const auto& entry) { return entry.first == name; });
198 if (it != m_recordMap.cend()) {
199 return it->second.size();
200 }
201 return 0;
202}

Referenced by podio::SIOReader::getEntries(), podio::SIOFrameReader::getEntries(), and podio::SIOLegacyReader::getEntries().

◆ getPosition()

SIOFileTOCRecord::PositionType podio::SIOFileTOCRecord::getPosition ( const std::string &  name,
unsigned  iEntry = 0 
) const

Get the position of the iEntry-th record with the given name. If no entry with the given name is recorded, return 0. Note there is no internal check on whether the given name actually has iEntry records. Use getNRecords to check for that if necessary.

Definition at line 204 of file SIOBlock.cc.

204 {
205 const auto it = std::find_if(m_recordMap.cbegin(), m_recordMap.cend(),
206 [&name](const auto& keyVal) { return keyVal.first == name; });
207 if (it != m_recordMap.end()) {
208 if (iEntry < it->second.size()) {
209 return it->second[iEntry];
210 }
211 }
212
213 return 0;
214}

Referenced by podio::SIOLegacyReader::readEntry(), and podio::SIOFrameReader::readNextEntry().

◆ getRecordNames()

std::vector< std::string_view > podio::SIOFileTOCRecord::getRecordNames ( ) const

Get all the record names that are stored in this TOC record

Definition at line 216 of file SIOBlock.cc.

216 {
217 std::vector<std::string_view> cats;
218 cats.reserve(m_recordMap.size());
219 for (const auto& [cat, _] : m_recordMap) {
220 cats.emplace_back(cat);
221 }
222
223 return cats;
224}

Referenced by podio::SIOFrameReader::getAvailableCategories().

Friends And Related Function Documentation

◆ SIOFileTOCRecordBlock

friend struct SIOFileTOCRecordBlock
friend

Definition at line 304 of file SIOBlock.h.


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