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 event naming #1898

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions ecal/core/include/ecal/ecal_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ namespace eCAL
* @param data_type_info_ Topic data type information (encoding, type, descriptor).
* @param data_ Data struct containing payload, timestamp and publication clock.
**/
using ReceiveIDCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SDataTypeInformation& data_type_info_, const SReceiveCallbackData& data_)>;
using ReceiveCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SDataTypeInformation& data_type_info_, const SReceiveCallbackData& data_)>;

/**
* @brief eCAL publisher event callback struct.
**/
struct SPubEventIDCallbackData
struct SPubEventCallbackData
{
eCAL_Publisher_Event type{ pub_event_none }; //!< publisher event type
long long time{ 0 }; //!< publisher event time in µs
Expand All @@ -79,12 +79,12 @@ namespace eCAL
* @param topic_id_ The topic id struct of the received message.
* @param data_ Event callback data structure with the event specific information.
**/
using PubEventIDCallbackT = std::function<void(const Registration::STopicId& topic_id_, const struct SPubEventIDCallbackData& data_)>;
using PubEventCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SPubEventCallbackData& data_)>;

/**
* @brief eCAL subscriber event callback struct.
**/
struct SSubEventIDCallbackData
struct SSubEventCallbackData
{
eCAL_Subscriber_Event type{ sub_event_none }; //!< subscriber event type
long long time{ 0 }; //!< subscriber event time in µs
Expand All @@ -98,12 +98,12 @@ namespace eCAL
* @param topic_id_ The topic id struct of the received message.
* @param data_ Event callback data structure with the event specific information.
**/
using SubEventIDCallbackT = std::function<void(const Registration::STopicId& topic_id_, const struct SSubEventIDCallbackData& data_)>;
using SubEventCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SSubEventCallbackData& data_)>;

/**
* @brief eCAL client event callback struct.
**/
struct SClientEventIDCallbackData
struct SClientEventCallbackData
{
eCAL_Client_Event type = client_event_none; //!< event type
long long time = 0; //!< event time in µs
Expand All @@ -115,12 +115,12 @@ namespace eCAL
* @param service_id_ The service id struct of the connection that triggered the event.
* @param data_ Event callback data structure with the event specific information.
**/
using ClientEventIDCallbackT = std::function<void(const Registration::SServiceMethodId& service_id_, const struct SClientEventIDCallbackData& data_)>;
using ClientEventCallbackT = std::function<void(const Registration::SServiceMethodId& service_id_, const SClientEventCallbackData& data_)>;

/**
* @brief eCAL server event callback struct.
**/
struct SServerEventIDCallbackData
struct SServerEventCallbackData
{
eCAL_Server_Event type = server_event_none; //!< event type
long long time = 0; //!< event time in µs
Expand All @@ -132,6 +132,6 @@ namespace eCAL
* @param service_id_ The service id struct of the connection that triggered the event.
* @param data_ Event callback data structure with the event specific information.
**/
using ServerEventIDCallbackT = std::function<void(const Registration::SServiceMethodId& service_id_, const struct SServerEventIDCallbackData& data_)>;
using ServerEventCallbackT = std::function<void(const Registration::SServiceMethodId& service_id_, const struct SServerEventCallbackData& data_)>;
}
}
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/ecal_client.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace eCAL
* @param event_callback_ The client event callback funtion.
**/
ECAL_API_EXPORTED_MEMBER
CServiceClient(const std::string& service_name_, const ServiceMethodInformationMapT method_information_map_ = ServiceMethodInformationMapT(), const ClientEventIDCallbackT event_callback_ = ClientEventIDCallbackT());
CServiceClient(const std::string& service_name_, const ServiceMethodInformationMapT method_information_map_ = ServiceMethodInformationMapT(), const ClientEventCallbackT event_callback_ = ClientEventCallbackT());

