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);
386 for (
size_t i = 0; i < size; ++i)
419 void push_packet(std::vector<std::pair<void *, int>> packet);
431 uint8_t _stream_type;
432 std::string _stream_name;
433 uint8_t _stream_identifier;
435 size_t _buffered_iterator;
438 std::vector<std::pair<void *, int>> _buffered_packet;
441 static const std::map<int, int> _stream_type_match_map;
442 static std::vector<RxStream *> _listening_streams;
453 uint8_t str_copy[128];
456 static std::mutex _rx_mutex;
458 static std::pair<void *, int> interpret_field(cbor_item_t * items,
size_t i,
union _cbor_value & val);
459 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()
Destroy the reception stream.
Definition CBorStream.cpp:199
RxStream & deserialize_integer(T &n)
Decode a generic integer.
Definition CBorStream.cpp:302
std::string get_name() const
Get the topic name of a specific instance.
Definition CBorStream.cpp:391
RxStream & operator>>(std::vector< T > &v)
Decode vector.
Definition CBorStream.h:363
static void interpret_packets()
Interpret raw packets and splits them into different communication types.
Definition CBorStream.cpp:406
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:216
uint8_t get_identifier() const
Get the stream identifier of a specific instance.
Definition CBorStream.cpp:396
uint8_t get_type() const
Get the stream type of a specific instance.
Definition CBorStream.cpp:386
void push_packet(std::vector< std::pair< void *, int > > packet)
Add a packet to _received_packets.
Definition CBorStream.cpp:401
RxStream & deserialize_sequence(T *items, size_t size)
Deserialize a sequence of uniform elements.
Definition CBorStream.h:384
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