PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
SIOLegacyReader.h
Go to the documentation of this file.
1#ifndef PODIO_SIOLEGACYREADER_H
2#define PODIO_SIOLEGACYREADER_H
3
4#include "podio/SIOBlock.h"
6#include "podio/podioVersion.h"
7
8#include <sio/definitions.h>
9
10#include <memory>
11#include <string_view>
12#include <vector>
13
14namespace podio {
15
16class CollectionIDTable;
17
18/**
19 * A SIO reader for reading legacy podio .sio files that have been written using
20 * the legacy, non Frame based I/O model. This reader grants Frame based access
21 * to those files, by mimicking Frame I/O functionality and the interfaces of
22 * those readers.
23 *
24 * NOTE: Since there was only one category ("events") for those legacy podio
25 * files this reader will really only work if you try to read that category, and
26 * will simply return no data if you try to read anything else.
27 */
29
30public:
32 ~SIOLegacyReader() = default;
33
34 // non copy-able
37
38 /**
39 * Read the next data entry from which a Frame can be constructed. In case
40 * there are no more entries left, this returns a nullptr.
41 *
42 * NOTE: the category name has to be "events" in this case, as only that
43 * category is available for legacy files.
44 */
45 std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string&);
46
47 /**
48 * Read the specified data entry from which a Frame can be constructed In case
49 * the entry does not exist, this returns a nullptr.
50 *
51 * NOTE: the category name has to be "events" in this case, as only that
52 * category is available for legacy files.
53 */
54 std::unique_ptr<podio::SIOFrameData> readEntry(const std::string&, const unsigned entry);
55
56 /// Returns the number of
57 unsigned getEntries(const std::string& name) const;
58
59 void openFile(const std::string& filename);
60
61 /// Get the build version of podio that has been used to write the current file
63 return m_fileVersion;
64 }
65
66 /// Get the names of all the availalable Frame categories in the current file(s)
67 std::vector<std::string_view> getAvailableCategories() const;
68
69private:
70 /// read the TOC record
71 bool readFileTOCRecord();
72
73 void readCollectionIDTable();
74
75 sio::ifstream m_stream{};
76
77 // TODO: Move these somewhere else
78 std::vector<std::string> m_typeNames{};
79 std::vector<short> m_subsetCollectionBits{};
80
81 sio::buffer m_tableBuffer{1}; ///< The buffer holding the **compressed** CollectionIDTable
82 unsigned m_tableUncLength{0}; ///< The uncompressed length of the tableBuffer
83
84 std::shared_ptr<podio::CollectionIDTable> m_table{nullptr};
85 unsigned m_eventNumber{0};
86
87 SIOFileTOCRecord m_tocRecord{};
88 podio::version::Version m_fileVersion{0};
89
90 constexpr static auto m_categoryName = "events";
91};
92
93} // namespace podio
94
95#endif // PODIO_SIOLEGACYREADER_H
std::unique_ptr< podio::SIOFrameData > readEntry(const std::string &, const unsigned entry)
unsigned getEntries(const std::string &name) const
Returns the number of.
std::unique_ptr< podio::SIOFrameData > readNextEntry(const std::string &)
SIOLegacyReader(const SIOLegacyReader &)=delete
SIOLegacyReader & operator=(const SIOLegacyReader &)=delete
podio::version::Version currentFileVersion() const
Get the build version of podio that has been used to write the current file.
void openFile(const std::string &filename)
std::vector< std::string_view > getAvailableCategories() const
Get the names of all the availalable Frame categories in the current file(s)