NexusForce 1.0.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
signal< Types > 模板结构体 参考

信号类 更多...

#include <signals.hpp>

Public 成员函数

template<typename Self, typename MemFn, typename... Tag>
connection connect (Self self, MemFn memfn, Tag... tag)
 连接成员函数(默认优先级0)
template<typename Func>
connection connect (Func callback, int priority=0)
 连接普通函数/lambda
template<typename Self, typename MemFn, typename... Tag>
connection connect (Self self, MemFn memfn, int priority, Tag... tag)
 连接成员函数
void emit (Types... args)
 触发信号
template<typename Executor>
void emit_executor (Executor &executor, Types... args)
 执行器触发信号
template<typename... Args>
void operator() (Args &&... args)
 函数调用操作符
void disconnect_all ()
 断开所有连接
connection connect_signal (signal &other, int priority=0)
 连接另一个信号
connection connect_signal (signal *other, int priority=0)
 连接另一个信号(指针版本)
template<typename Func, typename Predicate>
connection connect_if (Func callback, Predicate pred, int priority=0)
 条件连接
template<typename Self, typename MemFn, typename Predicate, typename... Tag>
connection connect_if (Self self, MemFn memfn, Predicate pred, int priority, Tag... tag)
 条件连接(成员函数版本)
template<typename Func, typename Filter>
connection connect_filtered (Func callback, Filter filter, int priority=0)
 过滤连接
template<typename Func, typename Transform>
connection connect_transformed (Func callback, Transform transform, int priority=0)
 变换连接
shared_ptr< bool > block_flag () const noexcept
 获取阻塞标志
bool is_blocked () const noexcept
 检查信号是否被阻塞
size_t slot_count () const noexcept
 获取活跃槽的数量
NEFORCE_NODISCARD bool empty () const noexcept
 检查信号是否为空(无活跃槽)

详细描述

template<typename... Types>
struct signal< Types >

信号类

模板参数
Types信号参数类型列表

多播委托实现。

在文件 signals.hpp240 行定义.

成员函数说明

◆ block_flag()

template<typename... Types>
shared_ptr< bool > signal< Types >::block_flag ( ) const
inlinenoexcept

获取阻塞标志

返回
阻塞标志的共享指针

在文件 signals.hpp705 行定义.

◆ connect() [1/3]

template<typename... Types>
template<typename Func>
connection signal< Types >::connect ( Func callback,
int priority = 0 )
inline

连接普通函数/lambda

模板参数
Func函数类型
参数
callback回调函数
priority优先级(值越大优先级越高)
返回
连接句柄

在文件 signals.hpp444 行定义.

引用了 move() , 以及 priority().

◆ connect() [2/3]

template<typename... Types>
template<typename Self, typename MemFn, typename... Tag>
connection signal< Types >::connect ( Self self,
MemFn memfn,
int priority,
Tag... tag )
inline

连接成员函数

模板参数
Self对象类型
MemFn成员函数类型
Tag连接标签类型
参数
self对象指针/智能指针
memfn成员函数指针
priority优先级
tag连接标签(可选)
返回
连接句柄

在文件 signals.hpp462 行定义.

引用了 move() , 以及 priority().

◆ connect() [3/3]

template<typename... Types>
template<typename Self, typename MemFn, typename... Tag>
connection signal< Types >::connect ( Self self,
MemFn memfn,
Tag... tag )
inline

连接成员函数(默认优先级0)

模板参数
Self对象类型
MemFn成员函数类型
Tag连接标签类型
参数
self对象指针/智能指针
memfn成员函数指针
tag连接标签(可选)
返回
连接句柄

在文件 signals.hpp432 行定义.

引用了 connect() , 以及 move().

被这些函数引用 connect(), connect_filtered(), connect_if(), connect_if(), connect_signal(), connect_signal() , 以及 connect_transformed().

◆ connect_filtered()

template<typename... Types>
template<typename Func, typename Filter>
connection signal< Types >::connect_filtered ( Func callback,
Filter filter,
int priority = 0 )
inline

过滤连接

模板参数
Func回调函数类型
Filter过滤器类型
参数
callback回调函数
filter过滤器
priority优先级
返回
连接句柄

过滤器可以修改或抑制参数。

在文件 signals.hpp659 行定义.

引用了 connect(), keep, move() , 以及 priority().

