Skip to content

Commit 51448ae

Browse files
Refs #21745. Make lambda a reusable public method
Signed-off-by: Juan Lopez Fernandez <[email protected]>
1 parent 05f1b56 commit 51448ae

File tree

3 files changed

+31
-40
lines changed

3 files changed

+31
-40
lines changed

include/fastdds/dds/domain/qos/DomainParticipantQos.hpp

+10-20
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,6 @@ class DomainParticipantQos
7878
virtual bool operator ==(
7979
const DomainParticipantQos& b) const
8080
{
81-
auto compare_flow_controllers = [](const DomainParticipantQos& lhs, const DomainParticipantQos& rhs) -> bool
82-
{
83-
const auto& lhs_flow_controllers = lhs.flow_controllers();
84-
const auto& rhs_flow_controllers = rhs.flow_controllers();
85-
86-
if (lhs_flow_controllers.size() != rhs_flow_controllers.size())
87-
{
88-
return false;
89-
}
90-
91-
return std::equal(lhs_flow_controllers.begin(), lhs_flow_controllers.end(),
92-
rhs_flow_controllers.begin(),
93-
[](const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& a,
94-
const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& b)
95-
{
96-
return *a == *b;
97-
});
98-
};
99-
10081
return (this->user_data_ == b.user_data()) &&
10182
(this->entity_factory_ == b.entity_factory()) &&
10283
(this->allocation_ == b.allocation()) &&
@@ -111,7 +92,7 @@ class DomainParticipantQos
11192
#if HAVE_SECURITY
11293
(this->security_log_thread_ == b.security_log_thread()) &&
11394
#endif // if HAVE_SECURITY
114-
(compare_flow_controllers(*this, b));
95+
(compare_flow_controllers(b));
11596
}
11697

11798
/**
@@ -341,6 +322,15 @@ class DomainParticipantQos
341322
return flow_controllers_;
342323
}
343324

325+
/**
326+
* Compares the flow controllers of two DomainParticipantQos element-wise.
327+
*
328+
* @param qos The DomainParticipantQos to compare with.
329+
* @return true if the flow controllers are the same, false otherwise.
330+
*/
331+
FASTDDS_EXPORTED_API bool compare_flow_controllers(
332+
const DomainParticipantQos& qos) const;
333+
344334
/**
345335
* Getter for FlowControllerDescriptorList
346336
*

src/cpp/fastdds/domain/qos/DomainParticipantQos.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ void DomainParticipantQos::setup_transports(
4141
utils::set_qos_from_attributes(*this, attr);
4242
}
4343

44+
bool DomainParticipantQos::compare_flow_controllers(
45+
const DomainParticipantQos& qos) const
46+
{
47+
const auto& lhs_flow_controllers = flow_controllers();
48+
const auto& rhs_flow_controllers = qos.flow_controllers();
49+
50+
if (lhs_flow_controllers.size() != rhs_flow_controllers.size())
51+
{
52+
return false;
53+
}
54+
55+
return std::equal(lhs_flow_controllers.begin(), lhs_flow_controllers.end(),
56+
rhs_flow_controllers.begin(),
57+
[](const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& a,
58+
const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& b)
59+
{
60+
return *a == *b;
61+
});
62+
}
63+
4464
} /* namespace dds */
4565
} /* namespace fastdds */
4666
} /* namespace eprosima */

test/unittest/dds/participant/ParticipantTests.cpp

+1-20
Original file line numberDiff line numberDiff line change
@@ -500,26 +500,7 @@ void check_equivalent_qos(
500500
ASSERT_EQ(qos_1.security_log_thread(), qos_2.security_log_thread());
501501
#endif // if HAVE_SECURITY
502502

503-
auto compare_flow_controllers = [](const DomainParticipantQos& lhs, const DomainParticipantQos& rhs) -> bool
504-
{
505-
const auto& lhs_flow_controllers = lhs.flow_controllers();
506-
const auto& rhs_flow_controllers = rhs.flow_controllers();
507-
508-
if (lhs_flow_controllers.size() != rhs_flow_controllers.size())
509-
{
510-
return false;
511-
}
512-
513-
return std::equal(lhs_flow_controllers.begin(), lhs_flow_controllers.end(),
514-
rhs_flow_controllers.begin(),
515-
[](const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& a,
516-
const std::shared_ptr<fastdds::rtps::FlowControllerDescriptor>& b)
517-
{
518-
return *a == *b;
519-
});
520-
};
521-
522-
ASSERT_TRUE(compare_flow_controllers(qos_1, qos_2));
503+
ASSERT_TRUE(qos_1.compare_flow_controllers(qos_2));
523504
}
524505

525506
void check_participant_with_profile(

0 commit comments

Comments
 (0)