StormByte C++ Library: Network module 1.1.0
StormByte-Network is the C++26 networking module of the StormByte suite.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
StormByte::Network::Transport::Packet Class Referenceabstract

Polymorphic wire packet: opcode + payload hook. More...

#include <StormByte/network/transport/packet.hxx>

Public Types

using OpcodeType = unsigned short
 Opcode storage type.
 

Public Member Functions

 Packet (const Packet &other)=default
 Copy constructor.
 
 Packet (Packet &&other) noexcept=default
 Move constructor.
 
virtual ~Packet () noexcept=default
 Destructor.
 
Packetoperator= (const Packet &other)=default
 Copy assignment.
 
Packetoperator= (Packet &&other) noexcept=default
 Move assignment.
 
const OpcodeTypeOpcode () const noexcept
 Stored opcode.
 
Buffer::FIFO Serialize () const noexcept
 Serialize opcode followed by DoSerialize() payload.
 

Static Public Attributes

static constexpr unsigned short PROCESS_THRESHOLD = 10
 Opcodes at or above this value run payload through Buffer pipelines when framing.
 

Protected Member Functions

constexpr Packet (const OpcodeType &opcode) noexcept
 Construct with an opcode.
 
virtual Buffer::DataType DoSerialize () const noexcept=0
 Payload-only serialization (no opcode).
 

Protected Attributes

OpcodeType m_opcode
 Packet opcode.
 

Detailed Description

Polymorphic wire packet: opcode + payload hook.

Derive and override DoSerialize() for the payload (excluding opcode). Serialize() writes opcode then payload.

Opcodes must fit OpcodeType (unsigned short).

Member Typedef Documentation

◆ OpcodeType

Opcode storage type.

Constructor & Destructor Documentation

◆ Packet() [1/3]

StormByte::Network::Transport::Packet::Packet ( const Packet other)
default

Copy constructor.

◆ Packet() [2/3]

StormByte::Network::Transport::Packet::Packet ( Packet &&  other)
defaultnoexcept

Move constructor.

◆ ~Packet()

virtual StormByte::Network::Transport::Packet::~Packet ( )
virtualdefaultnoexcept

Destructor.

◆ Packet() [3/3]

constexpr StormByte::Network::Transport::Packet::Packet ( const OpcodeType opcode)
inlineconstexprprotectednoexcept

Construct with an opcode.

Parameters
opcodePacket opcode.

Member Function Documentation

◆ DoSerialize()

virtual Buffer::DataType StormByte::Network::Transport::Packet::DoSerialize ( ) const
protectedpure virtualnoexcept

Payload-only serialization (no opcode).

Returns
Payload bytes (may be empty).

◆ Opcode()

const OpcodeType & StormByte::Network::Transport::Packet::Opcode ( ) const
inlinenoexcept

Stored opcode.

Returns
Opcode.

◆ operator=() [1/2]

Packet & StormByte::Network::Transport::Packet::operator= ( const Packet other)
default

Copy assignment.

◆ operator=() [2/2]

Packet & StormByte::Network::Transport::Packet::operator= ( Packet &&  other)
defaultnoexcept

Move assignment.

◆ Serialize()

Buffer::FIFO StormByte::Network::Transport::Packet::Serialize ( ) const
noexcept

Serialize opcode followed by DoSerialize() payload.

Returns
Complete on-wire buffer.

Member Data Documentation

◆ m_opcode

OpcodeType StormByte::Network::Transport::Packet::m_opcode
protected

Packet opcode.

◆ PROCESS_THRESHOLD

constexpr unsigned short StormByte::Network::Transport::Packet::PROCESS_THRESHOLD = 10
staticconstexpr

Opcodes at or above this value run payload through Buffer pipelines when framing.


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