diff --git a/include/podio/ROOTFrameData.h b/include/podio/ROOTFrameData.h index d58dd43e4..502ff24ef 100644 --- a/include/podio/ROOTFrameData.h +++ b/include/podio/ROOTFrameData.h @@ -25,37 +25,15 @@ class ROOTFrameData { ROOTFrameData(const ROOTFrameData&) = delete; ROOTFrameData& operator=(const ROOTFrameData&) = delete; - ROOTFrameData(BufferMap&& buffers, CollIDPtr&& idTable, podio::GenericParameters&& params) : - m_buffers(std::move(buffers)), m_idTable(std::move(idTable)), m_parameters(std::move(params)) { - } + ROOTFrameData(BufferMap&& buffers, CollIDPtr&& idTable, podio::GenericParameters&& params); - std::optional getCollectionBuffers(const std::string& name) { - const auto bufferHandle = m_buffers.extract(name); - if (bufferHandle.empty()) { - return std::nullopt; - } + std::optional getCollectionBuffers(const std::string& name); - return {bufferHandle.mapped()}; - } + podio::CollectionIDTable getIDTable() const; - podio::CollectionIDTable getIDTable() const { - // Construct a copy of the internal table - return {m_idTable->ids(), m_idTable->names()}; - } + std::unique_ptr getParameters(); - std::unique_ptr getParameters() { - return std::make_unique(std::move(m_parameters)); - } - - std::vector getAvailableCollections() const { - std::vector collections; - collections.reserve(m_buffers.size()); - for (const auto& [name, _] : m_buffers) { - collections.push_back(name); - } - - return collections; - } + std::vector getAvailableCollections() const; private: // TODO: switch to something more elegant once the basic functionality and @@ -66,13 +44,6 @@ class ROOTFrameData { podio::GenericParameters m_parameters{}; }; -// Interim workaround for https://github.com/AIDASoft/podio#500 -inline ROOTFrameData::~ROOTFrameData() { - for (auto& [_, buffer] : m_buffers) { - buffer.deleteBuffers(buffer); - } -} - } // namespace podio #endif // PODIO_ROOTFRAMEDATA_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb5092498..1d83bfba4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,6 +80,7 @@ SET(root_sources ROOTWriter.cc ROOTReader.cc ROOTLegacyReader.cc + ROOTFrameData.cc ) if(ENABLE_RNTUPLE) list(APPEND root_sources @@ -93,6 +94,7 @@ SET(root_headers ${PROJECT_SOURCE_DIR}/include/podio/ROOTLegacyReader.h ${PROJECT_SOURCE_DIR}/include/podio/ROOTWriter.h ${PROJECT_SOURCE_DIR}/include/podio/utilities/RootHelpers.h + ${PROJECT_SOURCE_DIR}/include/podio/ROOTFrameData.h ) if(ENABLE_RNTUPLE) list(APPEND root_headers diff --git a/src/ROOTFrameData.cc b/src/ROOTFrameData.cc new file mode 100644 index 000000000..2fde64154 --- /dev/null +++ b/src/ROOTFrameData.cc @@ -0,0 +1,44 @@ +#include "podio/ROOTFrameData.h" + +namespace podio { + +ROOTFrameData::ROOTFrameData(BufferMap&& buffers, CollIDPtr&& idTable, podio::GenericParameters&& params) : + m_buffers(std::move(buffers)), m_idTable(std::move(idTable)), m_parameters(std::move(params)) { +} + +// Interim workaround for https://github.com/AIDASoft/podio#500 +ROOTFrameData::~ROOTFrameData() { + for (auto& [_, buffer] : m_buffers) { + buffer.deleteBuffers(buffer); + } +} + +std::optional ROOTFrameData::getCollectionBuffers(const std::string& name) { + const auto bufferHandle = m_buffers.extract(name); + if (bufferHandle.empty()) { + return std::nullopt; + } + + return {bufferHandle.mapped()}; +} + +podio::CollectionIDTable ROOTFrameData::getIDTable() const { + // Construct a copy of the internal table + return {m_idTable->ids(), m_idTable->names()}; +} + +std::unique_ptr ROOTFrameData::getParameters() { + return std::make_unique(std::move(m_parameters)); +} + +std::vector ROOTFrameData::getAvailableCollections() const { + std::vector collections; + collections.reserve(m_buffers.size()); + for (const auto& [name, _] : m_buffers) { + collections.push_back(name); + } + + return collections; +} + +} // namespace podio