每次发布时直接执行函数的订阅句柄 / Subscription handle that runs a function on each publish
More...
#include <callback.hpp>
|
|
| 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
|
| |
|
| template<typename BoundArg , typename Callable > |
| static Callback | Create (Callable fun, BoundArg arg) |
| | 创建一个回调订阅句柄 / Create a callback subscription handle
|
| |
每次发布时直接执行函数的订阅句柄 / 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.
◆ Callback()
| LibXR::Topic::Callback::Callback |
( |
const Callback & | other | ) |
|
|
default |
拷贝构造回调句柄 / Copy-construct one callback handle
- Parameters
-
| other | 被拷贝的回调句柄 / Callback handle to copy from |
- Note
- 这里只复制句柄本身,不复制底层回调块;两个句柄会指向同一块回调数据 / This copies only the handle itself, not the underlying callback block; both handles point to the same callback data block
◆ Create()
template<typename BoundArg , typename Callable >
| static Callback LibXR::Topic::Callback::Create |
( |
Callable | fun, |
|
|
BoundArg | arg ) |
|
inlinestaticnodiscard |
创建一个回调订阅句柄 / Create a callback subscription handle
- Template Parameters
-
| BoundArg | 绑定参数类型 / Bound argument type |
| Callable | 回调可调用对象类型 / Callback callable type |
- Parameters
-
| fun | 捕获为空的回调函数 / Capture-free callback function |
| arg | 绑定到回调的参数 / Argument bound into the callback |
- Returns
- 创建后的回调订阅句柄 / Returns the created callback subscription handle
- Note
- 这里会把
arg 拷进新分配的回调块里;之后回调执行读写的就是这份块内副本 / This copies arg into the newly allocated callback block; later callback execution reads or writes that stored copy
Definition at line 519 of file callback.hpp.
520 {
521 using Function = decltype(+std::declval<Callable>());
522 using Traits = FunctionTraits<Function>;
523 static_assert(Traits::ARITY == 3 || Traits::ARITY == 4,
524 "LibXR::Topic::Callback::Create expects a capture-free callable "
525 "with bool and bound-argument parameters.");
527 Factory<Function, BoundArg, Traits::ARITY>::Create(+fun, std::move(arg)));
528 }
Callback()=default
构造一个空回调句柄 / Construct one empty callback handle
◆ IsRawPayloadView()
| bool LibXR::Topic::Callback::IsRawPayloadView |
( |
| ) |
const |
|
inline |
判断该回调是否按 raw payload 视图接收消息 / Tell whether this callback receives messages as a raw payload view
- Returns
- 是 raw payload 视图回调则返回 true / Returns true for raw payload view callbacks
Definition at line 556 of file callback.hpp.
556{ return block_->accepts_raw_payload; }
◆ operator=()
拷贝赋值回调句柄 / Copy-assign one callback handle
- Parameters
-
| other | 被拷贝的回调句柄 / Callback handle to copy from |
- Returns
- 当前回调句柄 / Returns the current callback handle
- Note
- 这里只复制句柄本身,不复制底层回调块;赋值后两个句柄会指向同一块回调数据 / This copies only the handle itself, not the underlying callback block; after assignment both handles point to the same callback data block
◆ PayloadTypeID()
| TypeID::ID LibXR::Topic::Callback::PayloadTypeID |
( |
| ) |
const |
|
inline |
读取这个回调句柄期望的 payload 类型标识 / Read the payload type ID expected by this callback handle
- Returns
- payload 类型标识 / Payload type ID
Definition at line 548 of file callback.hpp.
548{ return block_->payload_type_id; }
◆ Run()
| void LibXR::Topic::Callback::Run |
( |
bool | in_isr, |
|
|
MicrosecondTimestamp | timestamp, |
|
|
void * | payload_addr, |
|
|
size_t | payload_size ) const |
|
inline |
执行回调 / Run the callback
- Parameters
-
| 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 537 of file callback.hpp.
539 {
540 block_->run(block_, in_isr, timestamp, payload_addr, payload_size);
541 }
The documentation for this class was generated from the following file: