Class RxStream
Defined in File CBorStream.h
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.
-
template<typename T>
RxStream &deserialize_integer(T &n) Decode a generic integer.
- Parameters:
n – Field to decode
-
template<typename T>
inline RxStream &operator>>(std::vector<T> &v) Decode 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.
-
RxStream(uint8_t stream_type, std::string stream_name, uint8_t stream_identifier)