libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::CallbackBlock< ArgType, Args > Class Template Reference

回调函数封装块,提供参数绑定与擦除调用入口 / Callback block with bound argument and erased invoke entry More...

#include <libxr_cb.hpp>

Inheritance diagram for LibXR::CallbackBlock< ArgType, Args >:
[legend]
Collaboration diagram for LibXR::CallbackBlock< ArgType, Args >:
[legend]

Public Types

using FunctionType = void (*)(bool, ArgType, Args...)
 回调函数类型定义 / Callback function type definition
 
- Public Types inherited from LibXR::CallbackBlockHeader< Args... >
using InvokeFunType
 

Public Member Functions

 CallbackBlock (FunctionType fun, ArgType &&arg)
 构造回调块,绑定回调函数与参数 / Construct a callback block with bound function and argument
 
 CallbackBlock (const CallbackBlock &other)=delete
 禁用拷贝构造与拷贝赋值 / Copy construction and copy assignment are disabled
 
CallbackBlockoperator= (const CallbackBlock &other)=delete
 

Static Public Member Functions

static void InvokeThunk (void *cb_block, bool in_isr, Args... args)
 

Protected Member Functions

void Invoke (bool in_isr, Args... args)
 

Protected Attributes

FunctionType fun_
 绑定的回调函数 / Bound callback function
 
ArgType arg_
 绑定的参数 / Bound argument
 

Additional Inherited Members

- Data Fields inherited from LibXR::CallbackBlockHeader< Args... >
InvokeFunType run_fun_
 

Detailed Description

template<typename ArgType, typename... Args>
class LibXR::CallbackBlock< ArgType, Args >

回调函数封装块,提供参数绑定与擦除调用入口 / Callback block with bound argument and erased invoke entry

Template Parameters
ArgType绑定的第一个参数类型 / Type of the first bound argument
Args额外的参数类型列表 / Additional argument types

Definition at line 40 of file libxr_cb.hpp.

Member Typedef Documentation

◆ FunctionType

template<typename ArgType , typename... Args>
using LibXR::CallbackBlock< ArgType, Args >::FunctionType = void (*)(bool, ArgType, Args...)

回调函数类型定义 / Callback function type definition

Definition at line 46 of file libxr_cb.hpp.

Constructor & Destructor Documentation

◆ CallbackBlock()

template<typename ArgType , typename... Args>
LibXR::CallbackBlock< ArgType, Args >::CallbackBlock ( FunctionType fun,
ArgType && arg )
inline

构造回调块,绑定回调函数与参数 / Construct a callback block with bound function and argument

Parameters
fun需要调用的回调函数 / Callback function to be invoked
arg绑定的参数值 / Bound argument value

Definition at line 55 of file libxr_cb.hpp.

56 : CallbackBlockHeader<Args...>{&InvokeThunk}, fun_(fun), arg_(std::move(arg))
57 {
58 ASSERT(fun_ != nullptr);
59 }
FunctionType fun_
绑定的回调函数 / Bound callback function
Definition libxr_cb.hpp:79
ArgType arg_
绑定的参数 / Bound argument
Definition libxr_cb.hpp:80

Member Function Documentation

◆ Invoke()

template<typename ArgType , typename... Args>
void LibXR::CallbackBlock< ArgType, Args >::Invoke ( bool in_isr,
Args... args )
inlineprotected

Definition at line 74 of file libxr_cb.hpp.

75 {
76 fun_(in_isr, arg_, std::forward<Args>(args)...);
77 }

◆ InvokeThunk()

template<typename ArgType , typename... Args>
static void LibXR::CallbackBlock< ArgType, Args >::InvokeThunk ( void * cb_block,
bool in_isr,
Args... args )
inlinestatic

Definition at line 67 of file libxr_cb.hpp.

68 {
69 auto* cb = static_cast<CallbackBlock<ArgType, Args...>*>(cb_block);
70 cb->Invoke(in_isr, std::forward<Args>(args)...);
71 }
CallbackBlock(FunctionType fun, ArgType &&arg)
构造回调块,绑定回调函数与参数 / Construct a callback block with bound function and argument
Definition libxr_cb.hpp:55

Field Documentation

◆ arg_

template<typename ArgType , typename... Args>
ArgType LibXR::CallbackBlock< ArgType, Args >::arg_
protected

绑定的参数 / Bound argument

Definition at line 80 of file libxr_cb.hpp.

◆ fun_

template<typename ArgType , typename... Args>
FunctionType LibXR::CallbackBlock< ArgType, Args >::fun_
protected

绑定的回调函数 / Bound callback function

Definition at line 79 of file libxr_cb.hpp.


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