NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::tui::state< T > 模板类 参考

响应式状态变量 更多...

#include <state.hpp>

Public 类型

using changed_signal = signal<T>
 值变化信号类型

Public 成员函数

 state (component_base *owner, strand &s, T initial)
 构造函数
const T & value () const noexcept
 读取当前值
const T & operator* () const noexcept
 读取当前值
const T * operator-> () const noexcept
 成员访问
stateoperator= (T v)
 整值替换
void modify (function< void(T &)> fn)
 就地修改
void set_quiet (T v)
 静默写入
void notify ()
 手动触发重渲染
connection on_change (function< void(const T &)> fn)
 订阅值变化通知

详细描述

template<typename T>
class neforce::tui::state< T >

响应式状态变量

模板参数
T值类型

写入时自动通过 strand 调度组件重渲染, 支持读取、整值替换、就地修改和批量静默更新四种模式。

注解
必须在 component::create_state() 中创建,通过组件生命周期管理。

在文件 state.hpp36 行定义.

构造及析构函数说明

◆ state()

template<typename T>
neforce::tui::state< T >::state ( component_base * owner,
strand & s,
T initial )
inline

构造函数

参数
owner所属组件
s串行执行器引用
initial初始值

在文件 state.hpp47 行定义.

引用了 neforce::move().

被这些函数引用 operator=().

成员函数说明

◆ modify()

template<typename T>
void neforce::tui::state< T >::modify ( function< void(T &)> fn)
inline

就地修改

参数
fn修改函数,接收 T& 引用

在文件 state.hpp92 行定义.

◆ notify()

template<typename T>
void neforce::tui::state< T >::notify ( )
inline

手动触发重渲染

配合 setQuiet() 使用,在批量操作结束后调用一次。

在文件 state.hpp114 行定义.

◆ on_change()

template<typename T>
connection neforce::tui::state< T >::on_change ( function< void(const T &)> fn)
inline

订阅值变化通知

参数
fn回调函数,接收新值常量引用
返回
连接句柄

在文件 state.hpp126 行定义.

引用了 neforce::move().

◆ operator*()

template<typename T>
const T & neforce::tui::state< T >::operator* ( ) const
inlinenodiscardnoexcept

读取当前值

返回
常量引用

在文件 state.hpp69 行定义.

◆ operator->()

template<typename T>
const T * neforce::tui::state< T >::operator-> ( ) const
inlinenodiscardnoexcept

成员访问

返回
常量指针

在文件 state.hpp75 行定义.

◆ operator=()

template<typename T>
state & neforce::tui::state< T >::operator= ( T v)
inline

整值替换

参数
v新值
返回
自身引用

在文件 state.hpp82 行定义.

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

◆ set_quiet()

template<typename T>
void neforce::tui::state< T >::set_quiet ( T v)
inline

静默写入

参数
v新值

用于批量操作场景,最后手动调用 notify()

在文件 state.hpp103 行定义.

引用了 neforce::move().

◆ value()

template<typename T>
const T & neforce::tui::state< T >::value ( ) const
inlinenodiscardnoexcept

读取当前值

返回
常量引用

在文件 state.hpp63 行定义.


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