Skip to content

Commit

Permalink
Add a pimpl inside rclcpp::Node for future distro backports (ros2#2228)
Browse files Browse the repository at this point in the history
* Add a pimpl inside rclcpp::Node for future distro backports

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
  • Loading branch information
2 people authored and Barry-Xu-2018 committed Jan 12, 2024
1 parent 6a0682f commit 9f89315
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions rclcpp/include/rclcpp/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,12 @@ class Node : public std::enable_shared_from_this<Node>
const rclcpp::NodeOptions node_options_;
const std::string sub_namespace_;
const std::string effective_namespace_;

class NodeImpl;
// This member is meant to be a place to backport features into stable distributions,
// and new features targeting Rolling should not use this.
// See the comment in node.cpp for more information.
std::shared_ptr<NodeImpl> hidden_impl_{nullptr};
};

} // namespace rclcpp
Expand Down
19 changes: 18 additions & 1 deletion rclcpp/src/rclcpp/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ create_effective_namespace(const std::string & node_namespace, const std::string

} // namespace

/// Internal implementation to provide hidden and API/ABI stable changes to the Node.
/**
* This class is intended to be an "escape hatch" within a stable distribution, so that certain
* smaller features and bugfixes can be backported, having a place to put new members, while
* maintaining the ABI.
*
* This is not intended to be a parking place for new features, it should be used for backports
* only, left empty and unallocated in Rolling.
*/
class Node::NodeImpl
{
public:
NodeImpl() = default;
~NodeImpl() = default;
};

Node::Node(
const std::string & node_name,
const NodeOptions & options)
Expand Down Expand Up @@ -260,7 +276,8 @@ Node::Node(
node_waitables_(other.node_waitables_),
node_options_(other.node_options_),
sub_namespace_(extend_sub_namespace(other.get_sub_namespace(), sub_namespace)),
effective_namespace_(create_effective_namespace(other.get_namespace(), sub_namespace_))
effective_namespace_(create_effective_namespace(other.get_namespace(), sub_namespace_)),
hidden_impl_(other.hidden_impl_)
{
// Validate new effective namespace.
int validation_result;
Expand Down

0 comments on commit 9f89315

Please sign in to comment.