Skip to content

refactor to use a std::tuple and be immutable#1

Merged
methylDragon merged 2 commits intomethylDragon:ch3/node-handlefrom
ros2:wjwwood/ch3/node-handle
Dec 14, 2022
Merged

refactor to use a std::tuple and be immutable#1
methylDragon merged 2 commits intomethylDragon:ch3/node-handlefrom
ros2:wjwwood/ch3/node-handle

Conversation

@wjwwood
Copy link

@wjwwood wjwwood commented Dec 13, 2022

@methylDragon and I discussed this off-line and I drafted the changes, at least in rclcpp.

I think there might be more changes needed in places it is used. Also, changes to LifecycleNode might be needed or no longer needed actually, but I didn't have time to check that. All the rclcpp tests pass atm at least.

Signed-off-by: William Woodall <william@osrfoundation.org>
Comment on lines +140 to +177
auto base = ni.get<NodeBaseInterface>();
base = ni.get_node_base_interface();
}
{
auto clock = ni.get<NodeClockInterface>();
clock = ni.get_node_clock_interface();
}
{
auto graph = ni.get<NodeGraphInterface>();
graph = ni.get_node_graph_interface();
}
{
auto logging = ni.get<NodeLoggingInterface>();
logging = ni.get_node_logging_interface();
}
{
auto timers = ni.get<NodeTimersInterface>();
timers = ni.get_node_timers_interface();
}
{
auto topics = ni.get<NodeTopicsInterface>();
topics = ni.get_node_topics_interface();
}
{
auto services = ni.get<NodeServicesInterface>();
services = ni.get_node_services_interface();
}
{
auto waitables = ni.get<NodeWaitablesInterface>();
waitables = ni.get_node_waitables_interface();
}
{
auto parameters = ni.get<NodeParametersInterface>();
parameters = ni.get_node_parameters_interface();
}
{
auto time_source = ni.get<NodeTimeSourceInterface>();
time_source = ni.get_node_time_source_interface();
Copy link
Owner

@methylDragon methylDragon Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should test the obtained interface for functionality in this test or a subsequent one, though I don't think we need to do it for every interface?

(e.g. calling the base interface's get_name)

0 != sizeof ...(InterfaceTs),
"must provide at least one interface as a template argument");
static_assert(
rclcpp::detail::template_unique_v<InterfaceTs ...>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the need for it now, but I'm leaving a note here for myself in the case that in the future, we want to allow users to aggregate multiple versions of the same interface type.

That is:
NodeInterfaces<NodeBaseInterface, NodeBaseInterface>(base_1, base_2);

We could potentially do it like a colliding hashmap (where we have a linked list or some other indexed sequence container stored in the tuple instead of the ptr to the interface)

Signed-off-by: methylDragon <methylDragon@gmail.com>
@methylDragon methylDragon merged commit 863d7a3 into methylDragon:ch3/node-handle Dec 14, 2022
@methylDragon methylDragon deleted the wjwwood/ch3/node-handle branch December 14, 2022 19:45
methylDragon added a commit that referenced this pull request Dec 14, 2022
Signed-off-by: methylDragon <methylDragon@gmail.com>
Co-authored-by: methylDragon <methylDragon@gmail.com>
methylDragon added a commit that referenced this pull request Dec 15, 2022
Signed-off-by: methylDragon <methylDragon@gmail.com>
Co-authored-by: methylDragon <methylDragon@gmail.com>
methylDragon added a commit that referenced this pull request Dec 28, 2022
Signed-off-by: methylDragon <methylDragon@gmail.com>
Co-authored-by: methylDragon <methylDragon@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants