Skip to content

Commit

Permalink
Added dockblock to ComponentManager class (ros2#1102)
Browse files Browse the repository at this point in the history
* Added dockblock to ComponentManager class

Signed-off-by: ahcorde <ahcorde@gmail.com>

* added feedback

Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde authored and Joshua Hampp committed Jul 7, 2020
1 parent 63e6d43 commit bdd88a3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions rclcpp_components/include/rclcpp_components/component_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ class ClassLoader;
namespace rclcpp_components
{

/// Thrown when an error happens in the component Manager class.
class ComponentManagerException : public std::runtime_error
{
public:
explicit ComponentManagerException(const std::string & error_desc)
: std::runtime_error(error_desc) {}
};

/// ComponentManager handles the services to load, unload, and get the list of loaded components.
class ComponentManager : public rclcpp::Node
{
public:
Expand All @@ -60,6 +62,15 @@ class ComponentManager : public rclcpp::Node
*/
using ComponentResource = std::pair<std::string, std::string>;

/// Default constructor
/**
* Initializes the component manager. It creates the services: load node, unload node
* and list nodes.
*
* \param executor the executor which will spin the node.
* \param node_name the name of the node that the data originates from.
* \param node_options additional options to control creation of the node.
*/
RCLCPP_COMPONENTS_PUBLIC
ComponentManager(
std::weak_ptr<rclcpp::Executor> executor,
Expand All @@ -70,31 +81,70 @@ class ComponentManager : public rclcpp::Node
virtual ~ComponentManager();

/// Return a list of valid loadable components in a given package.
/*
* \param package_name name of the package
* \param resource_index name of the executable
* \throws ComponentManagerException if the resource was not found or a invalid resource entry
* \return a list of component resources
*/
RCLCPP_COMPONENTS_PUBLIC
virtual std::vector<ComponentResource>
get_component_resources(
const std::string & package_name,
const std::string & resource_index = "rclcpp_components") const;

/// Instantiate a component from a dynamic library.
/*
* \param resource a component resource (class name + library path)
* \return a NodeFactory interface
*/
RCLCPP_COMPONENTS_PUBLIC
virtual std::shared_ptr<rclcpp_components::NodeFactory>
create_component_factory(const ComponentResource & resource);

protected:
/// Service callback to load a new node in the component
/*
* This function allows to add parameters, remap rules, a specific node, name a namespace
* and/or additional arguments.
*
* \param request_header unused
* \param request information with the node to load
* \param response
* \throws std::overflow_error if node_id suffers an overflow. Very unlikely to happen at 1 kHz
* (very optimistic rate). it would take 585 years.
* \throws ComponentManagerException In the case that the component constructor throws an
* exception, rethrow into the following catch block.
*/
RCLCPP_COMPONENTS_PUBLIC
virtual void
OnLoadNode(
const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<LoadNode::Request> request,
std::shared_ptr<LoadNode::Response> response);

/// Service callback to unload a node in the component
/*
* \param request_header unused
* \param request unique identifier to remove from the component
* \param response true on the success field if the node unload was succefully, otherwise false
* and the error_message field contains the error.
*/
RCLCPP_COMPONENTS_PUBLIC
virtual void
OnUnloadNode(
const std::shared_ptr<rmw_request_id_t> request_header,
const std::shared_ptr<UnloadNode::Request> request,
std::shared_ptr<UnloadNode::Response> response);

/// Service callback to get the list of nodes in the component
/*
* Return a two list: one with the unique identifiers and other with full name of the nodes.
*
* \param request_header unused
* \param request unused
* \param response list with the unique ids and full node names
*/
RCLCPP_COMPONENTS_PUBLIC
virtual void
OnListNodes(
Expand Down

0 comments on commit bdd88a3

Please sign in to comment.