-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcarousel.cpp
36 lines (29 loc) · 1.01 KB
/
carousel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "ttxdata.hpp"
#include "ttxdata/encoder.hpp"
class ttxCarousel {
public:
ttxCarousel() {
datastore = ttxDatastore::get_instance();
auto l = ttxEncode::encode_page_entry(datastore->get_next_page_entry());
current_page_packet_vector = { std::begin(l), std::end(l) };
}
// Get the next packet, retreiving a new line from datastore if necessary
ttxPacket_p get_next_line() {
if (current_page_packet_idx == current_page_packet_vector.size()) {
current_page_packet_idx = 0;
auto l = ttxEncode::encode_page_entry(datastore->get_next_page_entry());
current_page_packet_vector = { std::begin(l), std::end(l) };
}
return current_page_packet_vector.at(current_page_packet_idx++);
}
ttxEncodedField_p get_next_field() {
auto field_p = std::make_shared<ttxEncodedField>();
for (int i = 0; i <= field_p->size() - 1; i++) {
(*field_p)[i] = *get_next_line();
}
return field_p;
}
ttxDatastore * datastore;
int current_page_packet_idx = 0;
std::vector<ttxPacket_p> current_page_packet_vector;
};