NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::reflect::meta_type类 参考

类型反射元数据类 更多...

#include <type.hpp>

Public 类型

using constructor_func = _NEFORCE function<meta_any(const vector<meta_any>&)>
 构造函数调用器类型
using clone_func = _NEFORCE function<meta_any(const void*)>
 克隆函数类型
using container_size_func = _NEFORCE function<size_t(const void*)>
 容器大小查询
using container_get_func = _NEFORCE function<meta_any(const void*, size_t)>
 按索引获取元素
using container_insert_func = _NEFORCE function<void(void*, const meta_any&)>
 插入元素
using container_insert_kv_func = _NEFORCE function<void(void*, const meta_any&, const meta_any&)>
 插入键值对

Public 成员函数

 meta_type (string_view name, reflect::type_id id, size_t size)
 构造函数
reflect::type_id type_id () const noexcept
 获取类型ID
string_view name () const noexcept
 获取类型名称
string_view table_name () const noexcept
 获取数据库表名
meta_typeset_table_name (string_view table)
 设置数据库表名
size_t size () const noexcept
 获取类型大小
const vector< meta_type * > & base_types () const
 获取基类列表
meta_typebase_type (meta_type *base)
 添加基类(已解析)
meta_typebase_type (string_view base_name)
 添加基类(延迟解析)
bool is_derived_from (reflect::type_id base_id) const
 检查是否派生自指定类型
bool is_derived_from (string_view base_name) const
 检查是否派生自指定类型
meta_typeproperty (string_view name, reflect::type_id prop_type_id, meta_property::getter getter, meta_property::setter setter, const uint16_t attrs=PROP_NONE)
 添加属性
meta_functionfunction (string_view name, meta_function::invoker invoker)
 添加函数
meta_typeconstructor (constructor_func ctor)
 设置构造函数
meta_typecloner (clone_func cloner)
 设置克隆函数
meta_any clone (const void *src) const
 克隆对象
const meta_enumenum_info () const noexcept
 获取枚举信息
bool is_enum () const noexcept
 是否为枚举类型
meta_typeenum_info (unique_ptr< meta_enum > info)
 设置枚举信息
container_kind container () const noexcept
 获取容器类型
meta_typecontainer (container_kind kind)
 设置容器信息
reflect::type_id element_type_id () const noexcept
 获取元素类型 ID(顺序容器)
meta_typeelement_type_id (reflect::type_id id)
 设置元素类型 ID
reflect::type_id key_type_id () const noexcept
 获取键类型 ID(关联容器)
meta_typekey_type_id (reflect::type_id id)
 设置键类型 ID
reflect::type_id mapped_type_id () const noexcept
 获取值类型 ID(关联容器)
meta_typemapped_type_id (reflect::type_id id)
 设置值类型 ID
meta_typecontainer_size (container_size_func func)
 设置容器大小查询函数
size_t container_element_count (const void *container_ptr) const
 获取容器元素数量
meta_typecontainer_get (container_get_func func)
 设置按索引获取元素的函数
meta_any container_element_at (const void *container_ptr, size_t index) const
 获取容器中指定索引的元素
meta_typecontainer_insert (container_insert_func func)
 设置插入元素函数(顺序容器)
void container_push_back (void *container_ptr, const meta_any &value) const
 向容器追加元素
meta_typecontainer_insert_kv (container_insert_kv_func func)
 设置插入键值对函数(关联容器)
void container_insert_pair (void *container_ptr, const meta_any &key, const meta_any &value) const
 向关联容器插入键值对
bool is_container () const noexcept
 是否为容器类型
const meta_propertyget_property (string_view name) const
 获取属性
const meta_functionget_function (string_view name) const
 获取函数
meta_typeregister_signal (string_view name)
 注册信号名称
const vector< string > & signal_names () const noexcept
 获取信号名称列表
void add_property (string_view name, unique_ptr< meta_property > prop)
 运行时添加属性(动态属性)
meta_any create () const
 创建对象(无参构造)
meta_any create (const vector< meta_any > &args) const
 创建对象(带参数)
const auto & properties () const
 获取属性映射
const auto & functions () const
 获取函数映射
vector< pair< string, const meta_property * > > all_properties () const
 获取所有属性(包括继承的属性)
vector< pair< string, const meta_function * > > all_functions () const
 获取所有函数(包括继承的函数)
