Woman, Life, Freedom


OBD-II Emulator
Linux ODB-II Emulator public and protected interfaces documentation
ObdEmulator::PacketBuffer Class Reference

Thread-safe queue for buffering packet data bytes. More...

#include <packet_buffer.h>

Public Member Functions

bool Empty () const noexcept
 Indicate whether the buffer is empty or not. More...
 
bool TryEnqueue (std::vector< uint8_t > &&packet)
 Try to insert a packet to the buffer via moving. More...
 
bool TryDequeue (std::vector< uint8_t > &packet)
 Try to peek a packet from the buffer by removing it. More...
 
bool TryClear ()
 Try to make the buffer empty. More...
 

Detailed Description

Thread-safe queue for buffering packet data bytes.

Member Function Documentation

◆ Empty()

bool ObdEmulator::PacketBuffer::Empty ( ) const
inlinenoexcept

Indicate whether the buffer is empty or not.

Returns
True if the buffer is empty, otherwise false

◆ TryClear()

bool ObdEmulator::PacketBuffer::TryClear ( )

Try to make the buffer empty.

Returns
True if the buffer is cleared successfully; otherwise false

◆ TryDequeue()

bool ObdEmulator::PacketBuffer::TryDequeue ( std::vector< uint8_t > &  packet)

Try to peek a packet from the buffer by removing it.

Parameters
[out]packetPacket that is moved out from the buffer
Returns
True if the packet is dequeued successfully, otherwise false

◆ TryEnqueue()

bool ObdEmulator::PacketBuffer::TryEnqueue ( std::vector< uint8_t > &&  packet)

Try to insert a packet to the buffer via moving.

Parameters
[in]packetPacket bytes to be moved into the buffer
Returns
True if the packet is moved to the buffer successfully, otherwise false