轻量级发布订阅服务异步节点
更多...
#include <rmvl/lpss/node.hpp>
|
| | Node (std::string_view name, uint8_t domain_id=0) |
| | 创建通用节点,默认域 ID 为 0
|
| | ~Node () noexcept |
| Guid | guid () const noexcept |
| | 获取节点唯一标识符
|
| template<typename MsgType> |
| Publisher< MsgType >::ptr | createPublisher (std::string_view topic) noexcept |
| | 创建发布者
|
| template<typename MsgType, typename SubscribeMsgCallback, typename = std::enable_if_t<std::is_invocable_v<SubscribeMsgCallback, const MsgType &>>> |
| Subscriber< MsgType >::ptr | createSubscriber (std::string_view topic, SubscribeMsgCallback callback) noexcept |
| | 创建订阅者
|
| template<typename MsgType> |
| void | destroyPublisher (typename Publisher< MsgType >::ptr pub) |
| | 销毁发布者
|
| template<typename MsgType> |
| void | destroySubscriber (typename Subscriber< MsgType >::ptr sub) |
| | 销毁订阅者
|
| template<typename Rep, typename Period, typename TimerCallback> |
| Timer::ptr | createTimer (std::chrono::duration< Rep, Period > dur, TimerCallback callback) noexcept |
| | 创建异步定时器
|
| void | spin () |
| | 运行异步 IO 上下文
|
| void | shutdown () noexcept |
| | 手动停止节点运行
|
◆ Node()
| rm::lpss::async::Node::Node |
( |
std::string_view | name, |
|
|
uint8_t | domain_id = 0 ) |
|
explicit |
创建通用节点,默认域 ID 为 0
- 参数
-
| [in] | name | 节点名称 |
| [in] | domain_id | 域 ID |
◆ ~Node()
| rm::lpss::async::Node::~Node |
( |
| ) |
|
|
inlinenoexcept |
◆ createPublisher()
template<typename MsgType>
| Publisher< MsgType >::ptr rm::lpss::async::Node::createPublisher |
( |
std::string_view | topic | ) |
|
|
noexcept |
创建发布者
- 模板参数
-
- 参数
-
- 返回
- 发布者对象的智能指针
◆ createSubscriber()
template<typename MsgType, typename SubscribeMsgCallback, typename = std::enable_if_t<std::is_invocable_v<SubscribeMsgCallback, const MsgType &>>>
| Subscriber< MsgType >::ptr rm::lpss::async::Node::createSubscriber |
( |
std::string_view | topic, |
|
|
SubscribeMsgCallback | callback ) |
|
noexcept |
创建订阅者
- 模板参数
-
| MsgType | 消息类型 |
| SubscribeMsgCallback | 订阅回调函数类型 |
- 参数
-
| [in] | topic | 话题名称 |
| [in] | callback | 订阅回调函数 |
- 返回
- 订阅者对象的智能指针
◆ createTimer()
template<typename Rep, typename Period, typename TimerCallback>
| Timer::ptr rm::lpss::async::Node::createTimer |
( |
std::chrono::duration< Rep, Period > | dur, |
|
|
TimerCallback | callback ) |
|
noexcept |
创建异步定时器
- 模板参数
-
| Rep | 定时器时间间隔的表示类型 |
| Period | 定时器时间间隔的周期类型 |
| TimerCallback | 定时器回调函数类型 |
- 参数
-
| [in] | dur | 定时器时间间隔 |
| [in] | callback | 定时器回调函数 |
- 返回
- 定时器对象的智能指针
◆ destroyPublisher()
template<typename MsgType>
| void rm::lpss::async::Node::destroyPublisher |
( |
typename Publisher< MsgType >::ptr | pub | ) |
|
◆ destroySubscriber()
template<typename MsgType>
| void rm::lpss::async::Node::destroySubscriber |
( |
typename Subscriber< MsgType >::ptr | sub | ) |
|
◆ guid()
| Guid rm::lpss::async::Node::guid |
( |
| ) |
const |
|
inlinenoexcept |
◆ shutdown()
| void rm::lpss::async::Node::shutdown |
( |
| ) |
|
|
noexcept |
手动停止节点运行
- 注解
- 推荐使用析构函数自动清理资源并停止节点,除非在多线程环境中需要提前停止节点以释放资源
◆ spin()
| void rm::lpss::async::Node::spin |
( |
| ) |
|
|
inline |
◆ _ctx
◆ _discovered_nodes
| std::unordered_map<Guid, NodeStorageInfo, GuidHash> rm::lpss::async::Node::_discovered_nodes {} |
|
protected |
◆ _discovered_readers
| std::unordered_map<std::string, DiscoveredReaderStorageInfo> rm::lpss::async::Node::_discovered_readers {} |
|
protected |
◆ _discovered_writers
| std::unordered_map<std::string, DiscoveredWriterStorageInfo> rm::lpss::async::Node::_discovered_writers {} |
|
protected |
◆ _local_readers
| std::unordered_map<std::string, DataReaderBase::ptr> rm::lpss::async::Node::_local_readers {} |
|
protected |
◆ _local_writers
| std::unordered_map<std::string, DataWriterBase::ptr> rm::lpss::async::Node::_local_writers {} |
|
protected |