StormByte-Network 4.0.0
C++26 networking module of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Network::DeserializePacketFunction Class Reference

Caller-owned callback that builds a packet from opcode and payload. More...

#include <StormByte/network/typedefs.hxx>

Public Types

using OpcodeType = Transport::Packet::OpcodeType
 Wire opcode type.
using InvokeFunction = PacketPointer (*)(void*, OpcodeType, Buffer::Consumer, StormByte::Safe::Shared<Logger::Log>)
 Invocation trampoline taking context, opcode, payload, and logger.
using CloneFunction = void* (*)(const void*)
 Caller-allocator clone trampoline taking source context storage.
using DestroyFunction = void (*)(void*) noexcept
 Caller-allocator destroy trampoline taking context storage.

Public Member Functions

 DeserializePacketFunction () noexcept=default
 Construct an empty callback.
template<typename Callable>
requires (!StormByte::Type::SameAs<std::decay_t<Callable>, DeserializePacketFunction> && StormByte::Type::CopyConstructible<std::decay_t<Callable>>)
STORMBYTE_FORCE_INLINE DeserializePacketFunction (Callable &&callable)
 Own a caller-allocated callback target.
 DeserializePacketFunction (const DeserializePacketFunction &other)
 Clone using the caller's target allocator trampoline.
 DeserializePacketFunction (DeserializePacketFunction &&other) noexcept
 Transfer callback ownership without touching its target.
 ~DeserializePacketFunction () noexcept
 Destroy through the caller's destruction trampoline.
DeserializePacketFunction & operator= (const DeserializePacketFunction &other)
 Clone-assign using the caller's target allocator trampoline.
DeserializePacketFunction & operator= (DeserializePacketFunction &&other) noexcept
 Transfer-assign callback ownership.
PacketPointer operator() (OpcodeType opcode, Buffer::Consumer payload, StormByte::Safe::Shared< Logger::Log > logger) const
 Invoke the packet decoder.
 operator bool () const noexcept
 Test whether a callable target is present.

Detailed Description

Caller-owned callback that builds a packet from opcode and payload.

The context is allocated, cloned, invoked, and destroyed by function pointers instantiated in the caller's translation unit. The Network DLL stores only the context pointer and those trampolines; it never allocates or frees the callback target across the CRT boundary.

Member Typedef Documentation

◆ CloneFunction

Caller-allocator clone trampoline taking source context storage.

Returns
Cloned context storage allocated in the caller's module.

◆ DestroyFunction

Caller-allocator destroy trampoline taking context storage.

◆ InvokeFunction

Invocation trampoline taking context, opcode, payload, and logger.

Returns
Decoded packet, or an empty pointer.

◆ OpcodeType

Constructor & Destructor Documentation

◆ DeserializePacketFunction() [1/4]

StormByte::Network::DeserializePacketFunction::DeserializePacketFunction ( )
defaultnoexcept

Construct an empty callback.

◆ DeserializePacketFunction() [2/4]

template<typename Callable>
requires (!StormByte::Type::SameAs<std::decay_t<Callable>, DeserializePacketFunction> && StormByte::Type::CopyConstructible<std::decay_t<Callable>>)
STORMBYTE_FORCE_INLINE StormByte::Network::DeserializePacketFunction::DeserializePacketFunction ( Callable && callable)
inline

Own a caller-allocated callback target.

Template Parameters
CallableCopy-constructible callback type.
Parameters
callableCallback taking opcode, payload Consumer, and Shared logger.

◆ DeserializePacketFunction() [3/4]

StormByte::Network::DeserializePacketFunction::DeserializePacketFunction ( const DeserializePacketFunction & other)

Clone using the caller's target allocator trampoline.

Parameters
otherSource callback.

◆ DeserializePacketFunction() [4/4]

StormByte::Network::DeserializePacketFunction::DeserializePacketFunction ( DeserializePacketFunction && other)
noexcept

Transfer callback ownership without touching its target.

Parameters
otherSource callback.

◆ ~DeserializePacketFunction()

StormByte::Network::DeserializePacketFunction::~DeserializePacketFunction ( )
noexcept

Destroy through the caller's destruction trampoline.

Member Function Documentation

◆ operator bool()

StormByte::Network::DeserializePacketFunction::operator bool ( ) const
inlineexplicitnoexcept

Test whether a callable target is present.

Returns
True if a callable target is present, false otherwise.

◆ operator()()

PacketPointer StormByte::Network::DeserializePacketFunction::operator() ( OpcodeType opcode,
Buffer::Consumer payload,
StormByte::Safe::Shared< Logger::Log > logger ) const

Invoke the packet decoder.

Parameters
opcodePacket opcode.
payloadPayload consumer.
loggerShared diagnostic logger.
Returns
Decoded packet, or empty pointer.

◆ operator=() [1/2]

DeserializePacketFunction & StormByte::Network::DeserializePacketFunction::operator= ( const DeserializePacketFunction & other)

Clone-assign using the caller's target allocator trampoline.

Parameters
otherSource callback.
Returns
This callback.

◆ operator=() [2/2]

DeserializePacketFunction & StormByte::Network::DeserializePacketFunction::operator= ( DeserializePacketFunction && other)
noexcept

Transfer-assign callback ownership.

Parameters
otherSource callback.
Returns
This callback.

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