PARTONS/ElementaryUtils  
Basic utility softwares (Logger, threads, etc)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ElemUtils::Packet Class Reference

FIFO generic container. More...

Public Member Functions

 Packet ()
 Default constructor. More...
 
virtual ~Packet ()
 Default destructor. More...
 
void append (const void *data, std::size_t sizeInBytes)
 Append data to the end of the packet. More...
 
Packetoperator>> (bool &data)
 Overloads of operator >> to read data from the packet. More...
 
Packetoperator>> (double &data)
 
Packetoperator>> (unsigned int &data)
 
Packetoperator>> (int &data)
 
Packetoperator>> (unsigned short &data)
 
Packetoperator>> (short &data)
 
Packetoperator>> (const std::string &data)
 
Packetoperator<< (bool data)
 Overloads of operator << to write data into the packet. More...
 
Packetoperator<< (double data)
 
Packetoperator<< (unsigned int data)
 
Packetoperator<< (int data)
 
Packetoperator<< (unsigned short data)
 
Packetoperator<< (short data)
 
Packetoperator<< (const std::string &data)
 

Private Member Functions

bool checkSize (std::size_t size)
 Check if the packet can extract a given number of bytes. More...
 
bool operator== (const Packet &right) const
 Disallow comparisons between GenericTypes. More...
 
bool operator!= (const Packet &right) const
 

Private Attributes

std::vector< char > m_data
 Data stored in the packet. More...
 
std::size_t m_readPos
 Current reading position in the packet. More...
 
bool m_isValid
 Reading state of the packet. More...
 

Detailed Description

FIFO generic container.

Constructor & Destructor Documentation

◆ Packet()

ElemUtils::Packet::Packet ( )

Default constructor.

◆ ~Packet()

ElemUtils::Packet::~Packet ( )
virtual

Default destructor.

Member Function Documentation

◆ append()

void ElemUtils::Packet::append ( const void *  data,
std::size_t  sizeInBytes 
)

Append data to the end of the packet.

Parameters
dataPointer to the sequence of bytes to append
sizeInBytesNumber of bytes to append
See also
clear

◆ checkSize()

bool ElemUtils::Packet::checkSize ( std::size_t  size)
private

Check if the packet can extract a given number of bytes.

This function updates accordingly the state of the packet.

Parameters
sizeSize to check
Returns
True if size bytes can be read from the packet

◆ operator!=()

bool ElemUtils::Packet::operator!= ( const Packet right) const
private

◆ operator<<() [1/7]

Packet & ElemUtils::Packet::operator<< ( bool  data)

Overloads of operator << to write data into the packet.

◆ operator<<() [2/7]

Packet & ElemUtils::Packet::operator<< ( const std::string &  data)

◆ operator<<() [3/7]

Packet & ElemUtils::Packet::operator<< ( double  data)

◆ operator<<() [4/7]

Packet & ElemUtils::Packet::operator<< ( int  data)

◆ operator<<() [5/7]

Packet & ElemUtils::Packet::operator<< ( short  data)

◆ operator<<() [6/7]

Packet & ElemUtils::Packet::operator<< ( unsigned int  data)

◆ operator<<() [7/7]

Packet & ElemUtils::Packet::operator<< ( unsigned short  data)

◆ operator==()

bool ElemUtils::Packet::operator== ( const Packet right) const
private

Disallow comparisons between GenericTypes.

◆ operator>>() [1/7]

Packet & ElemUtils::Packet::operator>> ( bool &  data)

Overloads of operator >> to read data from the packet.

◆ operator>>() [2/7]

Packet & ElemUtils::Packet::operator>> ( const std::string &  data)

◆ operator>>() [3/7]

Packet & ElemUtils::Packet::operator>> ( double &  data)

◆ operator>>() [4/7]

Packet & ElemUtils::Packet::operator>> ( int &  data)

◆ operator>>() [5/7]

Packet & ElemUtils::Packet::operator>> ( short &  data)

◆ operator>>() [6/7]

Packet & ElemUtils::Packet::operator>> ( unsigned int &  data)

◆ operator>>() [7/7]

Packet & ElemUtils::Packet::operator>> ( unsigned short &  data)

Member Data Documentation

◆ m_data

std::vector<char> ElemUtils::Packet::m_data
private

Data stored in the packet.

◆ m_isValid

bool ElemUtils::Packet::m_isValid
private

Reading state of the packet.

◆ m_readPos

std::size_t ElemUtils::Packet::m_readPos
private

Current reading position in the packet.


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