55#include "cbor/encoder.h"
56#include "cbor/ieee754.h"
57#include "cbor/decoder.h"
58#include "cbor/parser.h"
59#include "cbor/helper.h"
63#define PUBLISHER_TYPE 0
64#define SUBSCRIBER_TYPE 1
68#define MAX_BUFFER_CAPACITY 100
70template <
typename T,
int MaxLen,
typename Container=std::deque<T>>
73 void push(
const T& value)
75 if (this->size() == MaxLen)
79 std::queue<T, Container>::push(value);
96 TxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier);
202 *this << static_cast<const uint32_t>(v.size());
220 for (
size_t i = 0; i < size; ++i)
228 uint8_t _stream_type;
229 std::string _stream_name;
230 uint8_t _stream_identifier;
234 cbor_writer_t * _writer;
237 void handle_overrun(cbor_error_t result);
239 std::string toUTF8(
const std::u16string source);
253 RxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier);
381 for (
size_t i = 0; i < size; ++i)
398 uint8_t _stream_type;
399 std::string _stream_name;
400 uint8_t _stream_identifier;
402 size_t _buffered_iterator;
403 std::vector<std::pair<void *, int>> _buffered_packet;
406 static std::map<uint32_t, CircularQueue<std::vector<std::pair<void *, int>>, MAX_BUFFER_CAPACITY>> _interpreted_publications;
408 static std::map<uint32_t, CircularQueue<std::vector<std::pair<void *, int>>, MAX_BUFFER_CAPACITY>> _interpreted_requests;
410 static std::map<uint32_t, CircularQueue<std::vector<std::pair<void *, int>>, MAX_BUFFER_CAPACITY>> _interpreted_responses;
421 uint8_t str_copy[128];
424 static std::mutex _rx_mutex;
426 static std::pair<void *, int> interpret_field(cbor_item_t * items,
size_t i,
union _cbor_value & val);
427 std::u16string toUTF16(
const std::string source);
Class used to send and receive data from the DESERT socket.
Class used to store configurations.
Definition CBorStream.h:71
Definition CBorStream.h:244
RxStream & deserialize_integer(T &n)
Decode a generic integer.
Definition CBorStream.cpp:302
RxStream & operator>>(std::vector< T > &v)
Decode vector.
Definition CBorStream.h:358
static void interpret_packets()
Interpret raw packets and splits them into different communication types.
Definition CBorStream.cpp:386
void clear_buffer()
Clear the currently buffered packet.
Definition CBorStream.cpp:256
bool data_available(int64_t sequence_id=0)
Check if there are data.
Definition CBorStream.cpp:204
RxStream & deserialize_sequence(T *items, size_t size)
Deserialize a sequence of uniform elements.
Definition CBorStream.h:379
RxStream & operator>>(uint64_t &n)
Decode uint64.
Definition CBorStream.cpp:261
Definition CBorStream.h:87
TxStream & operator<<(const uint64_t n)
Encode uint64.
Definition CBorStream.cpp:63
TxStream & serialize_sequence(const T *items, size_t size)
Serialize a sequence of uniform elements.
Definition CBorStream.h:218
TxStream & operator<<(const std::vector< T > v)
Encode vector.
Definition CBorStream.h:200
void end_transmission()
Tell the stream to send down the packet.
Definition CBorStream.cpp:45
void start_transmission()
Tell the stream to create a new packet.
Definition CBorStream.cpp:35