Skip to content

Add support for passing arguments to constructors#223

Open
pum1k wants to merge 3 commits intoros:rollingfrom
pum1k:rolling
Open

Add support for passing arguments to constructors#223
pum1k wants to merge 3 commits intoros:rollingfrom
pum1k:rolling

Conversation

@pum1k
Copy link

@pum1k pum1k commented Dec 17, 2025

This PR adds the ability to pass arguments to constructors of the derived classes. As a result, users can now create plugins that are not default constructible, removing the need for initialize method.

To achieve this, a new customization point was added: template struct InterfaceTraits. Specializing this struct allows users to define signature of the constructors that will be required by the derived classes.

If users do not specialize this structure, default constructor is assumed and there are no changes to the behavior.

- added InterfaceTraits type trait that can be used to define the
  constructor arguments used by the derived classes
- changed class loaders to pass arguments to the derived classes based
  on the information stored in InterfaceTraits

Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
@pum1k
Copy link
Author

pum1k commented Jan 29, 2026

Hi @ahcorde,
could you, please, review this PR and merge it if it is ok? I don't know who to ask, so i found you on other PRs. Sorry for the ping if you are not the right person to ask.

@ahcorde ahcorde self-requested a review February 5, 2026 11:35
@ahcorde
Copy link
Contributor

ahcorde commented Feb 5, 2026

Pulls: #223
Gist: https://gist.githubusercontent.com/ahcorde/2ac0c58c497edec9c4feac045a457731/raw/a0614acd74a344d977449d35533388fef9da1a02/ros2.repos
BUILD args: --packages-above-and-dependencies class_loader
TEST args: --packages-above class_loader
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18135

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
@pum1k
Copy link
Author

pum1k commented Feb 6, 2026

The Linux-rhel failure should alredy be fixed. Windows issue looks like a compiler bug in template deduction. It should be fixable with a slight change in the implementation.

Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
@pum1k
Copy link
Author

pum1k commented Feb 6, 2026

The MSVC problem should also be fixed now.

@ahcorde
Copy link
Contributor

ahcorde commented Feb 6, 2026

Pulls: #223
Gist: https://gist.githubusercontent.com/ahcorde/e7e87da95786dcd916c7761dad0bb56f/raw/a0614acd74a344d977449d35533388fef9da1a02/ros2.repos
BUILD args: --packages-above-and-dependencies class_loader
TEST args: --packages-above class_loader
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18142

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

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