void resolve_bases (registry *registry)
 解析待解析的基类名称
void resolve_bases_unlocked (registry *registry)
 解析待解析的基类名称(无需加锁版本)
bool has_pending_bases () const noexcept
 是否有待解析的基类

详细描述

类型反射元数据类

描述一个类型的完整反射信息,包括:

  • 类型基本信息(名称、大小、ID)
  • 继承关系(基类列表)
  • 属性列表(成员变量)
  • 函数列表(成员函数和静态函数)
  • 构造函数
  • 枚举信息
  • 容器信息
  • 克隆工厂

在文件 type.hpp53 行定义.

构造及析构函数说明

◆ meta_type()

neforce::reflect::meta_type::meta_type ( string_view name,
reflect::type_id id,
size_t size )
inline

构造函数

参数
name类型名称
id类型ID
size类型大小

在文件 type.hpp141 行定义.

引用了 name() , 以及 size().

被这些函数引用 base_type(), base_type(), cloner(), constructor(), container(), container_get(), container_insert(), container_insert_kv(), container_size(), element_type_id(), enum_info(), key_type_id(), mapped_type_id(), property(), register_signal() , 以及 set_table_name().

成员函数说明

◆ add_property()

void neforce::reflect::meta_type::add_property ( string_view name,
unique_ptr< meta_property > prop )
inline

运行时添加属性(动态属性)

参数
name属性名称
prop属性元数据

在文件 type.hpp500 行定义.

引用了 neforce::move() , 以及 name().

◆ all_functions()

vector< pair< string, const meta_function * > > neforce::reflect::meta_type::all_functions ( ) const
inlinenodiscard

获取所有函数(包括继承的函数)

返回
函数列表

在文件 type.hpp543 行定义.

◆ all_properties()

vector< pair< string, const meta_property * > > neforce::reflect::meta_type::all_properties ( ) const
inlinenodiscard

获取所有属性(包括继承的属性)

返回
属性列表

在文件 type.hpp533 行定义.

◆ base_type() [1/2]

meta_type & neforce::reflect::meta_type::base_type ( meta_type * base)
inline

添加基类(已解析)

参数
base基类元数据
返回
自身引用

在文件 type.hpp187 行定义.

引用了 meta_type().

◆ base_type() [2/2]

meta_type & neforce::reflect::meta_type::base_type ( string_view base_name)
inline

添加基类(延迟解析)

参数
base_name基类名称
返回
自身引用

在文件 type.hpp199 行定义.

引用了 meta_type().

◆ clone()

meta_any neforce::reflect::meta_type::clone ( const void * src) const
inlinenodiscard

克隆对象

参数
src源对象指针
返回
克隆出的对象

在文件 type.hpp287 行定义.

◆ cloner()

meta_type & neforce::reflect::meta_type::cloner ( clone_func cloner)
inline

设置克隆函数

参数
cloner克隆函数
返回
自身引用

在文件 type.hpp277 行定义.

引用了 cloner(), meta_type() , 以及 neforce::move().

被这些函数引用 cloner().

◆ constructor()

meta_type & neforce::reflect::meta_type::constructor ( constructor_func ctor)
inline

设置构造函数

参数
ctor构造函数调用器
返回
自身引用

在文件 type.hpp267 行定义.

引用了 meta_type() , 以及 neforce::move().

◆ container()

meta_type & neforce::reflect::meta_type::container ( container_kind kind)
inline

设置容器信息

参数
kind容器类型
返回
自身引用

在文件 type.hpp320 行定义.

引用了 meta_type().

◆ container_element_at()

meta_any neforce::reflect::meta_type::container_element_at ( const void * container_ptr,
size_t index ) const
inlinenodiscard

获取容器中指定索引的元素

参数
container_ptr容器对象指针
index元素索引
返回
包装为 meta_any 的元素

在文件 type.hpp395 行定义.

◆ container_element_count()

size_t neforce::reflect::meta_type::container_element_count ( const void * container_ptr) const
inlinenodiscard

获取容器元素数量

参数
container_ptr容器对象指针
返回
元素数量

在文件 type.hpp377 行定义.

◆ create() [1/2]

meta_any neforce::reflect::meta_type::create ( ) const
inlinenodiscard

创建对象(无参构造)

返回
创建的对象

在文件 type.hpp506 行定义.