/**
* @brief Destructor.
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/ecal_publisher.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace eCAL
* @param config_ Optional configuration parameters.
**/
ECAL_API_EXPORTED_MEMBER
CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventIDCallbackT 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());

/**
* @brief Destructor.
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/ecal_server.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,7 +53,7 @@ namespace eCAL
* @param event_callback_ Callback function for server events.
**/
ECAL_API_EXPORTED_MEMBER
explicit CServiceServer(const std::string& service_name_, const ServerEventIDCallbackT event_callback_ = ServerEventIDCallbackT());
explicit CServiceServer(const std::string& service_name_, const ServerEventCallbackT event_callback_ = ServerEventCallbackT());

/**
* @brief Destructor.
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/include/ecal/ecal_subscriber.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace eCAL
* @param config_ Configuration parameters.
**/
ECAL_API_EXPORTED_MEMBER
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 SubEventCallbackT event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());

/**
* @brief Destructor.
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace eCAL
* @return True if succeeded, false if not.
**/
ECAL_API_EXPORTED_MEMBER
bool SetReceiveCallback(ReceiveIDCallbackT callback_);
bool SetReceiveCallback(ReceiveCallbackT callback_);

/**
* @brief Remove callback function for incoming receives.
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/ecal_subscriber_v5.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -194,7 +194,7 @@ namespace eCAL
* @return True if succeeded, false if not.
**/
ECAL_API_EXPORTED_MEMBER
bool AddReceiveCallback(ReceiveIDCallbackT callback_);
bool AddReceiveCallback(v6::ReceiveCallbackT callback_);

