diff --git a/rclcpp/include/rclcpp/node_interfaces/node_graph.hpp b/rclcpp/include/rclcpp/node_interfaces/node_graph.hpp index ff2d91b261..90f9af6876 100644 --- a/rclcpp/include/rclcpp/node_interfaces/node_graph.hpp +++ b/rclcpp/include/rclcpp/node_interfaces/node_graph.hpp @@ -85,6 +85,18 @@ class NodeGraph : public NodeGraphInterface size_t count_subscribers(const std::string & topic_name) const override; + RCLCPP_PUBLIC + std::vector + get_publishers_info_by_topic( + const std::string & topic_name, + bool no_demangle = false) const override; + + RCLCPP_PUBLIC + std::vector + get_subscriptions_info_by_topic( + const std::string & topic_name, + bool no_demangle = false) const override; + RCLCPP_PUBLIC const rcl_guard_condition_t * diff --git a/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp b/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp index 022984dd47..b30fa9599c 100644 --- a/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp +++ b/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp @@ -22,6 +22,7 @@ #include #include "rcl/guard_condition.h" +#include "rmw/topic_endpoint_info.h" #include "rclcpp/event.hpp" #include "rclcpp/macros.hpp" @@ -89,6 +90,22 @@ class NodeGraphInterface size_t count_subscribers(const std::string & topic_name) const = 0; + /// Return a vector of publisher infos publishing to a given topic. + RCLCPP_PUBLIC + virtual + std::vector + get_publishers_info_by_topic( + const std::string & topic_name, + bool no_demangle = false) const = 0; + + /// Return a vector of subscription infos publishing to a given topic. + RCLCPP_PUBLIC + virtual + std::vector + get_subscriptions_info_by_topic( + const std::string & topic_name, + bool no_demangle = false) const = 0; + /// Return the rcl guard condition which is triggered when the ROS graph changes. RCLCPP_PUBLIC virtual diff --git a/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp b/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp index 11347881b3..afecb4c59d 100644 --- a/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp +++ b/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp @@ -266,6 +266,22 @@ NodeGraph::count_subscribers(const std::string & topic_name) const return count; } +std::vector +NodeGraph::get_publishers_info_by_topic( + const std::string & /*topic_name*/, + bool /*no_demangle*/) const +{ + return std::vector(); +} + +std::vector +NodeGraph::get_subscriptions_info_by_topic( + const std::string & /*topic_name*/, + bool /*no_demangle*/) const +{ + return std::vector(); +} + const rcl_guard_condition_t * NodeGraph::get_graph_guard_condition() const {