Skip to content

Commit

Permalink
[core] eCAL sample completely internal, only SEntityId public.
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Aug 19, 2024
1 parent 6a44dad commit b9d1ccf
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
16 changes: 8 additions & 8 deletions ecal/core/include/ecal/ecal_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
16 changes: 12 additions & 4 deletions ecal/core/src/ecal_descgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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_;
Expand All @@ -226,7 +234,7 @@ namespace eCAL
const std::string& topic_name_)
{
const std::unique_lock<std::mutex> 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_,
Expand All @@ -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_;
Expand All @@ -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);
}
Expand Down
19 changes: 19 additions & 0 deletions ecal/core/src/serialization/ecal_struct_sample_registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit b9d1ccf

Please sign in to comment.