Skip to content

Commit

Permalink
Move DR TypeConsistencyEnforcement & DataRepresentation from TypeCons…
Browse files Browse the repository at this point in the history
…istency to DataReaderQos (#4823)

* Refs #21053: Move DR TypeConsistencyEnforcementQosPolicy & DataRepresentationQosPolicy to correct place

Signed-off-by: JesusPoderoso <[email protected]>

* Refs #21053: Apply rev suggestions

Signed-off-by: JesusPoderoso <[email protected]>

---------

Signed-off-by: JesusPoderoso <[email protected]>
  • Loading branch information
JesusPoderoso authored May 27, 2024
1 parent e317234 commit 623685d
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 141 deletions.
96 changes: 46 additions & 50 deletions include/fastdds/dds/subscriber/qos/DataReaderQos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,45 +126,6 @@ class ReaderResourceLimitsQos
int32_t max_samples_per_read = 32;
};

//! Qos Policy to configure the XTypes Qos associated to the DataReader
class TypeConsistencyQos : public QosPolicy
{
public:

/**
* @brief Constructor
*/
FASTDDS_EXPORTED_API TypeConsistencyQos()
: QosPolicy(false)
{
}

/**
* @brief Destructor
*/
virtual FASTDDS_EXPORTED_API ~TypeConsistencyQos() = default;

bool operator ==(
const TypeConsistencyQos& b) const
{
return (this->type_consistency == b.type_consistency) &&
(this->representation == b.representation) &&
QosPolicy::operator ==(b);
}

inline void clear() override
{
TypeConsistencyQos reset = TypeConsistencyQos();
std::swap(*this, reset);
}

//!Type consistency enforcement Qos.
TypeConsistencyEnforcementQosPolicy type_consistency;

//!Data Representation Qos.
DataRepresentationQosPolicy representation;
};

/**
* Class DataReaderQos, containing all the possible Qos that can be set for a determined DataReader.
* Although these values can be set and are transmitted
Expand Down Expand Up @@ -203,6 +164,7 @@ class DataReaderQos
(durability_service_ == b.durability_service()) &&
(reliable_reader_qos_ == b.reliable_reader_qos()) &&
(type_consistency_ == b.type_consistency()) &&
(representation_ == b.representation()) &&
(expects_inline_qos_ == b.expects_inline_qos()) &&
(properties_ == b.properties()) &&
(endpoint_ == b.endpoint()) &&
Expand Down Expand Up @@ -679,36 +641,67 @@ class DataReaderQos
}

/**
* Getter for TypeConsistencyQos
* Getter for TypeConsistencyEnforcementQosPolicy
*
* @return TypeConsistencyQos reference
* @return TypeConsistencyEnforcementQosPolicy reference
*/
FASTDDS_EXPORTED_API TypeConsistencyQos& type_consistency()
FASTDDS_EXPORTED_API TypeConsistencyEnforcementQosPolicy& type_consistency()
{
return type_consistency_;
}

/**
* Getter for TypeConsistencyQos
* Getter for TypeConsistencyEnforcementQosPolicy
*
* @return TypeConsistencyQos const reference
* @return TypeConsistencyEnforcementQosPolicy const reference
*/
FASTDDS_EXPORTED_API const TypeConsistencyQos& type_consistency() const
FASTDDS_EXPORTED_API const TypeConsistencyEnforcementQosPolicy& type_consistency() const
{
return type_consistency_;
}

/**
* Setter for TypeConsistencyQos
* Setter for TypeConsistencyEnforcementQosPolicy
*
* @param new_value new value for the TypeConsistencyQos
* @param new_value new value for the TypeConsistencyEnforcementQosPolicy
*/
FASTDDS_EXPORTED_API void type_consistency(
const TypeConsistencyQos& new_value)
const TypeConsistencyEnforcementQosPolicy& new_value)
{
type_consistency_ = new_value;
}

/**
* Getter for DataRepresentationQosPolicy
*
* @return DataRepresentationQosPolicy reference
*/
FASTDDS_EXPORTED_API const DataRepresentationQosPolicy& representation() const
{
return representation_;
}

/**
* Getter for DataRepresentationQosPolicy
*
* @return DataRepresentationQosPolicy reference
*/
FASTDDS_EXPORTED_API DataRepresentationQosPolicy& representation()
{
return representation_;
}

/**
* Setter for DataRepresentationQosPolicy
*
* @param representation new value for the DataRepresentationQosPolicy
*/
FASTDDS_EXPORTED_API void representation(
const DataRepresentationQosPolicy& representation)
{
representation_ = representation;
}

