|
libxr
1.0
Want to be the best embedded framework
|
每次发布时直接执行函数的订阅句柄 / Subscription handle that runs a function on each publish More...
#include <callback.hpp>
Data Structures | |
| struct | BlockHeader |
| 回调句柄真正指向的那块数据的公共头 / Common header of the data block actually pointed to by one callback handle More... | |
| struct | Factory |
| 看回调有几个参数,决定分配哪种回调块 / Choose which callback block to allocate from the callback parameter count More... | |
| struct | Factory< Function, BoundArg, 3 > |
| 三参数回调块工厂 / Factory for three-argument callback blocks More... | |
| struct | Factory< Function, BoundArg, 4 > |
| 四参数回调块工厂 / Factory for four-argument callback blocks More... | |
| struct | FunctionTraits |
| 把一个无捕获回调函数拆成返回类型和参数类型 / Split one callback function without captures into its return type and parameter types More... | |
| struct | FunctionTraits< Return(*)(Args...)> |
| struct | MessageViewTraits |
判断某个参数是否为 MessageView<T> / Tell whether one argument is MessageView<T> More... | |
| struct | MessageViewTraits< MessageView< Data > > |
| struct | PayloadOnlyBlock |
| 只转发负载的回调块 / Callback block that forwards only the payload More... | |
| struct | TimestampPayloadBlock |
| 同时转发时间戳和负载的回调块 / Callback block that forwards both timestamp and payload More... | |
Public Member Functions | |
| Callback ()=default | |
| 构造一个空回调句柄 / Construct one empty callback handle | |
| Callback (const Callback &other)=default | |
| 拷贝构造回调句柄 / Copy-construct one callback handle | |
| Callback & | operator= (const Callback &other)=default |
| 拷贝赋值回调句柄 / Copy-assign one callback handle | |
| void | Run (bool in_isr, MicrosecondTimestamp timestamp, void *payload_addr, size_t payload_size) const |
| 执行回调 / Run the callback | |
| TypeID::ID | PayloadTypeID () const |
| 读取这个回调句柄期望的 payload 类型标识 / Read the payload type ID expected by this callback handle | |
| bool | IsRawPayloadView () const |
| 判断该回调是否按 raw payload 视图接收消息 / Tell whether this callback receives messages as a raw payload view | |
Static Public Member Functions | |
| template<typename BoundArg , typename Callable > | |
| static Callback | Create (Callable fun, BoundArg arg) |
| 创建一个回调订阅句柄 / Create a callback subscription handle | |
Private Types | |
| template<typename T > | |
| using | RemoveCVRef = std::remove_cv_t<std::remove_reference_t<T>> |
| 去掉引用和 cv 限定后的规范类型 / Canonical type after removing reference and cv qualifiers | |
Private Member Functions | |
| Callback (BlockHeader *block) | |
| 用指定执行块构造回调句柄 / Construct one callback handle from the given execution block | |
Static Private Member Functions | |
| template<typename PayloadArg > | |
| static TypeID::ID | PayloadTypeID () |
| 取回调 payload 参数对应的精确类型标识 / Get the exact type ID expected by one callback payload argument | |
| template<typename PayloadArg > | |
| static constexpr bool | AcceptsRawPayload () |
| 回调 payload 参数是否是 raw 字节视图 / Whether the callback payload argument is a raw byte view | |
| template<typename Function , typename BoundArg , typename PayloadArg > | |
| static void | InvokePayload (Function fun, BoundArg &arg, bool in_isr, MicrosecondTimestamp timestamp, void *payload_addr, size_t payload_size) |
| 按回调声明的参数形式,把当前消息拼成实参再调函数 / Build the actual call arguments from the current message in the form declared by the callback, then invoke it | |
| static void | EmptyRun (const BlockHeader *header, bool in_isr, MicrosecondTimestamp timestamp, void *payload_addr, size_t payload_size) |
| 空回调块的执行函数 / Execution function of the empty callback block | |
Private Attributes | |
| BlockHeader * | block_ = &empty_block_ |
Static Private Attributes | |
| template<typename T > | |
| static constexpr bool | IS_MESSAGE_VIEW |
| 是否为带时间戳的类型化消息视图参数 / Whether one callback payload argument is a timestamped typed message view | |
| template<typename T > | |
| static constexpr bool | IS_RAW_DATA_VIEW |
| 是否为只读 raw payload 视图参数 / Whether one callback payload argument is a read-only raw payload view | |
| template<typename T > | |
| static constexpr bool | IS_TYPED_DATA |
| 是否把 payload 直接当成一个对象接收 / Whether one callback payload argument receives the payload directly as one object | |
| template<typename T > | |
| static constexpr bool | IS_CALLBACK_PAYLOAD |
| 是否是回调接口允许的 payload 参数写法 / Whether one payload argument form is accepted by this callback interface | |
| template<typename T > | |
| static constexpr bool | IS_MUTABLE_MESSAGE_VIEW_REF |
是否错误地使用了可变 MessageView<T>& / Whether one payload argument is an invalid mutable MessageView<T>& | |
| static BlockHeader | empty_block_ |
每次发布时直接执行函数的订阅句柄 / Subscription handle that runs a function on each publish
每次发布时直接执行函数的回调订阅句柄 / Callback subscription handle that runs a function on each publish
Definition at line 15 of file callback.hpp.
|
private |
去掉引用和 cv 限定后的规范类型 / Canonical type after removing reference and cv qualifiers
| T | 待规范化的类型 / Type to normalize |
Definition at line 82 of file callback.hpp.
|
default |
拷贝构造回调句柄 / Copy-construct one callback handle
| other | 被拷贝的回调句柄 / Callback handle to copy from |
|
inlineexplicitprivate |
用指定执行块构造回调句柄 / Construct one callback handle from the given execution block
| block | 回调块公共头;为空时回退到静态空块 / Callback block header; falls back to the shared empty block when null |
Definition at line 554 of file callback.hpp.
|
inlinestaticconstexprprivate |
回调 payload 参数是否是 raw 字节视图 / Whether the callback payload argument is a raw byte view
| PayloadArg | 回调 payload 参数类型 / Callback payload argument type |
Definition at line 201 of file callback.hpp.
|
inlinestaticnodiscard |
创建一个回调订阅句柄 / Create a callback subscription handle
| BoundArg | 绑定参数类型 / Bound argument type |
| Callable | 回调可调用对象类型 / Callback callable type |
| fun | 捕获为空的回调函数 / Capture-free callback function |
| arg | 绑定到回调的参数 / Argument bound into the callback |
arg 拷进新分配的回调块里;之后回调执行读写的就是这份块内副本 / This copies arg into the newly allocated callback block; later callback execution reads or writes that stored copy Definition at line 508 of file callback.hpp.
|
inlinestaticprivate |
空回调块的执行函数 / Execution function of the empty callback block
| header | 空块头指针 / Empty block header pointer |
| in_isr | 当前是否处于中断上下文 / Whether the current path runs in ISR context |
| timestamp | 当前消息时间戳 / Current message timestamp |
| payload_addr | 当前消息 payload 对象地址 / Address of the current payload object |
Definition at line 456 of file callback.hpp.
|
inlinestaticprivate |
按回调声明的参数形式,把当前消息拼成实参再调函数 / Build the actual call arguments from the current message in the form declared by the callback, then invoke it
| Function | 回调函数类型 / Callback function type |
| BoundArg | 绑定参数类型 / Bound argument type |
| PayloadArg | 负载参数类型 / Payload argument type |
| fun | 回调函数 / Callback function |
| arg | 绑定参数 / Bound argument |
| in_isr | 当前是否处于中断上下文 / Whether the current path runs in ISR context |
| timestamp | 当前消息时间戳 / Current message timestamp |
| payload_addr | 当前消息 payload 对象地址 / Address of the current payload object |
Definition at line 221 of file callback.hpp.
|
inline |
判断该回调是否按 raw payload 视图接收消息 / Tell whether this callback receives messages as a raw payload view
Definition at line 545 of file callback.hpp.
拷贝赋值回调句柄 / Copy-assign one callback handle
| other | 被拷贝的回调句柄 / Callback handle to copy from |
|
inlinestaticprivate |
取回调 payload 参数对应的精确类型标识 / Get the exact type ID expected by one callback payload argument
| PayloadArg | 回调 payload 参数类型 / Callback payload argument type |
Definition at line 170 of file callback.hpp.
|
inline |
读取这个回调句柄期望的 payload 类型标识 / Read the payload type ID expected by this callback handle
Definition at line 537 of file callback.hpp.
|
inline |
执行回调 / Run the callback
| in_isr | 当前是否处于中断上下文 / Whether the current path runs in ISR context |
| timestamp | 当前消息时间戳 / Current message timestamp |
| payload_addr | 当前消息 payload 对象地址 / Address of the current payload object |
Definition at line 526 of file callback.hpp.
|
private |
当前回调句柄绑定的执行块。Execution block bound to the current callback handle.
Definition at line 556 of file callback.hpp.
|
inlinestaticprivate |
空回调句柄共用的静态空执行块。Shared static empty execution block used by empty callback handles.
Definition at line 467 of file callback.hpp.
|
staticconstexprprivate |
是否是回调接口允许的 payload 参数写法 / Whether one payload argument form is accepted by this callback interface
| T | 待判断的参数类型 / Argument type to inspect 是否是这个回调接口允许的负载参数写法。Whether this callback interface accepts this payload argument form. |
Definition at line 122 of file callback.hpp.
|
staticconstexprprivate |
是否为带时间戳的类型化消息视图参数 / Whether one callback payload argument is a timestamped typed message view
| T | 待判断的参数类型 / Argument type to inspect 是否为带时间戳的类型化消息视图参数。Whether the argument is a timestamped typed message view. |
Definition at line 90 of file callback.hpp.
|
staticconstexprprivate |
是否错误地使用了可变 MessageView<T>& / Whether one payload argument is an invalid mutable MessageView<T>&
| T | 待判断的参数类型 / Argument type to inspect |
Definition at line 133 of file callback.hpp.
|
staticconstexprprivate |
是否为只读 raw payload 视图参数 / Whether one callback payload argument is a read-only raw payload view
| T | 待判断的参数类型 / Argument type to inspect |
Definition at line 101 of file callback.hpp.
|
staticconstexprprivate |
是否把 payload 直接当成一个对象接收 / Whether one callback payload argument receives the payload directly as one object
| T | 待判断的参数类型 / Argument type to inspect 是否把负载直接当成一个对象来接收。Whether the payload is received directly as one typed object. |
Definition at line 110 of file callback.hpp.