StormByte-Network 2.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.
 
using CloneFunction = void *(*)(const void *)
 Caller-allocator clone trampoline.
 
using DestroyFunction = void(*)(void *) noexcept
 Caller-allocator destroy trampoline.
 

Public Member Functions

 DeserializePacketFunction () noexcept=default
 Empty callback.
 
template<typename Callable >
requires (!StormByte::Type::SameAs<std::decay_t<Callable>, DeserializePacketFunction> && StormByte::Type::CopyConstructible<std::decay_t<Callable>>)
 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
 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.

◆ DestroyFunction

Caller-allocator destroy trampoline.

◆ InvokeFunction

◆ OpcodeType

Constructor & Destructor Documentation

◆ DeserializePacketFunction() [1/4]

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

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::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

Whether a callable target is present.

◆ 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: