Fixed inconsistencies in connect/connack property accessor function signatures

Summary: related to T11798

Reviewers: ivica

Reviewed By: ivica

Subscribers: miljen, iljazovic

Differential Revision: https://repo.mireo.local/D27941
This commit is contained in:
Korina Šimičević
2024-02-15 13:13:29 +01:00
parent 9cb54f73a4
commit eb510ae1d4
3 changed files with 53 additions and 29 deletions

View File

@@ -71,26 +71,32 @@ public:
_mqtt_context.will_msg = std::move(will); _mqtt_context.will_msg = std::move(will);
} }
template <typename Prop> template <prop::property_type p>
const auto& connack_property(Prop p) const { const auto& connack_property(
return _mqtt_context.ca_props[p]; std::integral_constant<prop::property_type, p> prop
) const {
return _mqtt_context.ca_props[prop];
} }
const auto& connack_properties() const { const auto& connack_properties() const {
return _mqtt_context.ca_props; return _mqtt_context.ca_props;
} }
template <typename Prop> template <prop::property_type p>
const auto& connect_property(Prop p) const { const auto& connect_property(
return _mqtt_context.co_props[p]; std::integral_constant<prop::property_type, p> prop
) const {
return _mqtt_context.co_props[prop];
} }
template <typename Prop> template <prop::property_type p>
auto& connect_property(Prop p) { auto& connect_property(
return _mqtt_context.co_props[p]; std::integral_constant<prop::property_type, p> prop
) {
return _mqtt_context.co_props[prop];
} }
void connect_propertiess(connect_props props) { void connect_properties(connect_props props) {
_mqtt_context.co_props = std::move(props); _mqtt_context.co_props = std::move(props);
} }
@@ -144,23 +150,29 @@ public:
_mqtt_context.will_msg = std::move(will); _mqtt_context.will_msg = std::move(will);
} }
template <typename Prop> template <prop::property_type p>
const auto& connack_property(Prop p) const { const auto& connack_property(
return _mqtt_context.ca_props[p]; std::integral_constant<prop::property_type, p> prop
) const {
return _mqtt_context.ca_props[prop];
} }
const auto& connack_properties() const { const auto& connack_properties() const {
return _mqtt_context.ca_props; return _mqtt_context.ca_props;
} }
template <typename Prop> template <prop::property_type p>
const auto& connect_property(Prop p) const { const auto& connect_property(
return _mqtt_context.co_props[p]; std::integral_constant<prop::property_type, p> prop
) const {
return _mqtt_context.co_props[prop];
} }
template <typename Prop> template <prop::property_type p>
auto& connect_property(Prop p) { auto& connect_property(
return _mqtt_context.co_props[p]; std::integral_constant<prop::property_type, p> prop
) {
return _mqtt_context.co_props[prop];
} }
void connect_properties(connect_props props) { void connect_properties(connect_props props) {
@@ -323,14 +335,20 @@ public:
_stream_context.mqtt_context().keep_alive = seconds; _stream_context.mqtt_context().keep_alive = seconds;
} }
template <typename Prop> template <prop::property_type p>
const auto& connect_property(Prop p) const { const auto& connect_property(
return _stream_context.connect_property(p); std::integral_constant<prop::property_type, p> prop
) const {
return _stream_context.connect_property(prop);
} }
template <typename Prop> template <prop::property_type p>
auto& connect_property(Prop p) { void connect_property(
return _stream_context.connect_property(p); std::integral_constant<prop::property_type, p> prop,
prop::value_type_t<p> value
){
if (!is_open())
_stream_context.connect_property(prop) = value;
} }
void connect_properties(connect_props props) { void connect_properties(connect_props props) {
@@ -338,9 +356,11 @@ public:
_stream_context.connect_properties(std::move(props)); _stream_context.connect_properties(std::move(props));
} }
template <typename Prop> template <prop::property_type p>
const auto& connack_property(Prop p) const { const auto& connack_property(
return _stream_context.connack_property(p); std::integral_constant<prop::property_type, p> prop
) const {
return _stream_context.connack_property(prop);
} }
const auto& connack_properties() const { const auto& connack_properties() const {

View File

@@ -349,7 +349,7 @@ public:
std::integral_constant<prop::property_type, p> prop, std::integral_constant<prop::property_type, p> prop,
prop::value_type_t<p> value prop::value_type_t<p> value
) { ) {
_impl->connect_property(prop) = value; _svc_ptr->connect_property(prop, std::move(value));
return *this; return *this;
} }

View File

@@ -282,6 +282,10 @@ class will : public will_props {
public: public:
/** /**
* \brief Constructs an empty Will Message. * \brief Constructs an empty Will Message.
*
* \attention Do not use!
* An empty Will Message results in an empty Topic Name which is not valid.
* Internal uses only.
*/ */
will() = default; will() = default;