A class responsible for registering and creating packet deserializers.
More...
#include "packet-factory.hpp"
A class responsible for registering and creating packet deserializers.
Definition at line 12 of file packet-factory.hpp.
◆ PacketFactory()
mal_packet_weaver::PacketFactory::PacketFactory |
( |
| ) |
|
|
privatedefault |
◆ Deserialize()
Deserialize a byte view into a unique pointer of the specified packet type.
This function uses the registered packet deserializer functions to deserialize the binary data from a ByteView and reconstruct a unique pointer to a packet instance.
- Parameters
-
bytearray | The ByteView containing the binary serialized data. |
packet_type | The unique packet ID specifying the packet type. |
- Returns
- A unique pointer to the deserialized packet instance.
Definition at line 101 of file packet-factory.hpp.
◆ instance()
static PacketFactory & mal_packet_weaver::PacketFactory::instance |
( |
| ) |
|
|
inlinestatic |
◆ RegisterDeserializer() [1/2]
template<IsPacket PacketType>
static void mal_packet_weaver::PacketFactory::RegisterDeserializer |
( |
| ) |
|
|
inlinestatic |
Register a packet deserializer function for a specific PacketType.
This template function allows registration of deserializer functions for packet types that satisfy the IsPacket concept. The function associates the packet's static_unique_id with its deserialize member function.
- Template Parameters
-
PacketType | The packet type that satisfies the IsPacket concept. |
Definition at line 25 of file packet-factory.hpp.
◆ RegisterDeserializer() [2/2]
Register a packet deserializer function for a specific packet ID.
This function allows registration of a custom packet deserializer function for a unique packet ID. It associates the given packet_id with the provided factory function.
- Parameters
-
packet_id | The unique packet ID. |
factory | The packet deserialization factory function. |
Definition at line 75 of file packet-factory.hpp.
◆ instance_
std::unique_ptr< PacketFactory > mal_packet_weaver::PacketFactory::instance_ |
|
staticprivate |
◆ packet_deserializers_
The documentation for this class was generated from the following files: