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 "events.h"
8#include "packets/tof_packet.h"
9#include "serialization.h"
10
11
12//template<typename T>
13//requires HasFromByteStream<T>
14//Vec<T> unpack<T>(String filename) {
15// usize pos = 0;
16// auto packets = get_tofpackets(filename);
17// for (const auto &p : packets) {
18// T data = T::from_bytestream(p.payload, 0);
19//
20//
21// Vec<T> data;
22// return data;
23//}
24
34Vec<RBEventHeader> get_rbeventheaders(const String &filename, bool is_header=false);
35
39//typedef
40
41
48Vec<u32> get_event_ids_from_raw_stream(const Vec<u8> &bytestream, u64 &start_pos);
49
58Vec<TofPacket> get_tofpackets(const Vec<u8> &bytestream, u64 start_pos, PacketType filter=PacketType::Unknown);
59
68Vec<TofPacket> get_tofpackets(const String filename, PacketType filter = PacketType::Unknown);
69
77Vec<TofEvent> unpack_tofevents_from_tofpackets(const Vec<u8> &bytestream, u64 start_pos);
78
85Vec<TofEvent> unpack_tofevents_from_tofpackets(const String filename);
86
88// * Extract TofEvents from a stream of binary data
89// *
90// * @param bytestream : Binary TofEvent data.
91// * @param start_pos : Byte position to start searching from in bytestream
92// */
93//Vec<TofPacket> get_tofpackets(const Vec<u8> &bytestream, u64 start_pos);
94//
96// * Extract TofEvents from a file on disk
97// *
98// * @param filename : Full path to binary file with TofEvents.
99// */
100//Vec<TofPacket> get_tofpackets(const String filename);
101
102namespace Gaps {
103
107 public:
109 TofPacketReader(String filename);
110 TofPacketReader(const TofPacketReader&) = delete;
111 //TofPacketReader& operator=(const TofPacketReader&) = delete;
114 void set_filename(String filename);
118 String get_filename() const;
122 bool is_exhausted() const;
125 usize n_packets_read() const;
126
127 private:
128 std::ifstream stream_file_;
129 bool exhausted_;
130 usize n_packets_read_;
131 String filename_;
132 };
133}
134
135
136#endif
Definition io.hpp:106
bool is_exhausted() const
usize n_packets_read() const
TofPacket get_next_packet()
Walk over the file and return the next packet.
String get_filename() const
Return the filename we assigned.
void set_filename(String filename)
‍**
Definition caraspace.hpp:8
Definition tof_packet.h:81