mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
mal_packet_weaver::Packet Class Referenceabstract

Base class for all packets. More...

#include "packet.hpp"

Inheritance diagram for mal_packet_weaver::Packet:
[legend]
Collaboration diagram for mal_packet_weaver::Packet:
[legend]

Public Member Functions

 Packet (const UniquePacketID type, const float time_to_live)
 Constructor for Packet class.
 
 Packet (Packet &&)=default
 
Packetoperator= (Packet &&)=default
 
virtual ~Packet ()=default
 Virtual destructor for Packet class.
 
virtual const char * packet_name () const =0
 
virtual void serialize_to_bytearray (ByteArray &buffer) const =0
 Serialize the packet into a ByteArray.
 
float timestamp () const noexcept
 Get the timestamp when the packet was received.
 
float get_packet_time_alive () const noexcept
 Get the time elapsed since the packet was received.
 
bool expired () const noexcept
 Check if the packet has expired based on its time-to-live.
 

Public Attributes

const UniquePacketID type
 Unique packet ID.
 
const float time_to_live
 Time-to-live for the packet.
 
const float timestamp_
 Timestamp when the packet was received.
 

Private Member Functions

template<class Archive >
void serialize (Archive &, const unsigned int)
 

Static Private Attributes

static Measurer< std::chrono::steady_clock > measurer
 Measurer for packet timestamps.
 

Friends

class cereal::access
 

Detailed Description

Base class for all packets.

Definition at line 46 of file packet.hpp.

Constructor & Destructor Documentation

◆ Packet() [1/2]

mal_packet_weaver::Packet::Packet ( const UniquePacketID type,
const float time_to_live )
inlineexplicit

Constructor for Packet class.

Definition at line 52 of file packet.hpp.

◆ Packet() [2/2]

mal_packet_weaver::Packet::Packet ( Packet && )
default

◆ ~Packet()

virtual mal_packet_weaver::Packet::~Packet ( )
virtualdefault

Virtual destructor for Packet class.

Todo
: use RBAC system to manage permissions

Member Function Documentation

◆ expired()

bool mal_packet_weaver::Packet::expired ( ) const
inlinenodiscardnoexcept

Check if the packet has expired based on its time-to-live.

Definition at line 77 of file packet.hpp.

Here is the call graph for this function:

◆ get_packet_time_alive()

float mal_packet_weaver::Packet::get_packet_time_alive ( ) const
inlinenodiscardnoexcept

Get the time elapsed since the packet was received.

Definition at line 74 of file packet.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

Packet & mal_packet_weaver::Packet::operator= ( Packet && )
default

◆ packet_name()

virtual const char * mal_packet_weaver::Packet::packet_name ( ) const
pure virtual

◆ serialize()

template<class Archive >
void mal_packet_weaver::Packet::serialize ( Archive & ,
const unsigned int  )
inlineprivate

Definition at line 89 of file packet.hpp.

◆ serialize_to_bytearray()

virtual void mal_packet_weaver::Packet::serialize_to_bytearray ( ByteArray & buffer) const
pure virtual

Serialize the packet into a ByteArray.

Implemented in mal_packet_weaver::DerivedPacket< PacketType >.

◆ timestamp()

float mal_packet_weaver::Packet::timestamp ( ) const
inlinenodiscardnoexcept

Get the timestamp when the packet was received.

Definition at line 71 of file packet.hpp.

Friends And Related Symbol Documentation

◆ cereal::access

friend class cereal::access
friend

Definition at line 84 of file packet.hpp.

Member Data Documentation

◆ measurer

Measurer< std::chrono::steady_clock > mal_packet_weaver::Packet::measurer
staticprivate

Measurer for packet timestamps.

Definition at line 49 of file packet.hpp.

◆ time_to_live

const float mal_packet_weaver::Packet::time_to_live

Time-to-live for the packet.

Definition at line 80 of file packet.hpp.

◆ timestamp_

const float mal_packet_weaver::Packet::timestamp_

Timestamp when the packet was received.

Definition at line 81 of file packet.hpp.

◆ type

const UniquePacketID mal_packet_weaver::Packet::type

Unique packet ID.

Definition at line 79 of file packet.hpp.


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