RMVL  2.5.0-dev
Robotic Manipulation and Vision Library
载入中...
搜索中...
未找到
rm::lpss::Node类 参考

轻量级发布订阅服务节点 更多...

#include <rmvl/lpss/node.hpp>

rm::lpss::Node 的协作图:

Public 成员函数

 Node (std::string_view name, uint8_t domain_id=0)
 创建通用节点,默认域 ID 为 0
 ~Node () noexcept
Guid guid () const noexcept
 获取节点唯一标识符
template<typename MsgType>
Publisher< MsgType > 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 > createSubscriber (std::string_view topic, SubscribeMsgCallback &&callback) noexcept
 创建订阅者
template<typename MsgType>
void destroyPublisher (Publisher< MsgType > &pub)
 销毁发布者
template<typename MsgType>
void destroySubscriber (Subscriber< MsgType > &sub)
 销毁订阅者
void shutdown () noexcept
 手动停止节点运行

Protected 属性

std::shared_mutex _nodes_mtx {}
 节点读写锁
std::unordered_map< Guid, NodeStorageInfo, GuidHash > _discovered_nodes {}
 已发现的节点列表
std::shared_mutex _local_mtx {}
 本地实体读写锁
std::unordered_map< std::string, DataWriterBase::ptr > _local_writers {}
 已注册的 Writers 列表
std::unordered_map< std::string, DataReaderBase::ptr > _local_readers {}
 已注册的 Readers 列表
std::shared_mutex _discovered_mtx {}
 已发现实体读写锁
std::unordered_map< std::string, DiscoveredWriterStorageInfo > _discovered_writers {}
 已发现的 Writers 列表
std::unordered_map< std::string, DiscoveredReaderStorageInfo > _discovered_readers {}
 已发现的 Readers 列表

详细描述

轻量级发布订阅服务节点

  • 内置节点发现协议 NDP (Node Discovery Protocol),用于节点间的自动发现与通信
  • 内置通信端点发现协议 EDP (Endpoint Discovery Protocol),用于发布者与订阅者间的自动发现与通信
    参见
    详情见 轻量发布订阅服务 —— LPSS

构造及析构函数说明

◆ Node()

rm::lpss::Node::Node ( std::string_view name,
uint8_t domain_id = 0 )
explicit

创建通用节点,默认域 ID 为 0

参数
[in]name节点名称
[in]domain_id域 ID

◆ ~Node()

rm::lpss::Node::~Node ( )
inlinenoexcept
函数调用图:

成员函数说明

◆ createPublisher()

template<typename MsgType>
Publisher< MsgType > rm::lpss::Node::createPublisher ( std::string_view topic)
noexcept

创建发布者

模板参数
MsgType消息类型
参数
[in]topic话题名称
返回
Publisher<MsgType> 发布者对象

◆ createSubscriber()

template<typename MsgType, typename SubscribeMsgCallback, typename = std::enable_if_t<std::is_invocable_v<SubscribeMsgCallback, const MsgType &>>>
Subscriber< MsgType > rm::lpss::Node::createSubscriber ( std::string_view topic,
SubscribeMsgCallback && callback )
noexcept

创建订阅者

模板参数
MsgType消息类型
SubscribeMsgCallback订阅回调函数类型
参数
[in]topic话题名称
[in]callback订阅回调函数
返回
Subscriber<MsgType> 订阅者对象

◆ destroyPublisher()

template<typename MsgType>
void rm::lpss::Node::destroyPublisher ( Publisher< MsgType > & pub)

销毁发布者

模板参数
MsgType消息类型
参数
[in]pub发布者对象

◆ destroySubscriber()

template<typename MsgType>
void rm::lpss::Node::destroySubscriber ( Subscriber< MsgType > & sub)

销毁订阅者

模板参数
MsgType消息类型
参数
[in]sub订阅者对象

◆ guid()

Guid rm::lpss::Node::guid ( ) const
inlinenoexcept

获取节点唯一标识符

◆ shutdown()

void rm::lpss::Node::shutdown ( )
noexcept

手动停止节点运行

注解
推荐使用析构函数自动清理资源并停止节点,除非在多线程环境中需要提前停止节点以释放资源

类成员变量说明

◆ _discovered_mtx

std::shared_mutex rm::lpss::Node::_discovered_mtx {}
protected

已发现实体读写锁

◆ _discovered_nodes

std::unordered_map<Guid, NodeStorageInfo, GuidHash> rm::lpss::Node::_discovered_nodes {}
protected

已发现的节点列表

◆ _discovered_readers

std::unordered_map<std::string, DiscoveredReaderStorageInfo> rm::lpss::Node::_discovered_readers {}
protected

已发现的 Readers 列表

◆ _discovered_writers

std::unordered_map<std::string, DiscoveredWriterStorageInfo> rm::lpss::Node::_discovered_writers {}
protected

已发现的 Writers 列表

◆ _local_mtx

std::shared_mutex rm::lpss::Node::_local_mtx {}
protected

本地实体读写锁

◆ _local_readers

std::unordered_map<std::string, DataReaderBase::ptr> rm::lpss::Node::_local_readers {}
protected

已注册的 Readers 列表

◆ _local_writers

std::unordered_map<std::string, DataWriterBase::ptr> rm::lpss::Node::_local_writers {}
protected

已注册的 Writers 列表

◆ _nodes_mtx

std::shared_mutex rm::lpss::Node::_nodes_mtx {}
protected

节点读写锁