Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Commit

Permalink
fix windows build warnings (#269)
Browse files Browse the repository at this point in the history
Signed-off-by: Miaofei <[email protected]>
  • Loading branch information
mm318 authored and dirk-thomas committed May 8, 2019
1 parent bcf68fe commit 81e90b8
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions rmw_opensplice_cpp/src/qos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
using rosidl_typesupport_opensplice_cpp::impl::check_get_default_datareader_qos;
using rosidl_typesupport_opensplice_cpp::impl::check_get_default_datawriter_qos;

static bool
is_time_default(const rmw_time_t & time)
{
return time.sec == 0 && time.nsec == 0;
}

static DDS::Duration_t
rmw_time_to_dds(const rmw_time_t & time)
{
DDS::Duration_t duration;
duration.sec = static_cast<DDS::Long>(time.sec);
duration.nanosec = static_cast<DDS::ULong>(time.nsec);
return duration;
}

template<typename DDSEntityQos>
bool set_entity_qos_from_profile_generic(
const rmw_qos_profile_t & qos_profile,
Expand Down Expand Up @@ -75,9 +90,8 @@ bool set_entity_qos_from_profile_generic(
}

// DDS_DeadlineQosPolicy has default value of DDS_DURATION_INFINITE, don't touch it for 0
if (qos_profile.deadline.sec != 0 || qos_profile.deadline.nsec != 0) {
entity_qos.deadline.period.sec = qos_profile.deadline.sec;
entity_qos.deadline.period.nanosec = qos_profile.deadline.nsec;
if (!is_time_default(qos_profile.deadline)) {
entity_qos.deadline.period = rmw_time_to_dds(qos_profile.deadline);
}

switch (qos_profile.liveliness) {
Expand All @@ -96,11 +110,8 @@ bool set_entity_qos_from_profile_generic(
RMW_SET_ERROR_MSG("Unknown QoS liveliness policy");
return false;
}
if (qos_profile.liveliness_lease_duration.sec != 0 ||
qos_profile.liveliness_lease_duration.nsec != 0)
{
entity_qos.liveliness.lease_duration.sec = qos_profile.liveliness_lease_duration.sec;
entity_qos.liveliness.lease_duration.nanosec = qos_profile.liveliness_lease_duration.nsec;
if (!is_time_default(qos_profile.liveliness_lease_duration)) {
entity_qos.liveliness.lease_duration = rmw_time_to_dds(qos_profile.liveliness_lease_duration);
}

// ensure the history depth is at least the requested queue size
Expand Down Expand Up @@ -135,9 +146,8 @@ set_entity_qos_from_profile(
DDS::DataWriterQos & entity_qos)
{
// Set any QoS settings that are specific to DataWriter, then call the shared version
if (qos_profile.lifespan.sec != 0 || qos_profile.lifespan.nsec != 0) {
entity_qos.lifespan.duration.sec = qos_profile.lifespan.sec;
entity_qos.lifespan.duration.nanosec = qos_profile.lifespan.nsec;
if (!is_time_default(qos_profile.lifespan)) {
entity_qos.lifespan.duration = rmw_time_to_dds(qos_profile.lifespan);
}
return set_entity_qos_from_profile_generic(qos_profile, entity_qos);
}
Expand Down

0 comments on commit 81e90b8

Please sign in to comment.