11#include <unordered_map>
22 std::unique_ptr<hipo::reader>
reader;
24 mutable std::unordered_map<std::string, bank> bank_templates;
28 reader = std::make_unique<hipo::reader>();
34 bank_templates.reserve(schema_list.size());
35 for (
const std::string& name : schema_list) {
37 bank_templates.emplace(name,
bank(sch));
65 if (!event_ptr || !file_ptr)
throw std::runtime_error(
"Invalid HipoEvent (no event data)");
66 auto it = file_ptr->bank_templates.find(std::string(bankName));
67 if (it == file_ptr->bank_templates.end())
throw std::runtime_error(
"Schema not found for bank: " + std::string(bankName));
68 event_ptr->
read(it->second);
90 if (!reader_ptr || !reader_ptr->
next(current_event)) {
95 current_wrap =
iter_event(¤t_event, file_ptr);
100 iterator() : reader_ptr(nullptr), file_ptr(nullptr), at_end(true) {}
103 if (!reader_ptr || at_end)
return *
this;
104 if (!reader_ptr->
next(current_event)) {
105 reader_ptr =
nullptr;
109 current_wrap.event_ptr = ¤t_event;
110 current_wrap.file_ptr = file_ptr;
126 return {
reader.get(),
this};
Collection of schema definitions, typically read from a HIPO file header.
Definition dictionary.h:157
schema & getSchema(const char *name)
Definition dictionary.h:167
std::vector< std::string > getSchemaList()
Definition dictionary.cpp:117
void read(hipo::bank &b)
Definition event.cpp:63
Definition hipoeventiterator.h:73
reference operator*()
Definition hipoeventiterator.h:115
std::input_iterator_tag iterator_category
Definition hipoeventiterator.h:77
bool operator!=(const iterator &other) const
Definition hipoeventiterator.h:119
bool operator==(const iterator &other) const
Definition hipoeventiterator.h:121
iterator & operator++()
Definition hipoeventiterator.h:102
pointer operator->()
Definition hipoeventiterator.h:117
iterator()
Definition hipoeventiterator.h:100
Definition hipoeventiterator.h:14
friend class iter_event
Definition hipoeventiterator.h:15
hipoeventfile(const std::string &filename)
Definition hipoeventiterator.h:27
iterator end()
Definition hipoeventiterator.h:129
hipoeventfile & operator=(hipoeventfile &&other) noexcept=default
hipoeventfile(hipoeventfile &&other) noexcept=default
iterator begin()
Definition hipoeventiterator.h:124
hipoeventfile(const hipoeventfile &)=delete
hipoeventfile & operator=(const hipoeventfile &)=delete
Definition hipoeventiterator.h:50
iter_event(iter_event &&) noexcept=default
bank & get_bank(std::string_view bankName) const
Definition hipoeventiterator.h:64
iter_event()
Definition hipoeventiterator.h:60
void readDictionary(hipo::dictionary &dict)
Reads the dictionary for the file.
Definition reader.cpp:318
void rewind()
Definition reader.h:238
bool next()
Advances the event pointer to the next event.
Definition reader.cpp:341
void open(const char *filename)
Open file, if file stream is open, it is closed first.
Definition reader.cpp:78
Schema definition for a HIPO bank.
Definition dictionary.h:56
HIPO namespace is used for the classes that read/write files and records.
Definition bank.cpp:45