KENSv3
KAIST Educational Network System
Public Member Functions | Friends | List of all members
E::Packet Class Reference

This class abstracts a packet. You cannot directly allocate/deallocate Packet. Also you cannot directly access the internal buffer. Use access functions. More...

#include <E_Packet.hpp>

Inheritance diagram for E::Packet:
E::Module::MessageBase

Public Member Functions

 Packet (const Packet &other)
 
 Packet (Packet &&other) noexcept
 
Packetoperator= (const Packet &other)
 
Packetoperator= (Packet &&other) noexcept
 
 Packet (size_t size)
 
Packet clone () const
 
size_t writeData (size_t offset, const void *data, size_t length)
 
size_t readData (size_t offset, void *data, size_t length) const
 
size_t setSize (size_t size)
 Change the size of this Packet The size can be larger than the internal buffer. More...
 
size_t getSize () const
 
UUID getUUID () const
 
void clearContext ()
 

Friends

class NetworkSystem
 

Detailed Description

This class abstracts a packet. You cannot directly allocate/deallocate Packet. Also you cannot directly access the internal buffer. Use access functions.

Constructor & Destructor Documentation

◆ Packet() [1/3]

E::Packet::Packet ( const Packet other)

Copy constructor. (Copied packet has same UUID)

Parameters
otherPacket to copy.

◆ Packet() [2/3]

E::Packet::Packet ( Packet &&  other)
noexcept

Move constructor. (Moved packet become emtpy)

Parameters
otherPacket to move.

◆ Packet() [3/3]

E::Packet::Packet ( size_t  size)
Parameters
sizePacket size.

Member Function Documentation

◆ clone()

Packet E::Packet::clone ( ) const

Clone packet (Cloned packet has a different UUID)

Returns
Cloned packet.

◆ getSize()

size_t E::Packet::getSize ( ) const
Returns
Current packet size.

◆ getUUID()

UUID E::Packet::getUUID ( ) const
Returns
Packet UUID.

◆ operator=() [1/2]

Packet & E::Packet::operator= ( const Packet other)

Copy assignment operator. (Copied packet has same UUID)

Parameters
otherPacket to copy.

◆ operator=() [2/2]

Packet & E::Packet::operator= ( Packet &&  other)
noexcept

Move assignment operator. (Moved packet become emtpy)

Parameters
otherPacket to move.

◆ readData()

size_t E::Packet::readData ( size_t  offset,
void *  data,
size_t  length 
) const
Parameters
offsetStart read skipping first n bytes of the internal buffer.
dataDestination of the packet content.
lengthLength of data to be retrieved.
Returns
Actual retrieved bytes.

◆ setSize()

size_t E::Packet::setSize ( size_t  size)

Change the size of this Packet The size can be larger than the internal buffer.

Parameters
sizeNew size.
Returns
Actual changed size.

◆ writeData()

size_t E::Packet::writeData ( size_t  offset,
const void *  data,
size_t  length 
)
Parameters
offsetStart write skipping first n bytes of the given buffer.
dataData to be written in this packet.
lengthLength of data to be written.
Returns
Actual written bytes. If length + offset is larger than the internal buffer size, some data may be truncated.

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