/**
* Getter for expectsInlineQos
*
Expand Down Expand Up @@ -901,8 +894,11 @@ class DataReaderQos
//!Reliable reader configuration (Extension)
RTPSReliableReaderQos reliable_reader_qos_;

//! Tipe consistency (Extension)
TypeConsistencyQos type_consistency_;
//! Type consistency (Extension)
TypeConsistencyEnforcementQosPolicy type_consistency_;

//! Data representation (Extension)
DataRepresentationQosPolicy representation_;

//!Expects Inline QOS (Extension).
bool expects_inline_qos_;
Expand Down
9 changes: 7 additions & 2 deletions src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,11 @@ void DataReaderImpl::set_qos(
to.type_consistency() = from.type_consistency();
to.type_consistency().hasChanged = true;
}
if (first_time || !(to.representation() == from.representation()))
{
to.representation() = from.representation();
to.representation().hasChanged = true;
}
if (first_time && (to.history().kind != from.history().kind ||
to.history().depth != from.history().depth))
{
Expand Down Expand Up @@ -1804,9 +1809,9 @@ std::shared_ptr<IPayloadPool> DataReaderImpl::get_payload_pool()
{
// Check whether DataReader's type is plain in all its data representations
bool is_plain = true;
if (qos_.type_consistency().representation.m_value.size() > 0)
if (qos_.representation().m_value.size() > 0)
{
for (auto data_representation : qos_.type_consistency().representation.m_value)
for (auto data_representation : qos_.representation().m_value)
{
is_plain = is_plain && type_->is_plain(data_representation);
}
Expand Down
3 changes: 1 addition & 2 deletions src/cpp/fastdds/subscriber/SubscriberImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ ReturnCode_t SubscriberImpl::copy_from_topic_qos(
DataReaderQos& reader_qos,
const TopicQos& topic_qos)
{
TypeConsistencyQos new_value;
reader_qos.durability(topic_qos.durability());
reader_qos.durability_service(topic_qos.durability_service());
reader_qos.deadline(topic_qos.deadline());
Expand All @@ -452,7 +451,7 @@ ReturnCode_t SubscriberImpl::copy_from_topic_qos(
reader_qos.history(topic_qos.history());
reader_qos.resource_limits(topic_qos.resource_limits());
reader_qos.ownership(topic_qos.ownership());
reader_qos.type_consistency().representation = topic_qos.representation();
reader_qos.representation() = topic_qos.representation();
return RETCODE_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/fastdds/subscriber/qos/DataReaderQos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ ReaderQos DataReaderQos::get_readerqos(
//qos.m_topicData --> TODO: Fill with TopicQos info
qos.m_durabilityService = durability_service();
qos.m_disablePositiveACKs = reliable_reader_qos().disable_positive_ACKs;
qos.type_consistency = type_consistency().type_consistency;
qos.representation = type_consistency().representation;
qos.type_consistency = type_consistency();
qos.representation = representation();
qos.data_sharing = data_sharing();

if (qos.data_sharing.kind() != OFF &&
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/fastdds/utils/QosConverters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ void set_qos_from_attributes(
qos.user_data().setValue(attr.qos.m_userData);
qos.ownership() = attr.qos.m_ownership;
qos.destination_order() = attr.qos.m_destinationOrder;
qos.type_consistency().type_consistency = attr.qos.type_consistency;
qos.type_consistency().representation = attr.qos.representation;
qos.type_consistency() = attr.qos.type_consistency;
qos.representation() = attr.qos.representation;
qos.time_based_filter() = attr.qos.m_timeBasedFilter;
qos.history() = attr.topic.historyQos;
qos.resource_limits() = attr.topic.resourceLimitsQos;
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/PubSubReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ class PubSubReader
PubSubReader& data_representation(
const std::vector<eprosima::fastdds::dds::DataRepresentationId_t>& values)
{
datareader_qos_.type_consistency().representation.m_value = values;
datareader_qos_.representation().m_value = values;
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/common/DDSBlackboxTestsDataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ template<>
void TestsDataReaderQosCommonUtils::set_representation_qos(
eprosima::fastdds::dds::DataReaderQos& qos)
{
qos.type_consistency().representation.m_value.push_back(
qos.representation().m_value.push_back(
eprosima::fastdds::dds::DataRepresentationId_t::XCDR2_DATA_REPRESENTATION);
}

Expand Down
10 changes: 5 additions & 5 deletions test/unittest/dds/subscriber/DataReaderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3870,8 +3870,8 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation)
/* Define XCDR1 only data representation QoS to force "is_plain" call */
DataReaderQos qos_xcdr = DATAREADER_QOS_DEFAULT;
qos_xcdr.endpoint().history_memory_policy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
qos_xcdr.type_consistency().representation.m_value.clear();
qos_xcdr.type_consistency().representation.m_value.push_back(DataRepresentationId_t::XCDR_DATA_REPRESENTATION);
qos_xcdr.representation().m_value.clear();
qos_xcdr.representation().m_value.push_back(DataRepresentationId_t::XCDR_DATA_REPRESENTATION);

/* Expect the "is_plain" method called with default data representation (XCDR1) */
EXPECT_CALL(*type, custom_is_plain()).Times(0);
Expand All @@ -3888,8 +3888,8 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation)
/* Define XCDR2 data representation QoS to force "is_plain" call */
DataReaderQos qos_xcdr2 = DATAREADER_QOS_DEFAULT;
qos_xcdr2.endpoint().history_memory_policy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
qos_xcdr2.type_consistency().representation.m_value.clear();
qos_xcdr2.type_consistency().representation.m_value.push_back(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION);
qos_xcdr2.representation().m_value.clear();
qos_xcdr2.representation().m_value.push_back(DataRepresentationId_t::XCDR2_DATA_REPRESENTATION);

/* Expect the "is_plain" method called with XCDR2 data representation */
EXPECT_CALL(*type, custom_is_plain()).Times(0);
Expand All @@ -3904,7 +3904,7 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation)
/* NOT Define data representation QoS to force "is_plain" call */
DataReaderQos qos_no_xcdr = DATAREADER_QOS_DEFAULT;
qos_no_xcdr.endpoint().history_memory_policy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
qos_no_xcdr.type_consistency().representation.m_value.clear();
qos_no_xcdr.representation().m_value.clear();

/* Expect the "is_plain" method called with both data representation */
EXPECT_CALL(*type, custom_is_plain()).Times(0);
Expand Down
Loading

0 comments on commit 623685d

Please sign in to comment.