Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compressor implementations into a plugin via pluginlib #624

Merged
merged 3 commits into from
Jan 30, 2021

Conversation

emersonknapp
Copy link
Collaborator

@emersonknapp emersonknapp commented Jan 29, 2021

Part of #598

This is incremental progress - the next step will be to create rosbag2_compression_zstd package and move the zstd implementation there.

Key point: Use the shared_ptr implementation of pluginlib::ClassLoader instead of either unmanagedInstance or uniqueInstance. The unique version has a custom deleter, meaning we would have to pass around a pluginlib::UniquePtr - requiring all uses to include the pluginlib headers, which seems a bit restrictive. The unmanaged instance means that pluginlib can't warn us if we destroy the loader before the instance - this can lead to segfaults on the SequentialReader/Writer destructors if the member variables compressor_ and compression_factory_ aren't declared in the right order (which they aren't in the current code). This makes the shared library the most desirable, as it allows pluginlib to clean up after itself while letting the rest of the code.

@emersonknapp emersonknapp marked this pull request as ready for review January 29, 2021 01:37
@emersonknapp emersonknapp requested a review from a team as a code owner January 29, 2021 01:37
@emersonknapp emersonknapp requested review from Karsten1987 and prajakta-gokhale and removed request for a team January 29, 2021 01:37
{
return c1 == c2 || std::tolower(c1) == std::tolower(c2);
}
static constexpr const char * name = "rosbag2_compression::BaseCompressorInterface";
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a difference between constexpr const char * name and constexpr const char name[]?

Copy link
Collaborator Author

@emersonknapp emersonknapp Jan 29, 2021

Choose a reason for hiding this comment

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

yes - the pointer and the array are different C++ types, though I don't understand the details well enough of how they act differently in this situation.

In practice - it builds as char * name, but not as char name[], like so

/usr/bin/ld: librosbag2_compression.so: undefined reference to `rosbag2_compression::CompressionTraits<rosbag2_compression::BaseCompressorInterface>::name'

Copy link

@prajakta-gokhale prajakta-gokhale left a comment

Choose a reason for hiding this comment

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

Left a couple nits, mostly looks good!

Emerson Knapp added 3 commits January 29, 2021 14:36
…properly in tests

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/zstd-plugin-in-same-package branch from 610d300 to 33685e9 Compare January 29, 2021 22:47
@emersonknapp
Copy link
Collaborator Author

Gist: https://gist.githubusercontent.com/emersonknapp/5de8ab86a0473449296fbc19dcf5e60f/raw/c1a41f3fe0dbd1cf61ab98919c12003f79f58659/ros2.repos
BUILD args: --packages-up-to rosbag2_compression rosbag2_tests
TEST args: --packages-select rosbag2_compression rosbag2_tests
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/7558

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@emersonknapp emersonknapp merged commit 0fa15a1 into master Jan 30, 2021
@delete-merged-branch delete-merged-branch bot deleted the emersonknapp/zstd-plugin-in-same-package branch January 30, 2021 00:22
emersonknapp added a commit that referenced this pull request Feb 2, 2021
Make compressor implementation into a plugin via pluginlib

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
emersonknapp added a commit that referenced this pull request Feb 17, 2021
Make compressor implementation into a plugin via pluginlib

Signed-off-by: Emerson Knapp <eknapp@amazon.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.

None yet

3 participants