ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
ngl::message< T > Struct Template Reference

强类型消息信封模板。 More...

#include <nrfun.h>

Public Member Functions

 message (i32_threadid athread, const std::shared_ptr< pack > &apack, const std::shared_ptr< T > &adata)
 构造函数,使用shared_ptr持有消息数据。
 message (i32_threadid athread, std::shared_ptr< pack > apack, T *adata)
 构造函数,使用原始指针持有消息数据。
const T * get_data () const
 获取消息数据指针。
const std::shared_ptr< T > & get_shared_data () const
 获取消息数据的共享指针。
const packget_pack () const
 获取关联的网络数据包指针。
const std::shared_ptr< pack > & get_shared_pack () const
 获取网络数据包的共享指针。
std::optional< i32_threadidthread () const
 获取处理该消息的线程ID。

Detailed Description

template<typename T>
struct ngl::message< T >

强类型消息信封模板。

封装消息数据、网络包和线程信息。 提供类型安全的消息访问接口。

Template Parameters
T消息数据类型

Constructor & Destructor Documentation

◆ message() [1/2]

template<typename T>
ngl::message< T >::message ( i32_threadid athread,
const std::shared_ptr< pack > & apack,
const std::shared_ptr< T > & adata )
inline

构造函数,使用shared_ptr持有消息数据。

Parameters
athread线程ID
apack网络数据包
adata消息数据共享指针

◆ message() [2/2]

template<typename T>
ngl::message< T >::message ( i32_threadid athread,
std::shared_ptr< pack > apack,
T * adata )
inline

构造函数,使用原始指针持有消息数据。

Parameters
athread线程ID
apack网络数据包
adata消息数据原始指针

Member Function Documentation

◆ get_data()

template<typename T>
const T * ngl::message< T >::get_data ( ) const
inline

获取消息数据指针。

Returns
消息数据常量指针

◆ get_pack()

template<typename T>
const pack * ngl::message< T >::get_pack ( ) const
inline

获取关联的网络数据包指针。

Returns
网络数据包常量指针

◆ get_shared_data()

template<typename T>
const std::shared_ptr< T > & ngl::message< T >::get_shared_data ( ) const
inline

获取消息数据的共享指针。

Returns
消息数据共享指针的常量引用

◆ get_shared_pack()

template<typename T>
const std::shared_ptr< pack > & ngl::message< T >::get_shared_pack ( ) const
inline

获取网络数据包的共享指针。

Returns
网络数据包共享指针的常量引用

◆ thread()

template<typename T>
std::optional< i32_threadid > ngl::message< T >::thread ( ) const
inline

获取处理该消息的线程ID。

Returns
线程ID的optional,如果线程ID无效则返回nullopt

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