From 4f72432bdc240641ef8e1f0bbdf0d57554e3e466 Mon Sep 17 00:00:00 2001 From: Denis Biryukov <denis.biryukov@zettascale.tech> Date: Thu, 15 Feb 2024 19:31:04 +0100 Subject: [PATCH 1/3] add support for qos settings in sample --- include/zenohcxx/api.hxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/zenohcxx/api.hxx b/include/zenohcxx/api.hxx index d4e60a2b..a45bbae8 100644 --- a/include/zenohcxx/api.hxx +++ b/include/zenohcxx/api.hxx @@ -143,6 +143,16 @@ typedef ::z_congestion_control_t CongestionControl; /// - **Z_PRIORITY_BACKGROUND**: Priority for "background traffic" messages. typedef ::z_priority_t Priority; +/** + * QoS settings of zenoh message. + * + * Members: + * Priority priority: Priority of the message. + * CongestionControl congestion_control: Congestion control of the message. + * bool express: If true, the message is not batched during transmission, in order to reduce latency. + */ +typedef ::z_qos_t QoS; + /// Query target values. /// /// see also: ``zenoh::query_target_default`` @@ -875,6 +885,10 @@ struct Sample : public Copyable<::z_sample_t> { /// @return ``zenoh::SampleKind`` value SampleKind get_kind() const { return kind; } + /// @brief QoS settings this sample was sent with + /// @return ``zenoh::QoS`` struct + QoS get_qos() const { return qos; } + /// @brief The timestamp of this data sample /// @return ``Timestamp`` object const z::Timestamp& get_timestamp() const { return static_cast<const z::Timestamp&>(timestamp); } From a470412bde1f3fdfa1aacc213846dacd8900cce6 Mon Sep 17 00:00:00 2001 From: Denis Biryukov <denis.biryukov@zettascale.tech> Date: Tue, 20 Feb 2024 17:32:21 +0100 Subject: [PATCH 2/3] reduce qos size to 1 byte; use getters to extract individual qos settings --- include/zenohcxx/api.hxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/zenohcxx/api.hxx b/include/zenohcxx/api.hxx index a45bbae8..b4401a40 100644 --- a/include/zenohcxx/api.hxx +++ b/include/zenohcxx/api.hxx @@ -145,13 +145,16 @@ typedef ::z_priority_t Priority; /** * QoS settings of zenoh message. - * - * Members: - * Priority priority: Priority of the message. - * CongestionControl congestion_control: Congestion control of the message. - * bool express: If true, the message is not batched during transmission, in order to reduce latency. */ -typedef ::z_qos_t QoS; +struct QoS : public Copyable<::z_qos_t> { + using Copyable::Copyable; + /// Returns message priority. + Priority get_priority() const { return ::z_qos_get_priority(*this); } + /// Returns message congestion control. + CongestionControl get_congestion_control() const { return ::z_qos_get_congestion_control(*this); } + /// Returns message express flag. If set to true, the message is not batched to reduce the latency. + bool get_express() const { return ::z_qos_get_express(*this); } +}; /// Query target values. /// From f882dca5501c0bd036a6e03b0936fa8e8cbc71d7 Mon Sep 17 00:00:00 2001 From: Denis Biryukov <denis.biryukov@zettascale.tech> Date: Tue, 20 Feb 2024 17:48:41 +0100 Subject: [PATCH 3/3] add default constructor for qos; update docs --- include/zenohcxx/api.hxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/zenohcxx/api.hxx b/include/zenohcxx/api.hxx index b4401a40..e8d18460 100644 --- a/include/zenohcxx/api.hxx +++ b/include/zenohcxx/api.hxx @@ -143,17 +143,18 @@ typedef ::z_congestion_control_t CongestionControl; /// - **Z_PRIORITY_BACKGROUND**: Priority for "background traffic" messages. typedef ::z_priority_t Priority; -/** - * QoS settings of zenoh message. - */ + /// QoS settings of zenoh message. + /// struct QoS : public Copyable<::z_qos_t> { using Copyable::Copyable; - /// Returns message priority. + /// @brief Returns message priority. Priority get_priority() const { return ::z_qos_get_priority(*this); } - /// Returns message congestion control. + /// @brief Returns message congestion control. CongestionControl get_congestion_control() const { return ::z_qos_get_congestion_control(*this); } - /// Returns message express flag. If set to true, the message is not batched to reduce the latency. + /// @brief Returns message express flag. If set to true, the message is not batched to reduce the latency. bool get_express() const { return ::z_qos_get_express(*this); } + /// @brief Crates default QoS settings. + QoS() : Copyable(z_qos_default()) {}; }; /// Query target values.