-
Notifications
You must be signed in to change notification settings - Fork 181
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
[core] ported CMsgPublisher/Subscriber to v6 #1944
Conversation
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.
clang-tidy made some suggestions
serialization/protobuf/samples/pubsub/person_events_rec/src/person_events_rec.cpp
Show resolved
Hide resolved
serialization/protobuf/samples/pubsub/person_events_rec/src/person_events_rec.cpp
Show resolved
Hide resolved
sub.AddEventCallback(eCAL::eSubscriberEvent::connected, evt_callback); | ||
sub.AddEventCallback(eCAL::eSubscriberEvent::disconnected, evt_callback); | ||
sub.AddEventCallback(eCAL::eSubscriberEvent::dropped, evt_callback); | ||
eCAL::protobuf::CSubscriber<pb::People::Person> sub("person", OnEvent); |
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.
warning: variable 'sub' of type 'eCAL::protobuf::CSubscriberpb::People::Person' (aka 'CMessageSubscriber<pb::People::Person, internal::ProtobufDeserializer>') can be declared 'const' [misc-const-correctness]
eCAL::protobuf::CSubscriber<pb::People::Person> sub("person", OnEvent); | |
eCAL::protobuf::CSubscriber<pb::People::Person> const sub("person", OnEvent); |
msg/capnproto/publisher.h -> v6 play/play_core/src/measurement_container -> v6
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.
clang-tidy made some suggestions
serialization/capnproto/capnproto/include/ecal/msg/capnproto/publisher.h
Show resolved
Hide resolved
serialization/protobuf/samples/pubsub/person_events_snd/src/person_events_snd.cpp
Show resolved
Hide resolved
- no default constructor - 2 constructor types with and without event callback - no Create function
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.
clang-tidy made some suggestions
**/ | ||
CPublisher() | ||
: eCAL::v5::CPublisher() | ||
explicit CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = GetPublisherConfiguration()) : eCAL::CPublisher(topic_name_, GetDataTypeInformation(), config_) |
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.
warning: constructor does not initialize these fields: builder [cppcoreguidelines-pro-type-member-init]
serialization/capnproto/capnproto/include/ecal/msg/capnproto/publisher.h:172:
- std::unique_ptr<capnp::MallocMessageBuilder> builder;
+ std::unique_ptr<capnp::MallocMessageBuilder> builder{};
**/ | ||
CPublisher(const std::string& topic_name_, const eCAL::Publisher::Configuration& config_ = {}) | ||
: eCAL::v5::CPublisher(topic_name_, GetDataTypeInformation(), config_) | ||
explicit CPublisher(const std::string& topic_name_, const eCAL::PubEventCallbackT& event_callback_, const eCAL::Publisher::Configuration& config_ = GetPublisherConfiguration()) : eCAL::CPublisher(topic_name_, GetDataTypeInformation(), event_callback_, config_) |
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.
warning: constructor does not initialize these fields: builder [cppcoreguidelines-pro-type-member-init]
explicit CPublisher(const std::string& topic_name_, const eCAL::PubEventCallbackT& event_callback_, const eCAL::Publisher::Configuration& config_ = GetPublisherConfiguration()) : eCAL::CPublisher(topic_name_, GetDataTypeInformation(), event_callback_, config_)
^
@@ -219,7 +215,8 @@ bool MeasurementContainer::PublishFrame(long long index) | |||
{ | |||
timestamp_usecs = std::chrono::duration_cast<std::chrono::microseconds>(frame_table_[index].send_timestamp_.time_since_epoch()).count(); | |||
} | |||
frame_table_[index].publisher_info_->publisher_.SetID(frame_table_[index].send_id_); | |||
// this is not supported by the eCAL v6 API | |||
//frame_table_[index].publisher_info_->publisher_.SetID(frame_table_[index].send_id_); |
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.
Could this in any way be problematic?
So with eCAL 5, publishers will have the same ID they had when originally recording the measurement. In eCAL 6, they won't.
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.
Its about the topic id for subscriber side filtering. This feature is rarely used and no way to support this in the future, it's removed on both sides (pub and sub). So in v5 I can filter out different "streams" of the the same topic on subscriber side in v6 the connection will just receive all messages and I need to implement an ID myself (for example as part of my protobuf description).
@@ -144,6 +144,9 @@ std::unique_ptr<eCAL::rec_cli::command::Record> record_command; | |||
int main(int argc, char** argv) | |||
{ | |||
#ifdef WIN32 | |||
(void)argc; // suppress unused warning |
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.
Why surpress it only for Windows? also maybe just comment in the function declaration int main(int /*argc*/, char** /*argv*/)
(also this has nothing to do with this PR!!! 😏
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.
For LINUX platform both arguments are used unfortunately and yes it's not really related but I tried to fix at least some warnings when I touched a file.
@@ -113,7 +113,7 @@ namespace eCAL | |||
bool first_message_received; /**< Whether we received at least one Message (used for the status message)*/ | |||
eCAL::pb::SimTime::eState play_state; /**< Current state (used for the status message)*/ | |||
|
|||
eCAL::protobuf::CSubscriber<eCAL::pb::SimTime> sim_time_subscriber; /**< Subscriber for getting simulation timestamps */ | |||
std::unique_ptr<eCAL::protobuf::CSubscriber<eCAL::pb::SimTime>> sim_time_subscriber; /**< Subscriber for getting simulation timestamps */ |
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 kind of don't like that now we're "forcing" code to use pointers.
Do you now have to check the pointers in other locations?
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.
Without a Create/Destroy interface and the removed empty default constructors I see no alternative here.
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.
We need to think about error handling for all communication entities (pub/sub/server/client) in case construction fails.
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.
Yes, but the thing is, construction is unlikely to fail. Failure is more likely to occur during the runtime. E.g. The connections (memory files, sockets, ...) are usually not created during construction, but when we receive monitoring information about other entities in the system.
So we have to find a way to deal with this effectively.
Maybe error/event callbacks would be interesting in that case, too.
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 just have the few minor remarks... but I guess it looks good!
**/ | ||
explicit CMsgPublisher(const std::string& topic_name_, const Publisher::Configuration& config_ = GetPublisherConfiguration()) : CMsgPublisher(topic_name_, GetDataTypeInformation(), config_) | ||
CMsgPublisher(const std::string& topic_name_, const struct SDataTypeInformation& data_type_info_, const PubEventCallbackT& event_callback_, const Publisher::Configuration& config_ = GetPublisherConfiguration()) : CPublisher(topic_name_, data_type_info_, event_callback_, config_) |
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.
Why did you remove the explicit
keyword?
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.
Also why the struct
keywords? They are not necessary and I would consider them bad practice in this case. (I know we have them in various places, but I already remove them when I do see them).
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.
Fixed by next commit.
@@ -70,7 +70,7 @@ namespace eCAL | |||
* @param config_ Optional configuration parameters. | |||
**/ | |||
ECAL_API_EXPORTED_MEMBER | |||
CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventCallbackT event_callback_, const Publisher::Configuration& config_ = GetPublisherConfiguration()); | |||
CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventCallbackT& event_callback_, const Publisher::Configuration& config_ = GetPublisherConfiguration()); |
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 came across this, too, and I do wonder if it was on purpose, to copy the callbacks... But wasn't sure.
struct SDataTypeInformation -> SDataTypeInformation
Description
CMsgPub/Sub porting to v6.