-
Notifications
You must be signed in to change notification settings - Fork 402
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 1640 create polymorphic singleton abstraction #1656
Iox 1640 create polymorphic singleton abstraction #1656
Conversation
I need to port the clang format CI fix from the other PR to this one. The other PR will likely not be merged soon, but @elBoberido proposed how to build a singleton manager on top as well to solve the singleton destruction order problem. This will become important for posh and hopefully be a useful building block. The current PR is for error handling and logging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please
- use include guards instead of pragma once
- add the copyright header
- move implementation into inl file
- use noexcept on every method
- do not use
std::cerr
, use Logger instead - do not use
std::terminate
, usecxx::Ensures
instead
@elfenpiff The restructuring will be done. However, we should not have the default implementation depend on logger or later error handler. We could have empty default behavior instead of terminate, the hook is supposed to be set somehow by the concrete logger or error handler. Some methods can be |
Codecov Report
@@ Coverage Diff @@
## master #1656 +/- ##
==========================================
+ Coverage 75.42% 75.49% +0.07%
==========================================
Files 377 379 +2
Lines 14619 14693 +74
Branches 2084 2098 +14
==========================================
+ Hits 11026 11093 +67
Misses 2961 2961
- Partials 632 639 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Refactored and added some commits of @dkroenke to update clang-format. |
c57627f
to
7aab2d3
Compare
I made all methods I am still not sure how Axivion treats this. I think if it cannot prove that everything is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick first review
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
01574c5
to
2b80ab6
Compare
@elBoberido I adressed the following issues.
This introduces complexity in the implementation but I think they are useful buildings blocks for recurring problems. I placed them in |
Signed-off-by: Matthias Killat <[email protected]>
a71a290
to
ed0b134
Compare
…uction Signed-off-by: Matthias Killat <[email protected]>
ed0b134
to
b35cb02
Compare
iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/static_lifetime_guard.hpp
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/static_lifetime_guard.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/polymorphic_handler.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is now in good condition as far as the functionality is concerned but I'm a bit skeptical about the API. Unfortunately I don't have a better alternative.
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/static_lifetime_guard.inl
Outdated
Show resolved
Hide resolved
@elBoberido I am not perfectly happy with the API either, but probably in other ways than you. The guards are good internally but using them in the API limits functionality in ways I did not want initially (partly related to the Nevertheless it solves a problem in a useful way and we can build on that, e.g. I will for error handler exchange. |
a4f42dc
to
0fba4ac
Compare
Signed-off-by: Matthias Killat <[email protected]>
0fba4ac
to
4c259b9
Compare
@@ -39,7 +38,8 @@ struct DefaultHooks | |||
/// @brief called if the polymorphic handler is set or reset after finalize | |||
/// @param currentInstance the current instance of the handler singleton | |||
/// @param newInstance the instance of the handler singleton to be set | |||
static void onSetAfterFinalize(Interface& currentInstance, Interface& newInstance) noexcept; | |||
/// @note calls terminate and does not return | |||
[[noreturn]] static void onSetAfterFinalize(Interface& currentInstance, Interface& newInstance) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this does not restrict other hooks to define a non-noreturn method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it does not and should not. It is not mandatory for any hook. It is just plugged in as a template argument type ...
However, it is a guarantee the DefaultHooks are able to give and so they should. Can remove it, but would advise not to. This allows optimization and communicates intent. And is portable in C++11.
iceoryx_hoofs/include/iceoryx_hoofs/internal/design_pattern/polymorphic_handler.inl
Outdated
Show resolved
Hide resolved
Signed-off-by: Matthias Killat <[email protected]>
Pre-Review Checklist for the PR Author
iox-123-this-is-a-branch
)iox-#123 commit text
)git commit -s
)task-list-completed
)iceoryx_hoofs
are added to./clang-tidy-diff-scans.txt
Notes for Reviewer
refer to https://github.com/eclipse-iceoryx/iceoryx/pull/1656/files#diff-b342f851e544aab4457e99291a6b66baad23e941cfb95dbc4454bf08669dc356 for explanation of the functionality
Checklist for the PR Reviewer
iceoryx_hoofs
have been added to./clang-tidy-diff-scans.txt
Post-review Checklist for the PR Author
References