Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
MessageType Struct Reference

Represents either a default or custom message identifier. More...

#include <network_message.h>

Public Types

enum class  Kind : uint8_t { Default , Custom }
 

Public Member Functions

 MessageType ()=default
 
 MessageType (DefaultMessageTypes t)
 
 MessageType (CustomMessageTypes t)
 
 MessageType (Kind kind, uint16_t t)
 
bool operator< (const MessageType &other) const
 Strict ordering operator for use in associative containers.
 

Static Public Member Functions

static uint16_t to_raw (const MessageType &type)
 Packs a MessageType into a 16-bit integer.
 
static MessageType from_raw (uint16_t raw)
 Restores a MessageType from a raw 16-bit value.
 

Public Attributes

Kind kind
 
uint16_t value
 

Detailed Description

Represents either a default or custom message identifier.

MessageType encodes both the message category (Default/Custom) and the underlying 15-bit value. When serialized, the high bit is used to represent whether the type is custom or default.

Member Enumeration Documentation

◆ Kind

enum class MessageType::Kind : uint8_t
strong
Enumerator
Default 
Custom 

Constructor & Destructor Documentation

◆ MessageType() [1/4]

MessageType::MessageType ( )
default

◆ MessageType() [2/4]

MessageType::MessageType ( DefaultMessageTypes  t)
inline

◆ MessageType() [3/4]

MessageType::MessageType ( CustomMessageTypes  t)
inline

◆ MessageType() [4/4]

MessageType::MessageType ( Kind  kind,
uint16_t  t 
)
inline

Member Function Documentation

◆ from_raw()

static MessageType MessageType::from_raw ( uint16_t  raw)
inlinestatic

Restores a MessageType from a raw 16-bit value.

Top bit → Kind::Custom. Lowest 15 bits → type value.

◆ operator<()

bool MessageType::operator< ( const MessageType other) const
inline

Strict ordering operator for use in associative containers.

◆ to_raw()

static uint16_t MessageType::to_raw ( const MessageType type)
inlinestatic

Packs a MessageType into a 16-bit integer.

The highest bit indicates whether the type is custom.

Member Data Documentation

◆ kind

Kind MessageType::kind

◆ value

uint16_t MessageType::value

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