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

[core] remove multiple structs from Registration namespace. (IDs for pubsub / services). #1946

Merged
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
6 changes: 3 additions & 3 deletions app/mon/mon_plugins/raw_data_reflection/src/plugin_widget.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 @@ -59,7 +59,7 @@ PluginWidget::PluginWidget(const QString& topic_name, const QString&, QWidget* p
ui_.content_layout->addWidget(frame);

// Connect the eCAL Subscriber
subscriber_.SetReceiveCallback([this](const eCAL::Registration::STopicId& /*topic_id*/,
subscriber_.SetReceiveCallback([this](const eCAL::STopicId& /*topic_id*/,
const eCAL::SDataTypeInformation& /*data_type_info*/,
const eCAL::SReceiveCallbackData& callback_data)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ void PluginWidget::onUpdate()
void PluginWidget::onResume()
{
// (Re)Connect the eCAL Subscriber
subscriber_.SetReceiveCallback([this](const eCAL::Registration::STopicId& /*topic_id*/,
subscriber_.SetReceiveCallback([this](const eCAL::STopicId& /*topic_id*/,
const eCAL::SDataTypeInformation& /*data_type_info*/,
const eCAL::SReceiveCallbackData& callback_data)
{
Expand Down
4 changes: 2 additions & 2 deletions app/rec/rec_client_core/src/ecal_rec_impl.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 @@ -695,7 +695,7 @@ namespace eCAL
return subscribed_topics;
}

void EcalRecImpl::EcalMessageReceived(const eCAL::Registration::STopicId& topic_id_, const eCAL::SReceiveCallbackData& data_)
void EcalRecImpl::EcalMessageReceived(const eCAL::STopicId& topic_id_, const eCAL::SReceiveCallbackData& data_)
{
auto ecal_receive_time = eCAL::Time::ecal_clock::now();
auto system_receive_time = std::chrono::steady_clock::now();
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_client_core/src/ecal_rec_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace eCAL

std::set<std::string> GetSubscribedTopics() const;

void EcalMessageReceived(const eCAL::Registration::STopicId& topic_id_, const eCAL::SReceiveCallbackData& data_);
void EcalMessageReceived(const eCAL::STopicId& topic_id_, const eCAL::SReceiveCallbackData& data_);

//////////////////////////////////////
//// API for external threads ////
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
Expand Up @@ -148,7 +148,7 @@ namespace eCAL
* @param clock_ Message writer clock.
* @param id_ Message id.
**/
using MsgReceiveCallbackT = std::function<void(const Registration::STopicId& topic_id_, const T& msg_, long long time_, long long clock_, long long id_)>;
using MsgReceiveCallbackT = std::function<void(const STopicId& topic_id_, const T& msg_, long long time_, long long clock_, long long id_)>;

/**
* @brief Add receive callback for incoming messages.
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace eCAL
}

private:
void ReceiveCallback(const Registration::STopicId& topic_id_, const SDataTypeInformation& topic_info_, const struct SReceiveCallbackData& data_)
void ReceiveCallback(const STopicId& topic_id_, const SDataTypeInformation& topic_info_, const struct SReceiveCallbackData& data_)
{
MsgReceiveCallbackT fn_callback = nullptr;
{
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/pubsub/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace eCAL
* @return The topic id.
**/
ECAL_API_EXPORTED_MEMBER
Registration::STopicId GetTopicId() const;
STopicId GetTopicId() const;

/**
* @brief Gets description of the connected topic.
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/pubsub/subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace eCAL
* @return The topic id.
**/
ECAL_API_EXPORTED_MEMBER
Registration::STopicId GetTopicId() const;
STopicId GetTopicId() const;

/**
* @brief Retrieve the topic information.
Expand Down
13 changes: 5 additions & 8 deletions ecal/core/include/ecal/pubsub/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@

namespace eCAL
{
namespace Registration
{
struct STopicId
struct STopicId
{
SEntityId topic_id;
std::string topic_name;
Expand All @@ -51,13 +49,12 @@ namespace eCAL
}
};

inline std::ostream& operator<<(std::ostream& os, const STopicId& id)
inline std::ostream& operator<<(std::ostream& os, const STopicId& id)
{
os << "STopicId(topic_id: " << id.topic_id
<< ", topic_name: " << id.topic_name << ")";
return os;
}
}

/**
* @brief eCAL subscriber receive callback struct.
Expand Down Expand Up @@ -123,7 +120,7 @@ namespace eCAL
* @param data_type_info_ Topic data type information (encoding, type, descriptor).
* @param data_ Data struct containing payload, timestamp and publication clock.
**/
using ReceiveCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SDataTypeInformation& data_type_info_, const SReceiveCallbackData& data_)>;
using ReceiveCallbackT = std::function<void(const STopicId& topic_id_, const SDataTypeInformation& data_type_info_, const SReceiveCallbackData& data_)>;

/**
* @brief eCAL publisher event callback struct.
Expand All @@ -141,7 +138,7 @@ 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 PubEventCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SPubEventCallbackData& data_)>;
using PubEventCallbackT = std::function<void(const STopicId& topic_id_, const SPubEventCallbackData& data_)>;

/**
* @brief eCAL subscriber event callback struct.
Expand All @@ -159,7 +156,7 @@ 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 SubEventCallbackT = std::function<void(const Registration::STopicId& topic_id_, const SSubEventCallbackData& data_)>;
using SubEventCallbackT = std::function<void(const STopicId& topic_id_, const SSubEventCallbackData& data_)>;
}
}

2 changes: 1 addition & 1 deletion ecal/core/include/ecal/service/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace eCAL
* @return The service id.
**/
ECAL_API_EXPORTED_MEMBER
Registration::SServiceId GetServiceId() const;
SServiceId GetServiceId() const;

/**
* @brief Check connection to at least one service.
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/include/ecal/service/client_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace eCAL
public:
// Constructor
ECAL_API_EXPORTED_MEMBER
CClientInstance(const Registration::SEntityId& entity_id_, const std::shared_ptr<v6::CServiceClientImpl>& service_client_id_impl_);
CClientInstance(const SEntityId& entity_id_, const std::shared_ptr<v6::CServiceClientImpl>& service_client_id_impl_);

// Defaulted destructor
~CClientInstance() = default;
Expand Down Expand Up @@ -109,10 +109,10 @@ namespace eCAL
* @return The client entity id.
**/
ECAL_API_EXPORTED_MEMBER
Registration::SEntityId GetClientID() const;
SEntityId GetClientID() const;

private:
Registration::SEntityId m_entity_id;
SEntityId m_entity_id;
const std::shared_ptr<eCAL::v6::CServiceClientImpl> m_service_client_impl;
};
}
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/service/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace eCAL
* @return The service id.
**/
ECAL_API_EXPORTED_MEMBER
Registration::SServiceId GetServiceId() const;
SServiceId GetServiceId() const;

/**
* @brief Check connection state.
Expand Down
73 changes: 37 additions & 36 deletions ecal/core/include/ecal/service/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,45 +84,46 @@ namespace eCAL
}
}

namespace Registration
/**
* @brief Unique ID with which to identify a service (client or server)
* It can be queried from the client or the server, and it can be obtained from the registration layer.
**/
struct SServiceId
{
SEntityId service_id;
std::string service_name;

struct SServiceId
bool operator==(const SServiceId& other) const
{
SEntityId service_id;
std::string service_name;

bool operator==(const SServiceId& other) const
{
return service_id == other.service_id && service_name == other.service_name;
}

bool operator<(const SServiceId& other) const
{
return std::tie(service_id, service_name) < std::tie(other.service_id, other.service_name);
}
};
return service_id == other.service_id && service_name == other.service_name;
}

struct SServiceMethodId
bool operator<(const SServiceId& other) const
{
SEntityId service_id;
std::string service_name;
std::string method_name;

bool operator==(const SServiceMethodId& other) const
{
return service_id == other.service_id && service_name == other.service_name && method_name == other.method_name;
}

bool operator<(const SServiceMethodId& other) const
{
return std::tie(service_id, service_name, method_name) < std::tie(other.service_id, other.service_name, other.method_name);
}
};
}
return std::tie(service_id, service_name) < std::tie(other.service_id, other.service_name);
}
};

struct SServiceMethodId
{
SEntityId service_id;
std::string service_name;
std::string method_name;

bool operator==(const SServiceMethodId& other) const
{
return service_id == other.service_id && service_name == other.service_name && method_name == other.method_name;
}

bool operator<(const SServiceMethodId& other) const
{
return std::tie(service_id, service_name, method_name) < std::tie(other.service_id, other.service_name, other.method_name);
}
};

/**
* @brief Service method information struct containing the request and response type information.
* @brief Service method information struct containing the method name, the request and response type information.
* This type is used when creating services (servers or clients), or when querying information about them from the registration layer.
**/
struct SServiceMethodInformation
{
Expand All @@ -146,7 +147,7 @@ namespace eCAL
**/
struct SServiceIDResponse
{
Registration::SServiceMethodId service_method_id; //!< service method information (service id (entity id, process id, host name), service name, method name)
SServiceMethodId service_method_id; //!< service method information (service id (entity id, process id, host name), service name, method name)
std::string error_msg; //!< human readable error message
int ret_state = 0; //!< return state of the called service method
eCallState call_state = eCallState::none; //!< call state (see eCallState)
Expand All @@ -169,7 +170,7 @@ namespace eCAL
* @param entity_id_ Unique service id (entity id, process id, host name, service name, method name)
* @param service_response_ Service response struct containing the (responding) server informations and the response itself.
**/
using ResponseIDCallbackT = std::function<void (const Registration::SEntityId& entity_id_, const struct SServiceIDResponse& service_response_)>;
using ResponseIDCallbackT = std::function<void (const SEntityId& entity_id_, const struct SServiceIDResponse& service_response_)>;

/**
* @brief Map of <method name, method information (like request type, reponse type)>.
Expand All @@ -193,7 +194,7 @@ 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 ClientEventCallbackT = std::function<void(const Registration::SServiceId& service_id_, const SClientEventCallbackData& data_)>;
using ClientEventCallbackT = std::function<void(const SServiceId& service_id_, const SClientEventCallbackData& data_)>;

/**
* @brief eCAL server event callback struct.
Expand All @@ -210,7 +211,7 @@ 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 ServerEventCallbackT = std::function<void(const Registration::SServiceId& service_id_, const struct SServerEventCallbackData& data_)>;
using ServerEventCallbackT = std::function<void(const SServiceId& service_id_, const struct SServerEventCallbackData& data_)>;
}

}
43 changes: 20 additions & 23 deletions ecal/core/include/ecal/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,30 @@ namespace eCAL
//!< @endcond
};

namespace Registration
{
using EntityIdT = uint64_t;

struct SEntityId
{
EntityIdT entity_id = 0; // unique id within that process (it should already be unique within the whole system)
int32_t process_id = 0; // process id which produced the sample
std::string host_name; // host which produced the sample
using EntityIdT = uint64_t;

bool operator==(const SEntityId& other) const {
return entity_id == other.entity_id;
}
struct SEntityId
{
EntityIdT entity_id = 0; // unique id within that process (it should already be unique within the whole system)
int32_t process_id = 0; // process id which produced the sample
std::string host_name; // host which produced the sample

bool operator<(const SEntityId& other) const
{
return entity_id < other.entity_id;
}
};
bool operator==(const SEntityId& other) const {
return entity_id == other.entity_id;
}

// Overload the << operator for SEntityId
inline std::ostream& operator<<(std::ostream& os, const SEntityId& id)
bool operator<(const SEntityId& other) const
{
os << "SEntityId(entity_id: " << id.entity_id
<< ", process_id: " << id.process_id
<< ", host_name: " << id.host_name << ")";
return os;
return entity_id < other.entity_id;
}
};

// Overload the << operator for SEntityId
inline std::ostream& operator<<(std::ostream& os, const SEntityId& id)
{
os << "SEntityId(entity_id: " << id.entity_id
<< ", process_id: " << id.process_id
<< ", host_name: " << id.host_name << ")";
return os;
}
}
6 changes: 3 additions & 3 deletions ecal/core/include/ecal/types/monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace eCAL
int32_t pid{0}; //!< process id
std::string pname; //!< process name
std::string uname; //!< unit name
Registration::EntityIdT tid{0}; //!< topic id
EntityIdT tid{0}; //!< topic id
std::string tname; //!< topic name
std::string direction; //!< direction (publisher, subscriber)
SDataTypeInformation tdatatype; //!< topic datatype information (name, encoding, descriptor)
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace eCAL
int32_t pid{0}; //<! process id

std::string sname; //<! service name
Registration::EntityIdT sid{0}; //<! service id
EntityIdT sid{0}; //<! service id

uint32_t version{0}; //<! service protocol version
uint32_t tcp_port_v0{0}; //<! the tcp port protocol version 0 used for that service
Expand All @@ -169,7 +169,7 @@ namespace eCAL
int32_t pid{0}; //<! process id

std::string sname; //<! service name
Registration::EntityIdT sid{0}; //<! service id
EntityIdT sid{0}; //<! service id

std::vector<SMethodMon> methods; //<! list of methods

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/v5/ecal_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace eCAL
std::string pname; //!< process name
std::string uname; //!< process unit name
std::string sname; //!< service name
Registration::EntityIdT sid = 0; //!< service id
EntityIdT sid = 0; //!< service id
int pid = 0; //!< process id

// internal protocol specifics
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/include/ecal/v5/ecal_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ namespace eCAL
* @return The topic id.
**/
ECAL_API_EXPORTED_MEMBER
Registration::STopicId GetId() const;
STopicId GetId() const;

/**
* @brief Gets description of the connected topic.
Expand Down
Loading
Loading