◆ connect_if() [1/2]

template<typename... Types>
template<typename Func, typename Predicate>
connection signal< Types >::connect_if ( Func callback,
Predicate pred,
int priority = 0 )
inline

条件连接

模板参数
Func回调函数类型
Predicate谓词类型
参数
callback回调函数
pred谓词
priority优先级
返回
连接句柄

仅当谓词返回true时才调用回调。

在文件 signals.hpp602 行定义.

引用了 connect(), is_boolean_v, keep, move() , 以及 priority().

◆ connect_if() [2/2]

template<typename... Types>
template<typename Self, typename MemFn, typename Predicate, typename... Tag>
connection signal< Types >::connect_if ( Self self,
MemFn memfn,
Predicate pred,
int priority,
Tag... tag )
inline

条件连接(成员函数版本)

模板参数
Self对象类型
MemFn成员函数类型
Predicate谓词类型
Tag连接标签类型
参数
self对象指针/智能指针
memfn成员函数指针
pred谓词
priority优先级
tag连接标签
返回
连接句柄

在文件 signals.hpp630 行定义.

引用了 connect(), is_boolean_v, keep, move() , 以及 priority().

◆ connect_signal() [1/2]

template<typename... Types>
connection signal< Types >::connect_signal ( signal< Types > & other,
int priority = 0 )
inline

连接另一个信号

参数
other另一个信号
priority优先级
返回
连接句柄

当此信号触发时,会转发给other信号。

在文件 signals.hpp562 行定义.

引用了 connect() , 以及 priority().

◆ connect_signal() [2/2]

template<typename... Types>
connection signal< Types >::connect_signal ( signal< Types > * other,
int priority = 0 )
inline

连接另一个信号(指针版本)

参数
other另一个信号指针
priority优先级
返回
连接句柄

当此信号触发时,如果指针非空,则转发给other信号。

在文件 signals.hpp579 行定义.

引用了 connect(), keep , 以及 priority().

◆ connect_transformed()

template<typename... Types>
template<typename Func, typename Transform>
connection signal< Types >::connect_transformed ( Func callback,
Transform transform,
int priority = 0 )
inline

变换连接

模板参数
Func回调函数类型
Transform变换函数类型
参数
callback回调函数
transform变换函数
priority优先级
返回
连接句柄

变换函数将参数转换为新类型后传递给回调。

在文件 signals.hpp690 行定义.

引用了 connect(), is_invocable_v, move() , 以及 priority().

◆ emit()

template<typename... Types>
void signal< Types >::emit ( Types... args)
inline

触发信号

参数
args信号参数

同步调用所有已连接的槽函数。会自动清理已断开或请求擦除的槽。 如果信号被阻塞,则什么也不做。

在文件 signals.hpp485 行定义.

引用了 erase, is_blocked() , 以及 remove_if().

被这些函数引用 emit_executor() , 以及 operator()().

◆ emit_executor()

template<typename... Types>
template<typename Executor>
void signal< Types >::emit_executor ( Executor & executor,
Types... args )
inline

执行器触发信号

模板参数
Executor执行器类型
参数
executor执行器对象
args信号参数

在指定的执行器上异步调用emit。

在文件 signals.hpp524 行定义.

引用了 apply(), emit(), forward(), make_tuple() , 以及 move().

◆ empty()

template<typename... Types>
NEFORCE_NODISCARD bool signal< Types >::empty ( ) const
inlinenoexcept

检查信号是否为空(无活跃槽)

返回
是否为空

在文件 signals.hpp725 行定义.

◆ is_blocked()

template<typename... Types>
bool signal< Types >::is_blocked ( ) const
inlinenoexcept

检查信号是否被阻塞

返回
是否被阻塞

在文件 signals.hpp711 行定义.

被这些函数引用 emit().

◆ operator()()

template<typename... Types>
template<typename... Args>
void signal< Types >::operator() ( Args &&... args)
inline

函数调用操作符

参数
args信号参数

在文件 signals.hpp543 行定义.

引用了 emit() , 以及 forward().

◆ slot_count()

template<typename... Types>
size_t signal< Types >::slot_count ( ) const
inlinenoexcept

获取活跃槽的数量

返回
槽数量

在文件 signals.hpp717 行定义.


该结构体的文档由以下文件生成: