轻量级发布订阅服务节点
更多...
#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 > | 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 |
| | 手动停止节点运行
|
◆ 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 |
◆ 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 | ) |
|
◆ destroySubscriber()
template<typename MsgType>
| void rm::lpss::Node::destroySubscriber |
( |
Subscriber< MsgType > & | 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 |
◆ _discovered_writers
| std::unordered_map<std::string, DiscoveredWriterStorageInfo> rm::lpss::Node::_discovered_writers {} |
|
protected |
◆ _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 |
◆ _local_writers
| std::unordered_map<std::string, DataWriterBase::ptr> rm::lpss::Node::_local_writers {} |
|
protected |
◆ _nodes_mtx
| std::shared_mutex rm::lpss::Node::_nodes_mtx {} |
|
protected |