-
Notifications
You must be signed in to change notification settings - Fork 180
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] redesign subscriber api #1863
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
There were too many comments to post at once. Showing the first 20 out of 125. Check the log or trigger a new build to see more.
CPublisherImpl event handling renamings
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
There were too many comments to post at once. Showing the first 20 out of 109. Check the log or trigger a new build to see more.
RemXY -> RemoveXY Logging corrected
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
There were too many comments to post at once. Showing the first 20 out of 105. Check the log or trigger a new build to see more.
} | ||
|
||
bool CSubscriber::Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Subscriber::Configuration& config_) | ||
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT event_callback_, const Subscriber::Configuration& 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: the const qualified parameter 'event_callback_' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
ecal/core/include/ecal/ecal_subscriber.h:69:
- CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());
+ CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT& event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT event_callback_, const Subscriber::Configuration& config_) : | |
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT& event_callback_, const Subscriber::Configuration& 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.
Rex: did you want to turn off this warning? doesn't it make sense in this case? Why not a reference?
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
There were too many comments to post at once. Showing the first 20 out of 89. Check the log or trigger a new build to see more.
} | ||
|
||
bool CSubscriber::Create(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const Subscriber::Configuration& config_) | ||
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT event_callback_, const Subscriber::Configuration& 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: the const qualified parameter 'event_callback_' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
ecal/core/include/ecal/ecal_subscriber.h:67:
- CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());
+ CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT& event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT event_callback_, const Subscriber::Configuration& config_) : | |
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventIDCallbackT& event_callback_, const Subscriber::Configuration& 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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 20 out of 30. Check the log or trigger a new build to see more.
|
||
int content(static_cast<int>(static_cast<unsigned char*>(data_->buf)[0])); | ||
int content(static_cast<int>(static_cast<unsigned char*>(data_.buf)[0])); |
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 'content' of type 'int' can be declared 'const' [misc-const-correctness]
int content(static_cast<int>(static_cast<unsigned char*>(data_.buf)[0])); | |
int const content(static_cast<int>(static_cast<unsigned char*>(data_.buf)[0])); |
std::cout << " Id : " << data_->id << std::endl; | ||
std::cout << " Time : " << data_->time << std::endl; | ||
std::cout << " Clock : " << data_->clock << std::endl; | ||
std::cout << " Size : " << data_.size << std::endl; |
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: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
std::cout << " Size : " << data_.size << std::endl; | |
std::cout << " Size : " << data_.size << '\n'; |
std::cout << " Time : " << data_->time << std::endl; | ||
std::cout << " Clock : " << data_->clock << std::endl; | ||
std::cout << " Size : " << data_.size << std::endl; | ||
std::cout << " Id : " << data_.id << std::endl; |
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: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
std::cout << " Id : " << data_.id << std::endl; | |
std::cout << " Id : " << data_.id << '\n'; |
std::cout << " Clock : " << data_->clock << std::endl; | ||
std::cout << " Size : " << data_.size << std::endl; | ||
std::cout << " Id : " << data_.id << std::endl; | ||
std::cout << " Time : " << data_.time << std::endl; |
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: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
std::cout << " Time : " << data_.time << std::endl; | |
std::cout << " Time : " << data_.time << '\n'; |
std::cout << " Size : " << data_.size << std::endl; | ||
std::cout << " Id : " << data_.id << std::endl; | ||
std::cout << " Time : " << data_.time << std::endl; | ||
std::cout << " Clock : " << data_.clock << std::endl; |
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: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
std::cout << " Clock : " << data_.clock << std::endl; | |
std::cout << " Clock : " << data_.clock << '\n'; |
eCAL::Initialize(config, "callback_topic_id"); | ||
} | ||
|
||
void TearDown() override |
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: method 'TearDown' can be made static [readability-convert-member-functions-to-static]
void TearDown() override | |
static void TearDown() override |
} | ||
}; | ||
|
||
TEST_P(TestFixture, OnePubSub) |
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: all parameters should be named in a function [readability-named-parameter]
TEST_P(TestFixture, OnePubSub) | |
TEST_P(TestFixture /*unused*/, OnePubSub /*unused*/) |
} | ||
}; | ||
|
||
TEST_P(TestFixture, OnePubSub) |
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: the parameter #1 is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TEST_P(TestFixture, OnePubSub) | |
TEST_P(const TestFixture&, OnePubSub) |
EXPECT_EQ(callback_datatype_info, datatype_info); | ||
} | ||
|
||
TEST_P(TestFixture, MultiplePubSub) |
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: all parameters should be named in a function [readability-named-parameter]
TEST_P(TestFixture, MultiplePubSub) | |
TEST_P(TestFixture /*unused*/, MultiplePubSub /*unused*/) |
EXPECT_EQ(callback_datatype_info, datatype_info); | ||
} | ||
|
||
TEST_P(TestFixture, MultiplePubSub) |
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: the parameter #1 is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TEST_P(TestFixture, MultiplePubSub) | |
TEST_P(const TestFixture&, MultiplePubSub) |
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
@@ -68,25 +68,25 @@ namespace eCAL | |||
|
|||
|
|||
template <typename T, typename DynamicDeserializer> | |||
class CDynamicMessageSubscriber final : public CSubscriber | |||
class CDynamicMessageSubscriber final : public v5::CSubscriber |
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: m_cb_callback, m_error_callback [cppcoreguidelines-pro-type-member-init]
ecal/core/include/ecal/msg/dynamic.h:258:
- MsgReceiveCallbackT m_cb_callback;
+ MsgReceiveCallbackT m_cb_callback{};
ecal/core/include/ecal/msg/dynamic.h:260:
- ErrorCallbackT m_error_callback;
+ ErrorCallbackT m_error_callback{};
#include <string> | ||
#include <thread> | ||
|
||
#include <gtest/gtest.h> |
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: 'gtest/gtest.h' file not found [clang-diagnostic-error]
#include <gtest/gtest.h>
^
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(core_cpp_pubsub_v5, TestSubscriberIsPublishedTiming) |
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: all parameters should be named in a function [readability-named-parameter]
TEST(core_cpp_pubsub_v5, TestSubscriberIsPublishedTiming) | |
TEST(core_cpp_pubsub_v5 /*unused*/, TestSubscriberIsPublishedTiming /*unused*/) |
eCAL::Finalize(); | ||
} | ||
|
||
TEST(core_cpp_pubsub_v5, TestPublisherIsSubscribedTiming) |
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: all parameters should be named in a function [readability-named-parameter]
TEST(core_cpp_pubsub_v5, TestPublisherIsSubscribedTiming) | |
TEST(core_cpp_pubsub_v5 /*unused*/, TestPublisherIsSubscribedTiming /*unused*/) |
eCAL::Finalize(); | ||
} | ||
|
||
TEST(core_cpp_pubsub_v5, TestChainedPublisherSubscriberCallback) |
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: all parameters should be named in a function [readability-named-parameter]
TEST(core_cpp_pubsub_v5, TestChainedPublisherSubscriberCallback) | |
TEST(core_cpp_pubsub_v5 /*unused*/, TestChainedPublisherSubscriberCallback /*unused*/) |
@@ -384,7 +385,7 @@ | |||
topic_info.encoding = topic_enc_; | |||
topic_info.descriptor = std::string(topic_desc_, static_cast<size_t>(topic_desc_length_)); | |||
|
|||
auto* sub = new eCAL::CSubscriber; | |||
auto* sub = new eCAL::v5::CSubscriber; | |||
if (!sub->Create(topic_name_, topic_info)) | |||
{ | |||
delete sub; |
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: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]
delete sub;
^
Additional context
lang/python/core/src/ecal_clang.cpp:387: variable declared here
auto* sub = new eCAL::v5::CSubscriber;
^
@@ -398,7 +399,7 @@ | |||
/****************************************/ | |||
bool sub_destroy(ECAL_HANDLE handle_) | |||
{ | |||
auto* sub = static_cast<eCAL::CSubscriber*>(handle_); | |||
auto* sub = static_cast<eCAL::v5::CSubscriber*>(handle_); | |||
if(sub != nullptr) | |||
{ | |||
delete sub; |
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: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]
delete sub;
^
Additional context
lang/python/core/src/ecal_clang.cpp:401: variable declared here
auto* sub = static_cast<eCAL::v5::CSubscriber*>(handle_);
^
@@ -422,7 +423,7 @@ PyObject* sub_set_callback(PyObject* /*self*/, PyObject* args) | |||
if (!PyArg_ParseTuple(args, "nO", &topic_handle, &cb_func)) | |||
return nullptr; | |||
|
|||
eCAL::CSubscriber* sub = (eCAL::CSubscriber*)topic_handle; | |||
eCAL::v5::CSubscriber* sub = (eCAL::v5::CSubscriber*)topic_handle; |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
eCAL::v5::CSubscriber* sub = (eCAL::v5::CSubscriber*)topic_handle;
^
@@ -475,7 +476,7 @@ | |||
if (!PyArg_ParseTuple(args, "nO", &topic_handle, &cb_func)) | |||
return nullptr; | |||
|
|||
eCAL::CSubscriber* sub = (eCAL::CSubscriber*)topic_handle; | |||
eCAL::v5::CSubscriber* sub = (eCAL::v5::CSubscriber*)topic_handle; |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
eCAL::v5::CSubscriber* sub = (eCAL::v5::CSubscriber*)topic_handle;
^
{ | ||
std::string topicName = topic_name_; | ||
std::string topicName = topic_id_.topic_name; |
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 'topicName' of type 'std::string' (aka 'basic_string') can be declared 'const' [misc-const-correctness]
std::string topicName = topic_id_.topic_name; | |
std::string const topicName = topic_id_.topic_name; |
Description
Changes Summary:
Namespace Updates:
eCAL::CSubscriber
API has been moved to theeCAL::v5
namespace for compatibility with existing systems using eCAL version 5.eCAL::CSubscriber
API under theeCAL::v6
namespace (default inline namespace).API Modernization:
Create
andDestroy
methods inv6
. Subscribers are now fully initialized via constructors and cleaned up automatically via destructors.AddEventCallback
,RemEventCallback
) are now passed as optional parameters during object construction, simplifying event handling.AddReceiveCallback
toSetReceiveCallback
,RemReceiveCallback
toRemoveReceiveCallback
SetReceiveCallback
andRemoveReceiveCallback
methods remain part of the API for flexibility in managing message reception callbacks.SetAttribute
,ClearAttribute
, andSetID
were removed as they were experimental or rarely used.ReceiveBuffer
method inv5
was replaced withSetReceiveCallback
to encourage a more event-driven approach to data reception inv6
.Code Refactoring:
std::shared_ptr<CSubscriberImpl>
for robust resource management and memory safety.SDataTypeInformation
for specifying topic metadata and aSubEventIDCallbackT
for event-driven designs.Improved Usability:
Impact:
eCAL::v5::CSubscriber
while offering a modern, streamlined API for new applications.