ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
Public Member Functions | Protected Member Functions | List of all members
rclcpp::graph_listener::GraphListener Class Reference

Notifies many nodes of graph changes by listening in a thread. More...

#include <rclcpp/graph_listener.hpp>

Inheritance diagram for rclcpp::graph_listener::GraphListener:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::graph_listener::GraphListener:
Collaboration graph
[legend]

Public Member Functions

RCLCPP_PUBLIC GraphListener (const rclcpp::Context::SharedPtr &parent_context)
 
virtual RCLCPP_PUBLIC void start_if_not_started ()
 Start the graph listener's listen thread if it hasn't been started. More...
 
virtual RCLCPP_PUBLIC void add_node (rclcpp::node_interfaces::NodeGraphInterface *node_graph)
 Add a node to the graph listener's list of nodes. More...
 
virtual RCLCPP_PUBLIC bool has_node (rclcpp::node_interfaces::NodeGraphInterface *node_graph)
 Return true if the given node is in the graph listener's list of nodes. More...
 
virtual RCLCPP_PUBLIC void remove_node (rclcpp::node_interfaces::NodeGraphInterface *node_graph)
 Remove a node from the graph listener's list of nodes. More...
 
virtual RCLCPP_PUBLIC void shutdown ()
 Stop the listening thread. More...
 
virtual RCLCPP_PUBLIC void shutdown (const std::nothrow_t &) noexcept
 Nothrow version of shutdown(), logs to RCLCPP_ERROR instead.
 
virtual RCLCPP_PUBLIC bool is_shutdown ()
 Return true if shutdown() has been called, else false.
 

Protected Member Functions

virtual RCLCPP_PUBLIC void run ()
 Main function for the listening thread.
 
virtual RCLCPP_PUBLIC void run_loop ()
 
RCLCPP_PUBLIC void init_wait_set ()
 
RCLCPP_PUBLIC void cleanup_wait_set ()
 

Detailed Description

Notifies many nodes of graph changes by listening in a thread.

Definition at line 63 of file graph_listener.hpp.

Member Function Documentation

◆ add_node()

void rclcpp::graph_listener::GraphListener::add_node ( rclcpp::node_interfaces::NodeGraphInterface node_graph)
virtual

Add a node to the graph listener's list of nodes.

Exceptions
GraphListenerShutdownErrorif the GraphListener is shutdown
NodeAlreadyAddedErrorif the given node is already in the list
std::invalid_argumentif node is nullptr
std::system_erroranything std::mutex::lock() throws

Definition at line 254 of file graph_listener.cpp.

◆ has_node()

bool rclcpp::graph_listener::GraphListener::has_node ( rclcpp::node_interfaces::NodeGraphInterface node_graph)
virtual

Return true if the given node is in the graph listener's list of nodes.

Also return false if given nullptr.

Exceptions
std::system_erroranything std::mutex::lock() throws

Definition at line 237 of file graph_listener.cpp.

◆ remove_node()

void rclcpp::graph_listener::GraphListener::remove_node ( rclcpp::node_interfaces::NodeGraphInterface node_graph)
virtual

Remove a node from the graph listener's list of nodes.

Exceptions
NodeNotFoundErrorif the given node is not in the list
std::invalid_argumentif node is nullptr
std::system_erroranything std::mutex::lock() throws

Definition at line 299 of file graph_listener.cpp.

◆ shutdown()

void rclcpp::graph_listener::GraphListener::shutdown ( )
virtual

Stop the listening thread.

The thread cannot be restarted, and the class is defunct after calling. This function is called by the ~GraphListener() and does nothing if shutdown() was already called. This function exists separately from the ~GraphListener() so that it can be called before and exceptions can be caught.

If start_if_not_started() was never called, this function still succeeds, but start_if_not_started() still cannot be called after this function.

Exceptions
rclcpp::execptions::RCLErrorfrom rcl_guard_condition_fini()
rclcpp::execptions::RCLErrorfrom rcl_wait_set_fini()
std::system_erroranything std::mutex::lock() throws

Definition at line 346 of file graph_listener.cpp.

◆ start_if_not_started()

void rclcpp::graph_listener::GraphListener::start_if_not_started ( )
virtual

Start the graph listener's listen thread if it hasn't been started.

This function is thread-safe.

Exceptions
GraphListenerShutdownErrorif the GraphListener is shutdown
std::runtimeif the parent context was destroyed
anythingrclcpp::exceptions::throw_from_rcl_error can throw.

Definition at line 72 of file graph_listener.cpp.


The documentation for this class was generated from the following files: