[20543] Examples refactor: Hello World#4547
Conversation
48f5bad to
bb375a4
Compare
c366a69 to
6f2a1e0
Compare
7af5a31 to
d73f963
Compare
6f2a1e0 to
c6e0741
Compare
d73f963 to
2dc171a
Compare
3cd6aa0 to
30317aa
Compare
813cb7d to
fe33b04
Compare
EduPonz
left a comment
There was a problem hiding this comment.
We're definitely getting there! I like the idea of the classes not having any static members.
Now, I have a "crazy" idea to simplify the main and to also group some of the subscribers' code. Right now, all three entities have similar public API:
- A ctor
- A
runmember function with no args - A
stopmember function with no args
We can do some hierarchy of classes:
classDiagram
class Entity {
+run() void
+stop() void
+create_entity(const hello_world_config& config)$ std::shared_ptr~Entity~
}
Entity <|-- Publisher
Entity <|-- AbstractSubscriber : Optional grouping of subscriber code
AbstractSubscriber <|-- Subscriber
AbstractSubscriber <|-- WaitSubscriber
Entity ..> Publisher : creates
Entity ..> Subscriber : creates
Entity ..> WaitSubscriber : creates
We would have a base class for the entities which can also act as a factory of the specializations via an static method. This way you don't need all those pointers, just the one, nor do you need any switches. You'd just create the entity passing the config and then spawn the thread to run it's run method. Since the entity is a shared_ptr, you wouldn't need to delete it either. You can see a PoC here.
(NIT) Apart from the internally agreed things I would call the creation method (or global free function) |
b2a2839 to
5064ab8
Compare
EduPonz
left a comment
There was a problem hiding this comment.
This is turning out nicely, great job! 🤖
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> Refs #20543: Fix installation path Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> A Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Description
This PR should be merge right after:
This PR is the first of a suite of PR which would make a refactor in the repository examples.
It is intended to apply to most of the examples, by making them homogeneous, more understandable, and more specific to the case they were meant to be.
In this hello world example, the key changes are:
The following changes apply to this and the remain examples:
Contributor Checklist
versions.mdfile (if applicable).Reviewer Checklist