Skip to content

Commit

Permalink
[core] Remove SPublicationInfo / SSubscriptionInfo type.
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Aug 6, 2024
1 parent 5a4300b commit d6db6e4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 53 deletions.
11 changes: 2 additions & 9 deletions ecal/core/src/pubsub/ecal_pubgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<std::shared_timed_mutex> lock(m_topic_name_datawriter_sync);
Expand Down
12 changes: 2 additions & 10 deletions ecal/core/src/pubsub/ecal_subgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<std::shared_timed_mutex> lock(m_topic_name_datareader_sync);
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/readwrite/ecal_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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_)
Expand Down
14 changes: 1 addition & 13 deletions ecal/core/src/readwrite/ecal_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
14 changes: 7 additions & 7 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<eTLayerType> pub_layers;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 1 addition & 12 deletions ecal/core/src/readwrite/ecal_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions ecal/core/src/serialization/ecal_struct_sample_registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d6db6e4

Please sign in to comment.