Skip to content

Commit 623685d

Browse files
Move DR TypeConsistencyEnforcement & DataRepresentation from TypeConsistency to DataReaderQos (#4823)
* Refs #21053: Move DR TypeConsistencyEnforcementQosPolicy & DataRepresentationQosPolicy to correct place Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> * Refs #21053: Apply rev suggestions Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> --------- Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
1 parent e317234 commit 623685d

10 files changed

Lines changed: 143 additions & 141 deletions

File tree

include/fastdds/dds/subscriber/qos/DataReaderQos.hpp

Lines changed: 46 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -126,45 +126,6 @@ class ReaderResourceLimitsQos
126126
int32_t max_samples_per_read = 32;
127127
};
128128

129-
//! Qos Policy to configure the XTypes Qos associated to the DataReader
130-
class TypeConsistencyQos : public QosPolicy
131-
{
132-
public:
133-
134-
/**
135-
* @brief Constructor
136-
*/
137-
FASTDDS_EXPORTED_API TypeConsistencyQos()
138-
: QosPolicy(false)
139-
{
140-
}
141-
142-
/**
143-
* @brief Destructor
144-
*/
145-
virtual FASTDDS_EXPORTED_API ~TypeConsistencyQos() = default;
146-
147-
bool operator ==(
148-
const TypeConsistencyQos& b) const
149-
{
150-
return (this->type_consistency == b.type_consistency) &&
151-
(this->representation == b.representation) &&
152-
QosPolicy::operator ==(b);
153-
}
154-
155-
inline void clear() override
156-
{
157-
TypeConsistencyQos reset = TypeConsistencyQos();
158-
std::swap(*this, reset);
159-
}
160-
161-
//!Type consistency enforcement Qos.
162-
TypeConsistencyEnforcementQosPolicy type_consistency;
163-
164-
//!Data Representation Qos.
165-
DataRepresentationQosPolicy representation;
166-
};
167-
168129
/**
169130
* Class DataReaderQos, containing all the possible Qos that can be set for a determined DataReader.
170131
* Although these values can be set and are transmitted
@@ -203,6 +164,7 @@ class DataReaderQos
203164
(durability_service_ == b.durability_service()) &&
204165
(reliable_reader_qos_ == b.reliable_reader_qos()) &&
205166
(type_consistency_ == b.type_consistency()) &&
167+
(representation_ == b.representation()) &&
206168
(expects_inline_qos_ == b.expects_inline_qos()) &&
207169
(properties_ == b.properties()) &&
208170
(endpoint_ == b.endpoint()) &&
@@ -679,36 +641,67 @@ class DataReaderQos
679641
}
680642

681643
/**
682-
* Getter for TypeConsistencyQos
644+
* Getter for TypeConsistencyEnforcementQosPolicy
683645
*
684-
* @return TypeConsistencyQos reference
646+
* @return TypeConsistencyEnforcementQosPolicy reference
685647
*/
686-
FASTDDS_EXPORTED_API TypeConsistencyQos& type_consistency()
648+
FASTDDS_EXPORTED_API TypeConsistencyEnforcementQosPolicy& type_consistency()
687649
{
688650
return type_consistency_;
689651
}
690652

691653
/**
692-
* Getter for TypeConsistencyQos
654+
* Getter for TypeConsistencyEnforcementQosPolicy
693655
*
694-
* @return TypeConsistencyQos const reference
656+
* @return TypeConsistencyEnforcementQosPolicy const reference
695657
*/
696-
FASTDDS_EXPORTED_API const TypeConsistencyQos& type_consistency() const
658+
FASTDDS_EXPORTED_API const TypeConsistencyEnforcementQosPolicy& type_consistency() const
697659
{
698660
return type_consistency_;
699661
}
700662

701663
/**
702-
* Setter for TypeConsistencyQos
664+
* Setter for TypeConsistencyEnforcementQosPolicy
703665
*
704-
* @param new_value new value for the TypeConsistencyQos
666+
* @param new_value new value for the TypeConsistencyEnforcementQosPolicy
705667
*/
706668
FASTDDS_EXPORTED_API void type_consistency(
707-
const TypeConsistencyQos& new_value)
669+
const TypeConsistencyEnforcementQosPolicy& new_value)
708670
{
709671
type_consistency_ = new_value;
710672
}
711673

