From b9d1ccfa3af4f521885e27083ae0b7b8e49a32ca Mon Sep 17 00:00:00 2001 From: Kerstin Keller Date: Mon, 19 Aug 2024 17:38:03 +0200 Subject: [PATCH] [core] eCAL sample completely internal, only SEntityId public. --- ecal/core/include/ecal/ecal_types.h | 16 ++++++++-------- ecal/core/src/ecal_descgate.cpp | 16 ++++++++++++---- .../ecal_struct_sample_registration.h | 19 +++++++++++++++++++ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/ecal/core/include/ecal/ecal_types.h b/ecal/core/include/ecal/ecal_types.h index 9759f69a18..e2e14b16e6 100644 --- a/ecal/core/include/ecal/ecal_types.h +++ b/ecal/core/include/ecal/ecal_types.h @@ -85,19 +85,19 @@ namespace eCAL namespace Registration { - struct SampleIdentifier + struct SEntityId { std::string entity_id; // unique id within that process int32_t process_id = 0; // process id which produced the sample std::string host_name; // host which produced the sample - bool operator==(const SampleIdentifier& other) const { + bool operator==(const SEntityId& other) const { return entity_id == other.entity_id && process_id == other.process_id && host_name == other.host_name; } - bool operator<(const SampleIdentifier& other) const + bool operator<(const SEntityId& other) const { return std::tie(process_id, entity_id, host_name) < std::tie(other.process_id, other.entity_id, other.host_name); @@ -106,8 +106,8 @@ namespace eCAL struct STopicId { - Registration::SampleIdentifier topic_id; - std::string topic_name; + SEntityId topic_id; + std::string topic_name; bool operator<(const STopicId& other) const { @@ -117,9 +117,9 @@ namespace eCAL struct SServiceId { - Registration::SampleIdentifier service_id; - std::string service_name; - std::string method_name; + SEntityId service_id; + std::string service_name; + std::string method_name; bool operator<(const SServiceId& other) const { diff --git a/ecal/core/src/ecal_descgate.cpp b/ecal/core/src/ecal_descgate.cpp index 24ec6a5922..2c62df3113 100644 --- a/ecal/core/src/ecal_descgate.cpp +++ b/ecal/core/src/ecal_descgate.cpp @@ -39,6 +39,14 @@ namespace if(is_producer_) quality |= eCAL::Registration::DescQualityFlags::INFO_COMES_FROM_PRODUCER; return quality; } + + eCAL::Registration::SEntityId ConvertToEntityId(const eCAL::Registration::SampleIdentifier& sample_identifier) + { + eCAL::Registration::SEntityId id{ sample_identifier.entity_id, sample_identifier.process_id, sample_identifier.host_name}; + return id; + } + + } namespace eCAL @@ -211,7 +219,7 @@ namespace eCAL const SDataTypeInformation& topic_info_, const Registration::DescQualityFlags topic_quality_) { - const auto topic_info_key = Registration::STopicId{ topic_id_, topic_name_ }; + const auto topic_info_key = Registration::STopicId{ ConvertToEntityId(topic_id_), topic_name_ }; Registration::SQualityTopicInfo topic_quality_info; topic_quality_info.info = topic_info_; @@ -226,7 +234,7 @@ namespace eCAL const std::string& topic_name_) { const std::unique_lock lock(topic_info_map_.mtx); - topic_info_map_.map.erase(Registration::STopicId{ topic_id_ , topic_name_}); + topic_info_map_.map.erase(Registration::STopicId{ ConvertToEntityId(topic_id_) , topic_name_}); } void CDescGate::ApplyServiceDescription(SQualityServiceIdMap& service_method_info_map_, @@ -238,7 +246,7 @@ namespace eCAL const Registration::DescQualityFlags request_type_quality_, const Registration::DescQualityFlags response_type_quality_) { - const auto service_method_info_key = Registration::SServiceId{ service_id_, service_name_, method_name_}; + const auto service_method_info_key = Registration::SServiceId{ ConvertToEntityId(service_id_), service_name_, method_name_}; Registration::SQualityServiceInfo service_quality_info; service_quality_info.info.request_type = request_type_information_; @@ -262,7 +270,7 @@ namespace eCAL { const auto service_method_info_key = service_it.first; if ((service_method_info_key.service_name == service_name_) - && (service_method_info_key.service_id == service_id_)) + && (service_method_info_key.service_id == ConvertToEntityId(service_id_))) { service_method_info_keys_to_remove.push_back(service_method_info_key); } diff --git a/ecal/core/src/serialization/ecal_struct_sample_registration.h b/ecal/core/src/serialization/ecal_struct_sample_registration.h index d0145ba01b..a6835b434e 100644 --- a/ecal/core/src/serialization/ecal_struct_sample_registration.h +++ b/ecal/core/src/serialization/ecal_struct_sample_registration.h @@ -235,6 +235,25 @@ namespace eCAL } }; + struct SampleIdentifier + { + std::string entity_id; // unique id within that process + int32_t process_id = 0; // process id which produced the sample + std::string host_name; // host which produced the sample + + bool operator==(const SampleIdentifier& other) const { + return entity_id == other.entity_id && + process_id == other.process_id && + host_name == other.host_name; + } + + bool operator<(const SampleIdentifier& other) const + { + return std::tie(process_id, entity_id, host_name) + < std::tie(other.process_id, other.entity_id, other.host_name); + } + }; + // Registration sample struct Sample {