通用回调包装,支持动态参数传递 / Generic callback wrapper supporting dynamic argument passing
More...
|
| | Callback () |
| | 默认构造函数,创建空回调对象 / Default constructor creating an empty callback
|
| |
|
| Callback (const Callback &)=default |
| |
|
Callback & | operator= (const Callback &)=default |
| |
| | Callback (Callback &&other) noexcept |
| | 移动构造函数,转移回调对象的所有权 / Move constructor transferring callback ownership
|
| |
| Callback & | operator= (Callback &&other) noexcept |
| | 移动赋值运算符,转移回调对象的所有权 / Move assignment operator transferring callback ownership
|
| |
| template<typename... PassArgs> |
| void | Run (bool in_isr, PassArgs &&... args) const |
| |
| bool | Empty () const |
| | 检查回调是否为空 / Check whether the callback is empty
|
| |
|
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...> |
| static Callback | Create (CallableType fun, BoundArgType arg) |
| | 创建回调对象并绑定回调函数与参数 / Create a callback instance with bound function and argument
|
| |
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...> |
| static Callback | CreateGuarded (CallableType fun, BoundArgType arg) |
| | 创建带防重入保护的回调 / Create a guarded callback
|
| |
template<typename... Args>
class LibXR::Callback< Args >
通用回调包装,支持动态参数传递 / Generic callback wrapper supporting dynamic argument passing
- Template Parameters
-
| Args | 额外的参数类型列表 / Additional argument types |
Definition at line 141 of file libxr_cb.hpp.
template<typename... Args>
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...>
创建回调对象并绑定回调函数与参数 / Create a callback instance with bound function and argument
- Template Parameters
-
| BoundArgType | 绑定参数类型 / Bound argument type |
| CallableType | 回调可调用对象类型 / Callback callable type |
- Parameters
-
| fun | 需要绑定的回调函数 / Callback function to bind |
| arg | 绑定的参数值 / Bound argument value |
- Returns
- Callback 实例 / Created Callback instance
Definition at line 159 of file libxr_cb.hpp.
160 {
161 using FunctionType = typename CallbackBlock<BoundArgType, Args...>::FunctionType;
162 auto cb_block =
163 new CallbackBlock<BoundArgType, Args...>(static_cast<FunctionType>(fun),
164 std::move(arg));
166 }
Callback()
默认构造函数,创建空回调对象 / Default constructor creating an empty callback
template<typename... Args>
template<typename BoundArgType , typename CallableType >
requires CallbackFunctionCompatible<CallableType, BoundArgType, Args...>
创建带防重入保护的回调 / Create a guarded callback
- Template Parameters
-
| BoundArgType | 绑定参数类型 / Bound argument type |
| CallableType | 回调可调用对象类型 / Callback callable type |
- Parameters
-
| fun | 需要绑定的回调函数 / Callback function to bind |
| arg | 绑定的参数值 / Bound argument value |
- Returns
- Callback 实例 / Created Callback instance
Definition at line 179 of file libxr_cb.hpp.
180 {
181 using FunctionType = typename CallbackBlock<BoundArgType, Args...>::FunctionType;
182 auto cb_block =
183 new GuardedCallbackBlock<BoundArgType, Args...>(static_cast<FunctionType>(fun),
184 std::move(arg));
186 }