Skip to content
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

Merged
merged 4 commits into from
Jan 31, 2025
Merged

Conversation

KerstinKeller
Copy link
Contributor

Description

split v5 and v6 SCallbackData.
Rename v6 SCallbackData fields,

@KerstinKeller KerstinKeller added the cherry-pick-to-NONE Don't cherry-pick these changes label Jan 31, 2025
@KerstinKeller KerstinKeller requested a review from Peguen January 31, 2025 07:43
Copy link
Contributor

@github-actions github-actions bot left a 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);
Copy link
Contributor

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);
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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]));
Copy link
Contributor

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]

Suggested change
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);
Copy link
Contributor

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};
Copy link
Contributor

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 };
Copy link
Contributor

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_)
Copy link
Contributor

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*/)
Copy link
Contributor

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*/)
            ^

@KerstinKeller KerstinKeller requested a review from hannemn January 31, 2025 09:32
@KerstinKeller KerstinKeller merged commit d9faad3 into master Jan 31, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-to-NONE Don't cherry-pick these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants