gaps-online-software 0.10
online software for the TOF system for the GAPS experiment
Loading...
Searching...
No Matches
io.hpp
1#ifndef TOFIO_H_INCLUDED
2#define TOFIO_H_INCLUDED
3
4#include <fstream>
5#include <functional>
6
7#include "result/result.h"
8
9#include "events.h"
10#include "packets/tof_packet.h"
11#include "serialization.h"
12#include "errors.hpp"
13
14namespace r = result;
15
16//template<typename T>
17//requires HasFromByteStream<T>
18//Vec<T> unpack<T>(String filename) {
19// usize pos = 0;
20// auto packets = get_tofpackets(filename);
21// for (const auto &p : packets) {
22// T data = T::from_bytestream(p.payload, 0);
23//
24//
25// Vec<T> data;
26// return data;
27//}
28
41[[deprecated("This might not even be correct!")]]
42Vec<u32> get_event_ids_from_raw_stream(const Vec<u8> &bytestream, u64 &start_pos);
43
52Vec<TofPacket> get_tofpackets(const Vec<u8> &bytestream, u64 start_pos, PacketType filter=PacketType::Unknown);
53
62Vec<TofPacket> get_tofpackets(const String filename, PacketType filter = PacketType::Unknown);
63
71Vec<TofEvent> unpack_tofevents_from_tofpackets(const Vec<u8> &bytestream, u64 start_pos);
72
79Vec<TofEvent> unpack_tofevents_from_tofpackets(const String filename);
80
81namespace Gaps {
82
86 public:
88 TofPacketReader(String filename);
89 TofPacketReader(const TofPacketReader&) = delete;
90 //TofPacketReader& operator=(const TofPacketReader&) = delete;
93 void set_filename(String filename);
95 auto get_next_packet() -> r::Result<TofPacket, Gaps::IOError>;
97 auto get_filename() const -> std::string;
101 auto is_exhausted() const -> bool;
104 auto n_packets_read() const -> usize;
105
106 private:
107 std::ifstream stream_file_;
108 bool exhausted_;
109 usize n_packets_read_;
110 String filename_;
111 };
112}
113
114
115#endif
Definition io.hpp:85
auto get_next_packet() -> r::Result< TofPacket, Gaps::IOError >
Walk over the file and return the next packet.
auto n_packets_read() const -> usize
auto is_exhausted() const -> bool
auto get_filename() const -> std::string
Return the filename we assigned.
void set_filename(String filename)
Definition calibration.h:105