674+
/**
675+
* Getter for DataRepresentationQosPolicy
676+
*
677+
* @return DataRepresentationQosPolicy reference
678+
*/
679+
FASTDDS_EXPORTED_API const DataRepresentationQosPolicy& representation() const
680+
{
681+
return representation_;
682+
}
683+
684+
/**
685+
* Getter for DataRepresentationQosPolicy
686+
*
687+
* @return DataRepresentationQosPolicy reference
688+
*/
689+
FASTDDS_EXPORTED_API DataRepresentationQosPolicy& representation()
690+
{
691+
return representation_;
692+
}
693+
694+
/**
695+
* Setter for DataRepresentationQosPolicy
696+
*
697+
* @param representation new value for the DataRepresentationQosPolicy
698+
*/
699+
FASTDDS_EXPORTED_API void representation(
700+
const DataRepresentationQosPolicy& representation)
701+
{
702+
representation_ = representation;
703+
}
704+
712705
/**
713706
* Getter for expectsInlineQos
714707
*
@@ -901,8 +894,11 @@ class DataReaderQos
901894
//!Reliable reader configuration (Extension)
902895
RTPSReliableReaderQos reliable_reader_qos_;
903896

904-
//! Tipe consistency (Extension)
905-
TypeConsistencyQos type_consistency_;
897+
//! Type consistency (Extension)
898+
TypeConsistencyEnforcementQosPolicy type_consistency_;
899+
900+
//! Data representation (Extension)
901+
DataRepresentationQosPolicy representation_;
906902

907903
//!Expects Inline QOS (Extension).
908904
bool expects_inline_qos_;

src/cpp/fastdds/subscriber/DataReaderImpl.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,11 @@ void DataReaderImpl::set_qos(
17171717
to.type_consistency() = from.type_consistency();
17181718
to.type_consistency().hasChanged = true;
17191719
}
1720+
if (first_time || !(to.representation() == from.representation()))
1721+
{
1722+
to.representation() = from.representation();
1723+
to.representation().hasChanged = true;
1724+
}
17201725
if (first_time && (to.history().kind != from.history().kind ||
17211726
to.history().depth != from.history().depth))
17221727
{
@@ -1804,9 +1809,9 @@ std::shared_ptr<IPayloadPool> DataReaderImpl::get_payload_pool()
18041809
{
18051810
// Check whether DataReader's type is plain in all its data representations
18061811
bool is_plain = true;
1807-
if (qos_.type_consistency().representation.m_value.size() > 0)
1812+
if (qos_.representation().m_value.size() > 0)
18081813
{
1809-
for (auto data_representation : qos_.type_consistency().representation.m_value)
1814+
for (auto data_representation : qos_.representation().m_value)
18101815
{
18111816
is_plain = is_plain && type_->is_plain(data_representation);
18121817
}

src/cpp/fastdds/subscriber/SubscriberImpl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ ReturnCode_t SubscriberImpl::copy_from_topic_qos(
441441
DataReaderQos& reader_qos,
442442
const TopicQos& topic_qos)
443443
{
444-
TypeConsistencyQos new_value;
445444
reader_qos.durability(topic_qos.durability());
446445
reader_qos.durability_service(topic_qos.durability_service());
447446
reader_qos.deadline(topic_qos.deadline());
@@ -452,7 +451,7 @@ ReturnCode_t SubscriberImpl::copy_from_topic_qos(
452451
reader_qos.history(topic_qos.history());
453452
reader_qos.resource_limits(topic_qos.resource_limits());
454453
reader_qos.ownership(topic_qos.ownership());
455-
reader_qos.type_consistency().representation = topic_qos.representation();
454+
reader_qos.representation() = topic_qos.representation();
456455
return RETCODE_OK;
457456
}
458457

src/cpp/fastdds/subscriber/qos/DataReaderQos.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ ReaderQos DataReaderQos::get_readerqos(
4747
//qos.m_topicData --> TODO: Fill with TopicQos info
4848
qos.m_durabilityService = durability_service();
4949
qos.m_disablePositiveACKs = reliable_reader_qos().disable_positive_ACKs;
50-
qos.type_consistency = type_consistency().type_consistency;
51-
qos.representation = type_consistency().representation;
50+
qos.type_consistency = type_consistency();
51+
qos.representation = representation();
5252
qos.data_sharing = data_sharing();
5353

5454
if (qos.data_sharing.kind() != OFF &&

src/cpp/fastdds/utils/QosConverters.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ void set_qos_from_attributes(
110110
qos.user_data().setValue(attr.qos.m_userData);
111111
qos.ownership() = attr.qos.m_ownership;
112112
qos.destination_order() = attr.qos.m_destinationOrder;
113-
qos.type_consistency().type_consistency = attr.qos.type_consistency;
114-
qos.type_consistency().representation = attr.qos.representation;
113+
qos.type_consistency() = attr.qos.type_consistency;
114+
qos.representation() = attr.qos.representation;
115115
qos.time_based_filter() = attr.qos.m_timeBasedFilter;
116116
qos.history() = attr.topic.historyQos;
117117
qos.resource_limits() = attr.topic.resourceLimitsQos;

test/blackbox/api/dds-pim/PubSubReader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ class PubSubReader
15941594
PubSubReader& data_representation(
15951595
const std::vector<eprosima::fastdds::dds::DataRepresentationId_t>& values)
15961596
{
1597-
datareader_qos_.type_consistency().representation.m_value = values;
1597+
datareader_qos_.representation().m_value = values;
15981598
return *this;
15991599
}
16001600

test/blackbox/common/DDSBlackboxTestsDataReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ template<>
465465
void TestsDataReaderQosCommonUtils::set_representation_qos(
466466
eprosima::fastdds::dds::DataReaderQos& qos)
467467
{
468-
qos.type_consistency().representation.m_value.push_back(
468+
qos.representation().m_value.push_back(
469469
eprosima::fastdds::dds::DataRepresentationId_t::XCDR2_DATA_REPRESENTATION);
470470
}
471471

test/unittest/dds/subscriber/DataReaderTests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3870,8 +3870,8 @@ TEST_F(DataReaderTests, data_type_is_plain_data_representation)
38703870
/* Define XCDR1 only data representation QoS to force "is_plain" call */
38713871
DataReaderQos qos_xcdr = DATAREADER_QOS_DEFAULT;
38723872
qos_xcdr.endpoint().history_memory_policy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
3873-
qos_xcdr.type_consistency().representation.m_value.clear();
3874-
qos_xcdr.type_consistency().representation.m_value.push_back(DataRepresentationId_t::XCDR_DATA_REPRESENTATION);
3873+
qos_xcdr.representation().m_value.clear();
3874+
qos_xcdr.representation().m_value.push_back(DataRepresentationId_t::XCDR_DATA_REPRESENTATION);
38753875

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

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

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

0 commit comments

Comments
 (0)