PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
ROOTFrameData.h
Go to the documentation of this file.
1#ifndef PODIO_ROOTFRAMEDATA_H
2#define PODIO_ROOTFRAMEDATA_H
3
7
8#include <memory>
9#include <optional>
10#include <string>
11#include <unordered_map>
12
13namespace podio {
14
16 using CollIDPtr = std::shared_ptr<const podio::CollectionIDTable>;
17
18public:
19 using BufferMap = std::unordered_map<std::string, podio::CollectionReadBuffers>;
20
21 ROOTFrameData() = delete;
22 ~ROOTFrameData() = default;
25 ROOTFrameData(const ROOTFrameData&) = delete;
27
28 ROOTFrameData(BufferMap&& buffers, CollIDPtr&& idTable, podio::GenericParameters&& params) :
29 m_buffers(std::move(buffers)), m_idTable(idTable), m_parameters(std::move(params)) {
30 }
31
32 std::optional<podio::CollectionReadBuffers> getCollectionBuffers(const std::string& name) {
33 const auto bufferHandle = m_buffers.extract(name);
34 if (bufferHandle.empty()) {
35 return std::nullopt;
36 }
37
38 return {bufferHandle.mapped()};
39 }
40
42 // Construct a copy of the internal table
43 return {m_idTable->ids(), m_idTable->names()};
44 }
45
46 std::unique_ptr<podio::GenericParameters> getParameters() {
47 return std::make_unique<podio::GenericParameters>(std::move(m_parameters));
48 }
49
50 std::vector<std::string> getAvailableCollections() const {
51 std::vector<std::string> collections;
52 collections.reserve(m_buffers.size());
53 for (const auto& [name, _] : m_buffers) {
54 collections.push_back(name);
55 }
56
57 return collections;
58 }
59
60private:
61 // TODO: switch to something more elegant once the basic functionality and
62 // interface is better defined
63 BufferMap m_buffers{};
64 // This is co-owned by each FrameData and the original reader. (for now at least)
65 CollIDPtr m_idTable{nullptr};
66 podio::GenericParameters m_parameters{};
67};
68} // namespace podio
69
70#endif // PODIO_ROOTFRAMEDATA_H
ROOTFrameData & operator=(const ROOTFrameData &)=delete
ROOTFrameData & operator=(ROOTFrameData &&)=default
podio::CollectionIDTable getIDTable() const
Definition: ROOTFrameData.h:41
~ROOTFrameData()=default
ROOTFrameData(ROOTFrameData &&)=default
ROOTFrameData(const ROOTFrameData &)=delete
std::unordered_map< std::string, podio::CollectionReadBuffers > BufferMap
Definition: ROOTFrameData.h:19
ROOTFrameData(BufferMap &&buffers, CollIDPtr &&idTable, podio::GenericParameters &&params)
Definition: ROOTFrameData.h:28
std::vector< std::string > getAvailableCollections() const
Definition: ROOTFrameData.h:50
std::optional< podio::CollectionReadBuffers > getCollectionBuffers(const std::string &name)
Definition: ROOTFrameData.h:32
std::unique_ptr< podio::GenericParameters > getParameters()
Definition: ROOTFrameData.h:46