-
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
Feature/subscriber callback #1982
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
data_.reserve(callback_data->size); | ||
data_.assign((char*)callback_data->buf, (char*)callback_data->buf + callback_data->size); | ||
data_.reserve(callback_data->buffer_size); | ||
data_.assign((char*)callback_data->buffer, (char*)callback_data->buffer + callback_data->buffer_size); |
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]
data_.assign((char*)callback_data->buffer, (char*)callback_data->buffer + callback_data->buffer_size);
^
data_.reserve(callback_data->size); | ||
data_.assign((char*)callback_data->buf, (char*)callback_data->buf + callback_data->size); | ||
data_.reserve(callback_data->buffer_size); | ||
data_.assign((char*)callback_data->buffer, (char*)callback_data->buffer + callback_data->buffer_size); |
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]
data_.assign((char*)callback_data->buffer, (char*)callback_data->buffer + callback_data->buffer_size);
^
enum class eSubscriberEvent | ||
* @brief eCAL publisher event callback type. | ||
**/ | ||
enum class ePublisherEvent |
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: enum 'ePublisherEvent' uses a larger base type ('int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
^
enum class ePublisherEvent | ||
* @brief eCAL subscriber event callback type. | ||
**/ | ||
enum class eSubscriberEvent |
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: enum 'eSubscriberEvent' uses a larger base type ('int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]
^
|
||
int content(static_cast<int>(static_cast<unsigned char*>(data_.buf)[0])); | ||
int content(static_cast<int>(static_cast<const unsigned char*>(data_.buffer)[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<const unsigned char*>(data_.buffer)[0])); | |
int const content(static_cast<int>(static_cast<const unsigned char*>(data_.buffer)[0])); |
@@ -63,7 +63,7 @@ TEST(core_cpp_pubsub, TimeoutAcknowledgment) | |||
auto sub1 = std::make_shared< eCAL::CSubscriber>("topic"); | |||
auto sleeper_variable_time = [](const eCAL::STopicId& /*topic_id_*/, const eCAL::SDataTypeInformation& /*data_type_info_*/, const eCAL::SReceiveCallbackData& data_) | |||
{ | |||
std::string const sleep_time((const char*)data_.buf, data_.size); | |||
std::string const sleep_time((const char*)data_.buffer, data_.buffer_size); |
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]
std::string const sleep_time((const char*)data_.buffer, data_.buffer_size);
^
@@ -130,8 +130,8 @@ TEST(core_cpp_pubsub, MultipleSendsSHM) | |||
// add callback | |||
auto save_data = [&last_received_msg, &last_received_timestamp](const eCAL::STopicId& /*topic_id_*/, const eCAL::SDataTypeInformation& /*data_type_info_*/, const eCAL::SReceiveCallbackData& data_) | |||
{ | |||
last_received_msg = std::string{ (const char*)data_.buf, (size_t)data_.size}; | |||
last_received_timestamp = data_.time; | |||
last_received_msg = std::string{ (const char*)data_.buffer, (size_t)data_.buffer_size}; |
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]
last_received_msg = std::string{ (const char*)data_.buffer, (size_t)data_.buffer_size};
^
@@ -116,8 +116,8 @@ TEST(core_cpp_pubsub, MultipleSendsUDP) | |||
// add callback | |||
auto save_data = [&last_received_msg, &last_received_timestamp](const eCAL::STopicId& /*topic_id_*/, const eCAL::SDataTypeInformation& /*data_type_info_*/, const eCAL::SReceiveCallbackData& data_) | |||
{ | |||
last_received_msg = std::string{ (const char*)data_.buf, (size_t)data_.size }; | |||
last_received_timestamp = data_.time; | |||
last_received_msg = std::string{ (const char*)data_.buffer, (size_t)data_.buffer_size }; |
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]
last_received_msg = std::string{ (const char*)data_.buffer, (size_t)data_.buffer_size };
^
@@ -528,7 +528,7 @@ bool sub_receive_buffer(ECAL_HANDLE handle_, const char** rcv_buf_, int* rcv_buf | |||
/* sub_add_receive_callback */ | |||
/****************************************/ | |||
static std::mutex g_sub_receive_callback_mtx; | |||
static void g_sub_receive_callback(const char* topic_name_, const struct eCAL::SReceiveCallbackData* data_, const ReceiveCallbackCT callback_, void* par_) | |||
static void g_sub_receive_callback(const char* topic_name_, const struct eCAL::v5::SReceiveCallbackData* data_, const ReceiveCallbackCT callback_, void* par_) |
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: function 'g_sub_receive_callback' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
static void g_sub_receive_callback(const char* topic_name_, const struct eCAL::v5::SReceiveCallbackData* data_, const ReceiveCallbackCT callback_, void* par_)
^
@@ -368,7 +368,7 @@ PyObject* sub_receive(PyObject* /*self*/, PyObject* args) | |||
/****************************************/ | |||
/* sub_set_callback */ | |||
/****************************************/ | |||
static void c_subscriber_callback(const char* topic_name_, const struct eCAL::SReceiveCallbackData* data_, ECAL_HANDLE handle_, const std::string& /*python_formatter*/) | |||
static void c_subscriber_callback(const char* topic_name_, const struct eCAL::v5::SReceiveCallbackData* data_, ECAL_HANDLE handle_, const std::string& /*python_formatter*/) |
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: function 'c_subscriber_callback' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
static void c_subscriber_callback(const char* topic_name_, const struct eCAL::v5::SReceiveCallbackData* data_, ECAL_HANDLE handle_, const std::string& /*python_formatter*/)
^
Description
split v5 and v6 SCallbackData.
Rename v6 SCallbackData fields,