commonlib
PacketFilter< T, BufferSize, HeaderLength > Class Template Referenceabstract

Public Member Functions

virtual void clear ()
 Clears the internal buffer.
 
const std::vector< T > & filter (const uint8_t *data, std::size_t size)
 Adds data to the internal buffer and filters out packets. More...
 

Protected Member Functions

virtual bool isHeader (const uint8_t *data, std::size_t size)=0
 Pure virtual function that checks if the data is a header. More...
 
virtual std::size_t findEnd (const uint8_t *start, std::size_t size)=0
 Function that checks if the packet is complete from the start of the header to the end of available data. More...
 
virtual T convertToPacket (const uint8_t *start, std::size_t size)=0
 Function that converts complete packet bytes to a packet. More...
 

Member Function Documentation

◆ convertToPacket()

template<typename T , std::size_t BufferSize, std::size_t HeaderLength>
virtual T PacketFilter< T, BufferSize, HeaderLength >::convertToPacket ( const uint8_t *  start,
std::size_t  size 
)
protectedpure virtual

Function that converts complete packet bytes to a packet.

Returns
Return a packet constructed from bytes

◆ filter()

template<typename T , std::size_t BufferSize, std::size_t HeaderLength>
const std::vector< T > & PacketFilter< T, BufferSize, HeaderLength >::filter ( const uint8_t *  data,
std::size_t  size 
)

Adds data to the internal buffer and filters out packets.

Returns
List of detected packets.

◆ findEnd()

template<typename T , std::size_t BufferSize, std::size_t HeaderLength>
virtual std::size_t PacketFilter< T, BufferSize, HeaderLength >::findEnd ( const uint8_t *  start,
std::size_t  size 
)
protectedpure virtual

Function that checks if the packet is complete from the start of the header to the end of available data.

Returns
Should return the position of the end of the packet if the packet is complete, std::string::npos otherwise.

◆ isHeader()

template<typename T , std::size_t BufferSize, std::size_t HeaderLength>
virtual bool PacketFilter< T, BufferSize, HeaderLength >::isHeader ( const uint8_t *  data,
std::size_t  size 
)
protectedpure virtual

Pure virtual function that checks if the data is a header.

Returns
Should returntrue if the data is a header, false otherwise.

The documentation for this class was generated from the following file: