diff --git a/ecal/core/src/pubsub/ecal_pubgate.cpp b/ecal/core/src/pubsub/ecal_pubgate.cpp index 498aec163b..671b559210 100644 --- a/ecal/core/src/pubsub/ecal_pubgate.cpp +++ b/ecal/core/src/pubsub/ecal_pubgate.cpp @@ -121,10 +121,7 @@ namespace eCAL if (topic_name.empty()) return; // TODO: Substitute ProducerInfo type - CDataWriter::SSubscriptionInfo subscription_info; - subscription_info.host_name = ecal_sample_.identifier.host_name; - subscription_info.topic_id = ecal_sample_.identifier.entity_id; - subscription_info.process_id = ecal_sample_.identifier.process_id; + const auto& subscription_info = ecal_sample_.identifier; const SDataTypeInformation topic_information = ecal_topic.tdatatype; CDataWriter::SLayerStates layer_states; @@ -181,11 +178,7 @@ namespace eCAL // check topic name if (topic_name.empty()) return; - //TODO: Remove the subscription info type - CDataWriter::SSubscriptionInfo subscription_info; - subscription_info.host_name = ecal_sample_.identifier.host_name; - subscription_info.topic_id = ecal_sample_.identifier.entity_id; - subscription_info.process_id = ecal_sample_.identifier.process_id; + const auto& subscription_info = ecal_sample_.identifier; // unregister subscriber const std::shared_lock lock(m_topic_name_datawriter_sync); diff --git a/ecal/core/src/pubsub/ecal_subgate.cpp b/ecal/core/src/pubsub/ecal_subgate.cpp index bd2f163324..314d4b005a 100644 --- a/ecal/core/src/pubsub/ecal_subgate.cpp +++ b/ecal/core/src/pubsub/ecal_subgate.cpp @@ -219,11 +219,7 @@ namespace eCAL // check topic name if (topic_name.empty()) return; - // TODO: Remove the PublicationInfo type - CDataReader::SPublicationInfo publication_info; - publication_info.host_name = ecal_sample_.identifier.host_name; - publication_info.topic_id = ecal_sample_.identifier.entity_id; - publication_info.process_id = ecal_sample_.identifier.process_id; + const auto& publication_info = ecal_sample_.identifier; const SDataTypeInformation topic_information = ecal_topic.tdatatype; CDataReader::SLayerStates layer_states; @@ -283,11 +279,7 @@ namespace eCAL // check topic name if (topic_name.empty()) return; - // TODO: Remove the SPublicationInfo type! - CDataReader::SPublicationInfo publication_info; - publication_info.host_name = ecal_sample_.identifier.host_name; - publication_info.topic_id = ecal_sample_.identifier.entity_id; - publication_info.process_id = ecal_sample_.identifier.process_id; + const auto& publication_info = ecal_sample_.identifier; // unregister publisher const std::shared_lock lock(m_topic_name_datareader_sync); diff --git a/ecal/core/src/readwrite/ecal_reader.cpp b/ecal/core/src/readwrite/ecal_reader.cpp index 6f590d4b9d..6b84834379 100644 --- a/ecal/core/src/readwrite/ecal_reader.cpp +++ b/ecal/core/src/readwrite/ecal_reader.cpp @@ -294,7 +294,7 @@ namespace eCAL m_layers.tcp.write_enabled = layer_states_.tcp.write_enabled; #endif - FireConnectEvent(publication_info_.topic_id, data_type_info_); + FireConnectEvent(publication_info_.entity_id, data_type_info_); // add key to publisher map { @@ -318,7 +318,7 @@ namespace eCAL par.host_name = publication_info_.host_name; par.process_id = publication_info_.process_id; par.topic_name = m_topic_name; - par.topic_id = publication_info_.topic_id; + par.topic_id = publication_info_.entity_id; par.parameter = parameter_; switch (type_) diff --git a/ecal/core/src/readwrite/ecal_reader.h b/ecal/core/src/readwrite/ecal_reader.h index c6955e2d69..6c4a0cf401 100644 --- a/ecal/core/src/readwrite/ecal_reader.h +++ b/ecal/core/src/readwrite/ecal_reader.h @@ -64,19 +64,7 @@ namespace eCAL SLayerState tcp; }; - struct SPublicationInfo - { - std::string host_name; - int32_t process_id = 0; - std::string topic_id; - - friend bool operator<(const SPublicationInfo& l, const SPublicationInfo& r) - { - return std::tie(l.host_name, l.process_id, l.topic_id) - < std::tie(r.host_name, r.process_id, r.topic_id); - } - }; - + using SPublicationInfo = Registration::SampleIdentifier; CDataReader(const std::string& topic_name_, const SDataTypeInformation& topic_info_, const Subscriber::Configuration& config_ = {}); ~CDataReader(); diff --git a/ecal/core/src/readwrite/ecal_writer.cpp b/ecal/core/src/readwrite/ecal_writer.cpp index 2c08fef928..a8365a09fd 100644 --- a/ecal/core/src/readwrite/ecal_writer.cpp +++ b/ecal/core/src/readwrite/ecal_writer.cpp @@ -432,7 +432,7 @@ namespace eCAL void CDataWriter::ApplySubscription(const SSubscriptionInfo& subscription_info_, const SDataTypeInformation& data_type_info_, const SLayerStates& sub_layer_states_, const std::string& reader_par_) { - FireConnectEvent(subscription_info_.topic_id, data_type_info_); + FireConnectEvent(subscription_info_.entity_id, data_type_info_); // collect layer states std::vector pub_layers; @@ -488,13 +488,13 @@ namespace eCAL // add a new subscription #if ECAL_CORE_TRANSPORT_UDP - if (m_writer_udp) m_writer_udp->ApplySubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.topic_id, reader_par_); + if (m_writer_udp) m_writer_udp->ApplySubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.entity_id, reader_par_); #endif #if ECAL_CORE_TRANSPORT_SHM - if (m_writer_shm) m_writer_shm->ApplySubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.topic_id, reader_par_); + if (m_writer_shm) m_writer_shm->ApplySubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.entity_id, reader_par_); #endif #if ECAL_CORE_TRANSPORT_TCP - if (m_writer_tcp) m_writer_tcp->ApplySubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.topic_id, reader_par_); + if (m_writer_tcp) m_writer_tcp->ApplySubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.entity_id, reader_par_); #endif #ifndef NDEBUG @@ -513,13 +513,13 @@ namespace eCAL // remove subscription #if ECAL_CORE_TRANSPORT_UDP - if (m_writer_udp) m_writer_udp->RemoveSubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.topic_id); + if (m_writer_udp) m_writer_udp->RemoveSubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.entity_id); #endif #if ECAL_CORE_TRANSPORT_SHM - if (m_writer_shm) m_writer_shm->RemoveSubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.topic_id); + if (m_writer_shm) m_writer_shm->RemoveSubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.entity_id); #endif #if ECAL_CORE_TRANSPORT_TCP - if (m_writer_tcp) m_writer_tcp->RemoveSubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.topic_id); + if (m_writer_tcp) m_writer_tcp->RemoveSubscription(subscription_info_.host_name, subscription_info_.process_id, subscription_info_.entity_id); #endif #ifndef NDEBUG diff --git a/ecal/core/src/readwrite/ecal_writer.h b/ecal/core/src/readwrite/ecal_writer.h index 1ea35da0d0..acb6c784bc 100644 --- a/ecal/core/src/readwrite/ecal_writer.h +++ b/ecal/core/src/readwrite/ecal_writer.h @@ -74,18 +74,7 @@ namespace eCAL SLayerState tcp; }; - struct SSubscriptionInfo - { - std::string host_name; - int32_t process_id = 0; - std::string topic_id; - - friend bool operator<(const SSubscriptionInfo& l, const SSubscriptionInfo& r) - { - return std::tie(l.host_name, l.process_id, l.topic_id) - < std::tie(r.host_name, r.process_id, r.topic_id); - } - }; + using SSubscriptionInfo = Registration::SampleIdentifier; CDataWriter(const std::string& topic_name_, const SDataTypeInformation& topic_info_, const Publisher::Configuration& config_ = {}); ~CDataWriter(); diff --git a/ecal/core/src/serialization/ecal_struct_sample_registration.h b/ecal/core/src/serialization/ecal_struct_sample_registration.h index 13d6c8d534..f3a65fd98f 100644 --- a/ecal/core/src/serialization/ecal_struct_sample_registration.h +++ b/ecal/core/src/serialization/ecal_struct_sample_registration.h @@ -167,6 +167,13 @@ namespace eCAL 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 std::tie(process_id, entity_id, host_name) + < std::tie(other.process_id, other.entity_id, other.host_name); + } }; // Registration sample