Class RxStream

Nested Relationships

Nested Types

Class Documentation

class RxStream

Public Functions

RxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier)

Create a reception stream.

Parameters:
  • stream_type – Type of the object using the current instance

  • stream_name – Name of the topic or the service to which the communication belongs

  • stream_identifier – Identifier of the topic or the service read from configuration

~RxStream()

Destroy the reception stream.

bool data_available(int64_t sequence_id = 0)

Check if there are data.

A map contains the information received for all topics and services, so using the name saved in the current instance as key it is possible to know if a message is arrived for a specific entity.

Parameters:

sequence_id – The id of the client service communication

void clear_buffer()

Clear the currently buffered packet.

When the packet is read by the entity, this function must be called to clear the buffer and allow RxStream to add the next one in the queue.

RxStream &operator>>(uint64_t &n)

Decode uint64.

Parameters:

n – Field to decode

RxStream &operator>>(uint32_t &n)

Decode uint32.

Parameters:

n – Field to decode

RxStream &operator>>(uint16_t &n)

Decode uint16.

Parameters:

n – Field to decode

RxStream &operator>>(uint8_t &n)

Decode uint8.

Parameters:

n – Field to decode

RxStream &operator>>(int64_t &n)

Decode int64.

Parameters:

n – Field to decode

RxStream &operator>>(int32_t &n)

Decode int32.

Parameters:

n – Field to decode

RxStream &operator>>(int16_t &n)

Decode int16.

Parameters:

n – Field to decode

RxStream &operator>>(int8_t &n)

Decode int8.

Parameters:

n – Field to decode

template<typename T>
RxStream &deserialize_integer(T &n)

Decode a generic integer.

Parameters:

n – Field to decode

RxStream &operator>>(char &n)

Decode char.

Parameters:

n – Field to decode

RxStream &operator>>(float &f)

Decode float.

Parameters:

f – Field to decode

RxStream &operator>>(double &d)

Decode double.

Parameters:

d – Field to decode

RxStream &operator>>(std::string &s)

Decode string.

Parameters:

s – Field to decode

RxStream &operator>>(std::u16string &s)

Decode u16string.

Parameters:

s – Field to decode

RxStream &operator>>(bool &b)

Decode bool.

Parameters:

b – Field to decode

template<typename T>
inline RxStream &operator>>(std::vector<T> &v)

Decode vector.

Parameters:

v – Field to decode

RxStream &operator>>(std::vector<bool> &v)

Decode bool vector.

Parameters:

v – Field to decode

template<typename T>
inline RxStream &deserialize_sequence(T *items, size_t size)

Deserialize a sequence of uniform elements.

Parameters:
  • items – Pointer to the first element

  • size – Size of the items array

uint8_t get_type() const

Get the stream type of a specific instance.

Returns:

Type of the stream

std::string get_name() const

Get the topic name of a specific instance.

Returns:

Topic name of the stream

uint8_t get_identifier() const

Get the stream identifier of a specific instance.

Returns:

Topic identifier of the stream

void push_packet(std::vector<std::pair<void*, int>> packet)

Add a packet to _received_packets.

When interpret_packets() is called is read all the currently active RxStream instances, and uses this function to enqueue a packet if the stream matches the type and the topic.

Parameters:

packet – The packet to add

Public Static Functions

static void interpret_packets()

Interpret raw packets and splits them into different communication types.

Raw packets from TcpDaemon are read and interpreted in order to put them in a map where the key allows to distinguish the topic name or the service name, and eventually the sequence identifier.