/**
* @brief Remove callback function for incoming receives.
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/msg/dynamic.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -166,7 +166,7 @@ namespace eCAL
m_cb_callback = callback_;
}

ReceiveIDCallbackT callback = std::bind(&CDynamicMessageSubscriber::ReceiveCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
ReceiveCallbackT callback = std::bind(&CDynamicMessageSubscriber::ReceiveCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
return(v5::CSubscriber::AddReceiveCallback(callback));
}

Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/pubsub/ecal_publisher.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2024 Continental Corporation
* Copyright (C) 2016 - 2025 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,11 +47,11 @@ namespace eCAL
if(g_pubgate() != nullptr) g_pubgate()->Register(topic_name_, m_publisher_impl);
}

CPublisher::CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventIDCallbackT event_callback_, const Publisher::Configuration& config_) :
CPublisher::CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventCallbackT event_callback_, const Publisher::Configuration& config_) :
Copy link
Contributor

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_publisher.h:71:

-         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());
Suggested change
CPublisher::CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventCallbackT event_callback_, const Publisher::Configuration& config_) :
CPublisher::CPublisher(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const PubEventCallbackT& event_callback_, const Publisher::Configuration& config_) :

CPublisher(topic_name_, data_type_info_, config_)
{
// add event callback for all current event types
m_publisher_impl->SetEventIDCallback(event_callback_);
m_publisher_impl->SetEventCallback(event_callback_);
}

CPublisher::~CPublisher()
Expand Down
10 changes: 5 additions & 5 deletions ecal/core/src/pubsub/ecal_publisher_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,12 @@ namespace eCAL
return(true);
}

bool CPublisherImpl::SetEventIDCallback(const PubEventIDCallbackT callback_)
bool CPublisherImpl::SetEventCallback(const PubEventCallbackT callback_)
Copy link
Contributor

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 'callback_' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]

ecal/core/src/pubsub/ecal_publisher_impl.h:89:

-     bool SetEventCallback(const PubEventCallbackT callback_);
+     bool SetEventCallback(const PubEventCallbackT& callback_);
Suggested change
bool CPublisherImpl::SetEventCallback(const PubEventCallbackT callback_)
bool CPublisherImpl::SetEventCallback(const PubEventCallbackT& callback_)

{
if (!m_created) return false;

#ifndef NDEBUG
Logging::Log(log_level_debug2, m_attributes.topic_name + "::CPublisherImpl::SetEventIDCallback");
Logging::Log(log_level_debug2, m_attributes.topic_name + "::CPublisherImpl::SetEventCallback");
#endif

// set event id callback
Expand All @@ -416,12 +416,12 @@ namespace eCAL
return true;
}

bool CPublisherImpl::RemoveEventIDCallback()
bool CPublisherImpl::RemoveEventCallback()
{
if (!m_created) return false;

#ifndef NDEBUG
Logging::Log(log_level_debug2, m_attributes.topic_name + "::CPublisherImpl::RemoveEventIDCallback");
Logging::Log(log_level_debug2, m_attributes.topic_name + "::CPublisherImpl::RemoveEventCallback");
#endif

// remove event id callback
Expand Down Expand Up @@ -738,7 +738,7 @@ namespace eCAL
// new event handling with topic id
if(m_event_id_callback)
{
SPubEventIDCallbackData data;
SPubEventCallbackData data;
data.type = type_;
data.time = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
data.clock = 0;
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/pubsub/ecal_publisher_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ namespace eCAL
bool RemoveEventCallback(eCAL_Publisher_Event type_);

// future event callback interface
bool SetEventIDCallback(const PubEventIDCallbackT callback_);
bool RemoveEventIDCallback();
bool SetEventCallback(const PubEventCallbackT callback_);
bool RemoveEventCallback();

bool SetAttribute(const std::string& attr_name_, const std::string& attr_value_);
bool ClearAttribute(const std::string& attr_name_);
Expand Down Expand Up @@ -168,7 +168,7 @@ namespace eCAL
EventCallbackMapT m_event_callback_map;

std::mutex m_event_id_callback_mutex;
PubEventIDCallbackT m_event_id_callback;
PubEventCallbackT m_event_id_callback;

long long m_id = 0;
long long m_clock = 0;
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/pubsub/ecal_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace eCAL
if (g_subgate() != nullptr) g_subgate()->Register(topic_name_, m_subscriber_impl);
}

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 SubEventCallbackT event_callback_, const Subscriber::Configuration& config_) :
Copy link
Contributor

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 SubEventCallbackT event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());
+         CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventCallbackT& event_callback_, const Subscriber::Configuration& config_ = GetSubscriberConfiguration());
Suggested change
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventCallbackT event_callback_, const Subscriber::Configuration& config_) :
CSubscriber::CSubscriber(const std::string& topic_name_, const SDataTypeInformation& data_type_info_, const SubEventCallbackT& event_callback_, const Subscriber::Configuration& config_) :

CSubscriber(topic_name_, data_type_info_, config_)
{
// add event callback for all current event types
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace eCAL
return *this;
}

bool CSubscriber::SetReceiveCallback(ReceiveIDCallbackT callback_)
bool CSubscriber::SetReceiveCallback(ReceiveCallbackT callback_)
{
if (m_subscriber_impl == nullptr) return false;
return m_subscriber_impl->SetReceiveCallback(std::move(callback_));
Expand Down
12 changes: 6 additions & 6 deletions ecal/core/src/pubsub/ecal_subscriber_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace eCAL
return(false);
}

bool CSubscriberImpl::SetReceiveCallback(ReceiveIDCallbackT callback_)
bool CSubscriberImpl::SetReceiveCallback(ReceiveCallbackT callback_)
{
if (!m_created) return(false);

Expand Down Expand Up @@ -231,7 +231,7 @@ namespace eCAL
return(true);
}

bool CSubscriberImpl::SetEventIDCallback(const SubEventIDCallbackT callback_)
bool CSubscriberImpl::SetEventIDCallback(const SubEventCallbackT callback_)
Copy link
Contributor

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 'callback_' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]

Suggested change
bool CSubscriberImpl::SetEventIDCallback(const SubEventCallbackT callback_)
bool CSubscriberImpl::SetEventIDCallback(const SubEventCallbackT& callback_)

ecal/core/src/pubsub/ecal_subscriber_impl.h:80:

-     bool SetEventIDCallback(const SubEventCallbackT callback_);
+     bool SetEventIDCallback(const SubEventCallbackT& callback_);

{
if (!m_created) return false;

Expand All @@ -247,12 +247,12 @@ namespace eCAL
return true;
}

bool CSubscriberImpl::RemoveEventIDCallback()
bool CSubscriberImpl::RemoveEventCallback()
{
if (!m_created) return false;

#ifndef NDEBUG
Logging::Log(log_level_debug2, m_attributes.topic_name + "::CSubscriberImpl::RemoveEventIDCallback");
Logging::Log(log_level_debug2, m_attributes.topic_name + "::CSubscriberImpl::RemoveEventCallback");
#endif

// remove event id callback
Expand Down Expand Up @@ -787,7 +787,7 @@ namespace eCAL
// new event handling with topic id
if (m_event_id_callback)
{
SSubEventIDCallbackData data;
SSubEventCallbackData data;
data.type = type_;
data.time = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
data.clock = 0;
Expand Down Expand Up @@ -909,7 +909,7 @@ namespace eCAL
// new event handling with topic id
if (m_event_id_callback)
{
SSubEventIDCallbackData data;
SSubEventCallbackData data;
data.type = sub_event_dropped;
data.time = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
data.clock = current_clock_;
Expand Down
10 changes: 5 additions & 5 deletions ecal/core/src/pubsub/ecal_subscriber_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ namespace eCAL

bool Read(std::string& buf_, long long* time_ = nullptr, int rcv_timeout_ms_ = 0);

bool SetReceiveCallback(ReceiveIDCallbackT callback_);
bool SetReceiveCallback(ReceiveCallbackT callback_);
bool RemoveReceiveCallback();

// deprecated event callback interface
bool SetEventCallback(eCAL_Subscriber_Event type_, v5::SubEventCallbackT callback_);
bool RemoveEventCallback(eCAL_Subscriber_Event type_);

// future event callback interface
bool SetEventIDCallback(const SubEventIDCallbackT callback_);
bool RemoveEventIDCallback();
bool SetEventIDCallback(const SubEventCallbackT callback_);
bool RemoveEventCallback();

bool SetAttribute(const std::string& attr_name_, const std::string& attr_value_);
bool ClearAttribute(const std::string& attr_name_);
Expand Down Expand Up @@ -158,7 +158,7 @@ namespace eCAL
long long m_read_time = 0;

std::mutex m_receive_callback_mutex;
ReceiveIDCallbackT m_receive_callback;
ReceiveCallbackT m_receive_callback;
std::atomic<int> m_receive_time;

std::deque<size_t> m_sample_hash_queue;
Expand All @@ -168,7 +168,7 @@ namespace eCAL
EventCallbackMapT m_event_callback_map;

std::mutex m_event_id_callback_mutex;
SubEventIDCallbackT m_event_id_callback;
SubEventCallbackT m_event_id_callback;

std::atomic<long long> m_clock;

Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/pubsub/ecal_subscriber_v5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ namespace eCAL

bool CSubscriber::AddReceiveCallback(ReceiveCallbackT callback_)
{
auto id_callback = [callback_](const Registration::STopicId& topic_id_, const SDataTypeInformation&, const SReceiveCallbackData& data_)
auto v6_callback = [callback_](const Registration::STopicId& topic_id_, const SDataTypeInformation&, const eCAL::SReceiveCallbackData& data_)
{
callback_(topic_id_.topic_name.c_str(), &data_);
};
return AddReceiveCallback(id_callback);
return AddReceiveCallback(v6_callback);
}

bool CSubscriber::AddReceiveCallback(ReceiveIDCallbackT callback_)
bool CSubscriber::AddReceiveCallback(v6::ReceiveCallbackT callback_)
{
if (m_subscriber_impl == nullptr) return(false);
RemReceiveCallback();
Expand Down
Loading
Loading