◆ create() [2/2]

meta_any neforce::reflect::meta_type::create ( const vector< meta_any > & args) const
inlinenodiscard

创建对象(带参数)

参数
args构造参数
返回
创建的对象

在文件 type.hpp513 行定义.

◆ enum_info() [1/2]

const meta_enum * neforce::reflect::meta_type::enum_info ( ) const
inlinenodiscardnoexcept

获取枚举信息

返回
枚举信息指针,非枚举类型返回 nullptr

在文件 type.hpp293 行定义.

◆ enum_info() [2/2]

meta_type & neforce::reflect::meta_type::enum_info ( unique_ptr< meta_enum > info)
inline

设置枚举信息

参数
info枚举信息
返回
自身引用

在文件 type.hpp305 行定义.

引用了 meta_type() , 以及 neforce::move().

◆ function()

meta_function * neforce::reflect::meta_type::function ( string_view name,
meta_function::invoker invoker )
inline

添加函数

参数
name函数名称
invoker调用器
返回
函数元数据指针

在文件 type.hpp257 行定义.

引用了 neforce::make_unique(), neforce::move() , 以及 name().

◆ functions()

const auto & neforce::reflect::meta_type::functions ( ) const
inlinenodiscard

获取函数映射

返回
函数映射常量引用

在文件 type.hpp527 行定义.

◆ get_function()

const meta_function * neforce::reflect::meta_type::get_function ( string_view name) const
inlinenodiscard

获取函数

参数
name函数名称
返回
函数元数据指针,不存在返回nullptr

在文件 type.hpp464 行定义.

引用了 name().

◆ get_property()

const meta_property * neforce::reflect::meta_type::get_property ( string_view name) const
inlinenodiscard

获取属性

参数
name属性名称
返回
属性元数据指针,不存在返回nullptr

在文件 type.hpp443 行定义.

引用了 name().

◆ is_derived_from() [1/2]

bool neforce::reflect::meta_type::is_derived_from ( reflect::type_id base_id) const
inlinenodiscard

检查是否派生自指定类型

参数
base_id基类类型ID
返回
是派生类返回true

在文件 type.hpp209 行定义.

◆ is_derived_from() [2/2]

bool neforce::reflect::meta_type::is_derived_from ( string_view base_name) const
inlinenodiscard

检查是否派生自指定类型

参数
base_name基类名称
返回
是派生类返回true

在文件 type.hpp226 行定义.

◆ properties()

const auto & neforce::reflect::meta_type::properties ( ) const
inlinenodiscard

获取属性映射

返回
属性映射常量引用

在文件 type.hpp521 行定义.

◆ property()

meta_type & neforce::reflect::meta_type::property ( string_view name,
reflect::type_id prop_type_id,
meta_property::getter getter,
meta_property::setter setter,
const uint16_t attrs = PROP_NONE )
inline

添加属性

参数
name属性名称
prop_type_id属性类型ID
getter读取器
setter写入器
attrs属性注解
返回
自身引用

在文件 type.hpp244 行定义.

引用了 neforce::make_unique(), meta_type(), neforce::move(), name() , 以及 neforce::reflect::PROP_NONE.

◆ register_signal()

meta_type & neforce::reflect::meta_type::register_signal ( string_view name)
inline

注册信号名称

参数
name信号名称
返回
自身引用

在文件 type.hpp485 行定义.

引用了 meta_type() , 以及 name().

◆ resolve_bases()

void neforce::reflect::meta_type::resolve_bases ( registry * registry)

解析待解析的基类名称

参数
registry注册表指针

◆ resolve_bases_unlocked()

void neforce::reflect::meta_type::resolve_bases_unlocked ( registry * registry)

解析待解析的基类名称(无需加锁版本)

参数
registry注册表指针

◆ set_table_name()

meta_type & neforce::reflect::meta_type::set_table_name ( string_view table)
inline

设置数据库表名

参数
table表名
返回
自身引用

在文件 type.hpp167 行定义.

引用了 meta_type().

◆ table_name()

string_view neforce::reflect::meta_type::table_name ( ) const
inlinenodiscardnoexcept

获取数据库表名

返回
表名视图,未设置时返回空

在文件 type.hpp160 行定义.

引用了 neforce::basic_string_view< CharT, Traits >::view().


该类的文档由以下文件生成: