ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
ngl::xmlprotocol Class Reference

XML协议定义加载器 More...

#include <xmlprotocol.h>

Static Public Member Functions

static void load ()
 加载协议定义
static std::optional< int32_t > protocol (const std::string &aname)
 按名称查询协议编号
static int32_t free_protocol (int32_t amin=200)
 分配运行时协议ID
static void reserve (const std::string &aname, int32_t anumber)
 保留协议ID

Detailed Description

XML协议定义加载器

从XML文件加载消息类型元数据,提供:

Member Function Documentation

◆ free_protocol()

int32_t ngl::xmlprotocol::free_protocol ( int32_t amin = 200)
static

分配运行时协议ID

分配一个未使用的协议编号

Parameters
amin最小协议ID,默认为200
Returns
分配的协议ID

在配置的XML集合之外分配运行时协议ID。 amin下界搜索;默认值高于框架保留范围, 以避免覆盖内置的np_* ID。

从amin开始递增查找第一个未被占用的编号并注册。

Parameters
amin起始编号(默认从1开始)
Returns
分配到的协议编号

◆ load()

void ngl::xmlprotocol::load ( )
static

加载协议定义

加载所有协议定义文件

从XML文件加载协议名称到编号的映射到静态map。

清空已有映射后依次读取net_protocol.xml和example_protocol.xml。

◆ protocol()

std::optional< int32_t > ngl::xmlprotocol::protocol ( const std::string & aname)
static

按名称查询协议编号

按协议名查找编号

Parameters
aname协议名称
Returns
协议编号,未找到返回std::nullopt

◆ reserve()

void ngl::xmlprotocol::reserve ( const std::string & aname,
int32_t anumber )
static

保留协议ID

手动预留指定协议编号

Parameters
aname协议名称
anumber协议编号

保留显式的(名称,编号)对,以便后续free_protocol调用 能够观察到分配并避免重复。

Parameters
aname协议名称
anumber要预留的编号

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