4#include <sio/compression/zlib.h>
17 const auto& names = m_idTable.
names();
18 const auto nameIt = std::find(std::begin(names), std::end(names), name);
20 const auto index = std::distance(std::begin(names), nameIt) + 1;
22 m_availableBlocks[index] = 1;
23 return {
dynamic_cast<podio::SIOBlock*
>(m_blocks[index].get())->getBuffers()};
31 m_availableBlocks[0] = 0;
32 return std::make_unique<podio::GenericParameters>(std::move(m_parameters));
37 std::vector<std::string> collections;
38 for (
size_t i = 0; i < m_blocks.size(); ++i) {
39 if (m_availableBlocks[i]) {
40 collections.push_back(m_idTable.
name(i));
47void SIOFrameData::unpackBuffers() {
51 if (!m_blocks.empty()) {
55 if (m_idTable.
empty()) {
61 sio::zlib_compression compressor;
62 sio::buffer uncBuffer{m_dataSize};
63 compressor.uncompress(m_recBuffer.span(), uncBuffer);
64 sio::api::read_blocks(uncBuffer.span(), m_blocks);
67void SIOFrameData::createBlocks() {
68 m_blocks.reserve(m_typeNames.size() + 1);
70 auto parameters = std::make_shared<podio::SIOEventMetaDataBlock>();
71 parameters->metadata = &m_parameters;
72 m_blocks.push_back(parameters);
74 for (
size_t i = 0; i < m_typeNames.size(); ++i) {
75 const bool subsetColl = !m_subsetCollectionBits.empty() && m_subsetCollectionBits[i];
77 m_blocks.push_back(blk);
80 m_availableBlocks.resize(m_blocks.size(), 1);
83void SIOFrameData::readIdTable() {
84 sio::buffer uncBuffer{m_tableSize};
85 sio::zlib_compression compressor;
86 compressor.uncompress(m_tableBuffer.span(), uncBuffer);
88 sio::block_list blocks;
89 blocks.emplace_back(std::make_shared<SIOCollectionIDTableBlock>());
90 sio::api::read_blocks(uncBuffer.span(), blocks);
92 auto* idTableBlock =
static_cast<SIOCollectionIDTableBlock*
>(blocks[0].get());
93 m_idTable = std::move(*idTableBlock->getTable());
94 m_typeNames = idTableBlock->getTypeNames();
95 m_subsetCollectionBits = idTableBlock->getSubsetCollectionBits();
bool present(const std::string &name) const
Check if collection name is known.
bool empty() const
Does this table hold any information?
const std::vector< std::string > & names() const
return registered names
const std::string name(int collectionID) const
return name for given collection ID
static SIOBlockFactory & instance()
std::shared_ptr< SIOBlock > createBlock(const podio::CollectionBase *col, const std::string &name) const
Base class for sio::block handlers used with PODIO.
std::unique_ptr< podio::GenericParameters > getParameters()
std::vector< std::string > getAvailableCollections()
std::optional< podio::CollectionReadBuffers > getCollectionBuffers(const std::string &name)