PODIO v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
SIOFrameReader.h
Go to the documentation of this file.
1#ifndef PODIO_SIOFRAMEREADER_H
2#define PODIO_SIOFRAMEREADER_H
3
4#include "podio/SIOBlock.h"
6#include "podio/podioVersion.h"
8
9#include <sio/definitions.h>
10
11#include <memory>
12#include <string>
13#include <string_view>
14#include <unordered_map>
15
16namespace podio {
17
18class CollectionIDTable;
19
21
22public:
24 ~SIOFrameReader() = default;
25
26 // non copyable
29
30 /**
31 * Read the next data entry from which a Frame can be constructed for the
32 * given name. In case there are no more entries left for this name or in
33 * case there is no data for this name, this returns a nullptr.
34 */
35 std::unique_ptr<podio::SIOFrameData> readNextEntry(const std::string& name);
36
37 /**
38 * Read the specified data entry from which a Frame can be constructed for
39 * the given name. In case the entry does not exist for this name or in
40 * case there is no data for this name, this returns a nullptr.
41 */
42 std::unique_ptr<podio::SIOFrameData> readEntry(const std::string& name, const unsigned entry);
43
44 /// Returns number of entries for the given name
45 unsigned getEntries(const std::string& name) const;
46
47 void openFile(const std::string& filename);
48
49 /// Get the build version of podio that has been used to write the current file
51 return m_fileVersion;
52 }
53
54 /// Get the names of all the availalable Frame categories in the current file(s)
55 std::vector<std::string_view> getAvailableCategories() const;
56
57 /// Get the datamodel definition for the given name
58 const std::string_view getDatamodelDefinition(const std::string& name) const {
59 return m_datamodelHolder.getDatamodelDefinition(name);
60 }
61
62 /// Get all names of the datamodels that ara available from this reader
63 std::vector<std::string> getAvailableDatamodels() const {
64 return m_datamodelHolder.getAvailableDatamodels();
65 }
66
67private:
68 void readPodioHeader();
69
70 /// read the TOC record
71 bool readFileTOCRecord();
72
73 void readEDMDefinitions();
74
75 sio::ifstream m_stream{}; ///< The stream from which we read
76
77 /// Count how many times each an entry of this name has been read already
78 std::unordered_map<std::string, unsigned> m_nameCtr{};
79
80 /// Table of content record where starting points of named entries can be read from
81 SIOFileTOCRecord m_tocRecord{};
82 /// The podio version that has been used to write the file
83 podio::version::Version m_fileVersion{0};
84
85 DatamodelDefinitionHolder m_datamodelHolder{};
86};
87
88} // namespace podio
89
90#endif // PODIO_SIOFRAMEREADER_H
std::vector< std::string > getAvailableDatamodels() const
const std::string_view getDatamodelDefinition(const std::string &name) const
podio::version::Version currentFileVersion() const
Get the build version of podio that has been used to write the current file.
unsigned getEntries(const std::string &name) const
Returns number of entries for the given name.
std::vector< std::string > getAvailableDatamodels() const
Get all names of the datamodels that ara available from this reader.
std::vector< std::string_view > getAvailableCategories() const
Get the names of all the availalable Frame categories in the current file(s)
void openFile(const std::string &filename)
SIOFrameReader & operator=(const SIOFrameReader &)=delete
const std::string_view getDatamodelDefinition(const std::string &name) const
Get the datamodel definition for the given name.
std::unique_ptr< podio::SIOFrameData > readEntry(const std::string &name, const unsigned entry)
std::unique_ptr< podio::SIOFrameData > readNextEntry(const std::string &name)
SIOFrameReader(const SIOFrameReader &)=delete