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

Iox #14 custom header for untyped C++ and C API #649

Merged

Conversation

elBoberido
Copy link
Member

@elBoberido elBoberido commented Mar 29, 2021

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Branch follows the naming format (iox-#123-this-is-a-branch)
  4. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  5. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  6. Relevant issues are linked
  7. Add sensible notes for the reviewer
  8. All checks have passed (except task-list-completed)
  9. Assign PR to reviewer

Notes for Reviewer

This PR adds the custom header support to the C++ an C API and refactors the c++2c enum translation tests in order to discover missing enum values on the C side more easily.

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@codecov
Copy link

codecov bot commented Mar 29, 2021

Codecov Report

Merging #649 (51102fc) into master (948d02a) will decrease coverage by 0.01%.
The diff coverage is 73.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #649      +/-   ##
==========================================
- Coverage   73.90%   73.89%   -0.02%     
==========================================
  Files         318      318              
  Lines       11077    11106      +29     
  Branches     1950     1955       +5     
==========================================
+ Hits         8187     8207      +20     
- Misses       2127     2130       +3     
- Partials      763      769       +6     
Flag Coverage Δ
unittests 73.85% <73.17%> (-0.02%) ⬇️
unittests_timing 31.55% <0.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ude/iceoryx_binding_c/internal/cpp2c_publisher.hpp 100.00% <ø> (ø)
...osh/internal/popo/building_blocks/chunk_sender.hpp 100.00% <ø> (ø)
...sh/include/iceoryx_posh/popo/untyped_publisher.hpp 100.00% <ø> (ø)
iceoryx_binding_c/source/c_listener.cpp 73.07% <40.00%> (+3.51%) ⬆️
iceoryx_binding_c/source/c_publisher.cpp 60.00% <57.14%> (+0.67%) ⬆️
iceoryx_binding_c/source/c_subscriber.cpp 61.40% <66.66%> (+2.14%) ⬆️
iceoryx_binding_c/source/c_wait_set.cpp 81.57% <66.66%> (+1.57%) ⬆️
iceoryx_binding_c/source/c_user_trigger.cpp 100.00% <100.00%> (ø)
...ceoryx_binding_c/source/cpp2c_enum_translation.cpp 100.00% <100.00%> (ø)
...osh/internal/popo/building_blocks/chunk_sender.inl 96.77% <100.00%> (+3.22%) ⬆️
... and 6 more

iceoryx_binding_c/include/iceoryx_binding_c/publisher.h Outdated Show resolved Hide resolved
iceoryx_binding_c/source/c_publisher.cpp Outdated Show resolved Hide resolved
iceoryx_binding_c/test/moduletests/test_publisher.cpp Outdated Show resolved Hide resolved
template <typename base_publisher_t>
inline UntypedPublisherImpl<base_publisher_t>::UntypedPublisherImpl(const capro::ServiceDescription& service,
const PublisherOptions& publisherOptions)
template <typename H, typename base_publisher_t>
Copy link
Contributor

Choose a reason for hiding this comment

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

HeaderType or Header_t? I think we're really inconsistent with naming template params, makes reading harder 😞

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just H to be consistent with the typed API. There was already a T template parameter and then I added the H one

Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the template param in the typed API, too. Same goes for the base_publisher_t. I think in iceoryx most of the time we use FooType.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change base_publisher_t (in a separate PR together with the typed API) but would keep the H.

Copy link
Contributor

Choose a reason for hiding this comment

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

I vote for short dummy variables in the inl, they do not have to be the same as in the hpp (readability). In fact, if they are not used even typename is enough. We need a convention for those _t suffixes but IMO they should not be used in template parameters.

@@ -273,7 +273,8 @@ class MyChunkHeaderHook : public ChunkHeaderHook
auto customHeaderHook = MyChunkHeaderHook<MyHeader>();
auto pub = iox::popo::Publisher<MyPayload>(serviceDescription, customHeaderHook);
```
- it has to be decided if it's a good idea to give the user easy write access to the `ChunkHeader` or just to the `CustomHeader`
- alternatively, instead of the ChunkHeaderHook class, the publisher could have a method `registerDeliveryHook(std::function<void(ChunkHeader&)>)`
- allow the user only read access to the `ChunkHeader` and write access to the `CustomHeader`
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to think about the access options for the header, true. std::function cannot be used in the long run, however. Maybe cxx::function will be sufficient but it is a bit problematic for unrestricted user callbacks due to its size bound.

Copy link
Member Author

Choose a reason for hiding this comment

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

an option would be plain C function pointer but then we would make it harder to use. I also thought about cxx::function, which would replace the std::function when it's ready. The API with the std::function would be marked as deprecated.

iceoryx_binding_c/include/iceoryx_binding_c/publisher.h Outdated Show resolved Hide resolved
iceoryx_binding_c/include/iceoryx_binding_c/publisher.h Outdated Show resolved Hide resolved
iceoryx_binding_c/source/c_publisher.cpp Outdated Show resolved Hide resolved
template <typename base_publisher_t>
inline UntypedPublisherImpl<base_publisher_t>::UntypedPublisherImpl(const capro::ServiceDescription& service,
const PublisherOptions& publisherOptions)
template <typename H, typename base_publisher_t>
Copy link
Contributor

Choose a reason for hiding this comment

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

I vote for short dummy variables in the inl, they do not have to be the same as in the hpp (readability). In fact, if they are not used even typename is enough. We need a convention for those _t suffixes but IMO they should not be used in template parameters.

@elBoberido elBoberido force-pushed the iox-#14-custom-header-for-untyped-API branch from 2c0371e to 67716d3 Compare March 29, 2021 18:45
@elBoberido elBoberido merged commit 45a3f41 into eclipse-iceoryx:master Mar 30, 2021
@elBoberido elBoberido deleted the iox-#14-custom-header-for-untyped-API branch March 30, 2021 09:52
marthtz pushed a commit to boschglobal/iceoryx that referenced this pull request May 12, 2021
…der-for-untyped-API

Iox eclipse-iceoryx#14 custom header for untyped C++ and C API
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.

Reserved chunkinfo user payload header
4 participants