cpp-common/bt2: make setters return `*this`
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 29 Feb 2024 18:50:00 +0000 (13:50 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 18:56:36 +0000 (14:56 -0400)
Change setters (and other methods currently returning `void`) to return
`*this`.

This allows writing more compact code and avoid intermediate variables,
like:

    return graph->addComponent(
        *dummySinkCompCls, "the-sink",
        bt2::MapValue::create()->insert("key1", "val1").insert("key2", "val2"));

It doesn't always produce super readable code, but it's nice to have the
option.

In sub-classes of `BorrowedObject`, the methods return by value.
`ConstMessageArray::append` returns by reference.

Change-Id: I5af80c96b4c947dc217f4dff4b0bcb31885005e8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11951
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
13 files changed:
src/cpp-common/bt2/clock-class.hpp
src/cpp-common/bt2/field-class.hpp
src/cpp-common/bt2/field.hpp
src/cpp-common/bt2/graph.hpp
src/cpp-common/bt2/integer-range-set.hpp
src/cpp-common/bt2/message-array.hpp
src/cpp-common/bt2/message-iterator.hpp
src/cpp-common/bt2/message.hpp
src/cpp-common/bt2/self-component-port.hpp
src/cpp-common/bt2/self-message-iterator-configuration.hpp
src/cpp-common/bt2/self-message-iterator.hpp
src/cpp-common/bt2/trace-ir.hpp
src/cpp-common/bt2/value.hpp

index f9814a78b58c0df128cf5a214d2f835012288592..e8780c385a3f340e6a667bec073e1abb6d38afd7 100644 (file)
@@ -119,11 +119,12 @@ public:
         return CommonClockClass<const bt_clock_class> {*this};
     }
 
-    void frequency(const std::uint64_t frequency) const noexcept
+    CommonClockClass frequency(const std::uint64_t frequency) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_frequency(this->libObjPtr(), frequency);
+        return *this;
     }
 
     std::uint64_t frequency() const noexcept
@@ -131,12 +132,13 @@ public:
         return bt_clock_class_get_frequency(this->libObjPtr());
     }
 
-    void offsetFromOrigin(const ClockOffset& offsetFromOrigin) const noexcept
+    CommonClockClass offsetFromOrigin(const ClockOffset& offsetFromOrigin) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_offset(this->libObjPtr(), offsetFromOrigin.seconds(),
                                   offsetFromOrigin.cycles());
+        return *this;
     }
 
     ClockOffset offsetFromOrigin() const noexcept
@@ -148,11 +150,12 @@ public:
         return ClockOffset {seconds, cycles};
     }
 
-    void precision(const std::uint64_t precision) const noexcept
+    CommonClockClass precision(const std::uint64_t precision) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_precision(this->libObjPtr(), precision);
+        return *this;
     }
 
     std::uint64_t precision() const noexcept
@@ -160,12 +163,13 @@ public:
         return bt_clock_class_get_precision(this->libObjPtr());
     }
 
-    void originIsUnixEpoch(const bool originIsUnixEpoch) const noexcept
+    CommonClockClass originIsUnixEpoch(const bool originIsUnixEpoch) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_origin_is_unix_epoch(this->libObjPtr(),
                                                 static_cast<bt_bool>(originIsUnixEpoch));
+        return *this;
     }
 
     bool originIsUnixEpoch() const noexcept
@@ -173,7 +177,7 @@ public:
         return static_cast<bool>(bt_clock_class_origin_is_unix_epoch(this->libObjPtr()));
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonClockClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
@@ -182,6 +186,8 @@ public:
         if (status == BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -189,7 +195,7 @@ public:
         return bt_clock_class_get_name(this->libObjPtr());
     }
 
-    void description(const bt2c::CStringView description) const
+    CommonClockClass description(const bt2c::CStringView description) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
@@ -198,6 +204,8 @@ public:
         if (status == BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView description() const noexcept
@@ -205,9 +213,10 @@ public:
         return bt_clock_class_get_description(this->libObjPtr());
     }
 
-    void uuid(const std::uint8_t * const uuid) const noexcept
+    CommonClockClass uuid(const std::uint8_t * const uuid) const noexcept
     {
         bt_clock_class_set_uuid(this->libObjPtr(), uuid);
+        return *this;
     }
 
     bt2s::optional<bt2c::UuidView> uuid() const noexcept
@@ -222,11 +231,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonClockClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
index 857c33a718335514caad8ad78d26936c188f103a..411cf6690a1798355b2bcc2341a5621f203acc01 100644 (file)
@@ -402,11 +402,12 @@ public:
     asVariantWithSignedIntegerSelector() const noexcept;
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonFieldClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstFieldClass`.");
 
         bt_field_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -564,12 +565,13 @@ public:
         return CommonIntegerFieldClass<const bt_field_class> {*this};
     }
 
-    void fieldValueRange(const std::uint64_t n) const noexcept
+    CommonIntegerFieldClass fieldValueRange(const std::uint64_t n) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstIntegerFieldClass`.");
 
         bt_field_class_integer_set_field_value_range(this->libObjPtr(), n);
+        return *this;
     }
 
     std::uint64_t fieldValueRange() const noexcept
@@ -577,13 +579,14 @@ public:
         return bt_field_class_integer_get_field_value_range(this->libObjPtr());
     }
 
-    void preferredDisplayBase(const DisplayBase base) const noexcept
+    CommonIntegerFieldClass preferredDisplayBase(const DisplayBase base) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstIntegerFieldClass`.");
 
         bt_field_class_integer_set_preferred_display_base(
             this->libObjPtr(), static_cast<bt_field_class_integer_preferred_display_base>(base));
+        return *this;
     }
 
     DisplayBase preferredDisplayBase() const noexcept
@@ -859,7 +862,8 @@ public:
             this->libObjPtr(), label);
     }
 
-    void addMapping(const bt2c::CStringView label, const typename Mapping::RangeSet ranges) const
+    CommonEnumerationFieldClass addMapping(const bt2c::CStringView label,
+                                           const typename Mapping::RangeSet ranges) const
     {
         const auto status = internal::CommonEnumerationFieldClassSpec<MappingT>::addMapping(
             this->libObjPtr(), label, ranges.libObjPtr());
@@ -867,6 +871,8 @@ public:
         if (status == BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     Iterator begin() const noexcept
@@ -1019,13 +1025,15 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonStructureFieldClassMember
+    userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStructureFieldClassMember`.");
 
         bt_field_class_structure_member_set_user_attributes(this->libObjPtr(),
                                                             userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -1136,7 +1144,7 @@ public:
         return CommonStructureFieldClass<const bt_field_class> {*this};
     }
 
-    void appendMember(const bt2c::CStringView name, const FieldClass fc) const
+    CommonStructureFieldClass appendMember(const bt2c::CStringView name, const FieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStructureFieldClass`.");
@@ -1147,6 +1155,8 @@ public:
         if (status == BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     std::uint64_t length() const noexcept
@@ -1899,12 +1909,14 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonVariantFieldClassOption
+    userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstVariantFieldClassOption`.");
 
         bt_field_class_variant_option_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -2227,7 +2239,8 @@ public:
         return CommonVariantWithoutSelectorFieldClass<const bt_field_class> {*this};
     }
 
-    void appendOption(const char * const name, const FieldClass fc) const
+    CommonVariantWithoutSelectorFieldClass appendOption(const char * const name,
+                                                        const FieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstVariantWithoutSelectorFieldClass`.");
@@ -2239,16 +2252,20 @@ public:
             BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void appendOption(const bt2c::CStringView name, const FieldClass fc) const
+    CommonVariantWithoutSelectorFieldClass appendOption(const bt2c::CStringView name,
+                                                        const FieldClass fc) const
     {
         return this->appendOption(name.data(), fc);
     }
 
-    void appendOption(const bt2s::optional<std::string>& name, const FieldClass fc) const
+    CommonVariantWithoutSelectorFieldClass appendOption(const bt2s::optional<std::string>& name,
+                                                        const FieldClass fc) const
     {
-        this->appendOption(name ? name->data() : nullptr, fc);
+        return this->appendOption(name ? name->data() : nullptr, fc);
     }
 
     Shared shared() const noexcept
@@ -2451,8 +2468,9 @@ public:
         return _Spec::optionByName(this->libObjPtr(), name);
     }
 
-    void appendOption(const char * const name, const FieldClass fc,
-                      const typename Option::RangeSet ranges) const
+    CommonVariantWithIntegerSelectorFieldClass
+    appendOption(const char * const name, const FieldClass fc,
+                 const typename Option::RangeSet ranges) const
     {
         static_assert(
             !std::is_const<LibObjT>::value,
@@ -2465,18 +2483,22 @@ public:
             BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void appendOption(const bt2c::CStringView name, const FieldClass fc,
-                      const typename Option::RangeSet ranges) const
+    CommonVariantWithIntegerSelectorFieldClass
+    appendOption(const bt2c::CStringView name, const FieldClass fc,
+                 const typename Option::RangeSet ranges) const
     {
         return this->appendOption(name.data(), fc, ranges);
     }
 
-    void appendOption(const bt2s::optional<std::string>& name, const FieldClass fc,
-                      const typename Option::RangeSet ranges) const
+    CommonVariantWithIntegerSelectorFieldClass
+    appendOption(const bt2s::optional<std::string>& name, const FieldClass fc,
+                 const typename Option::RangeSet ranges) const
     {
-        this->appendOption(name ? name->data() : nullptr, fc, ranges);
+        return this->appendOption(name ? name->data() : nullptr, fc, ranges);
     }
 
     Iterator begin() const noexcept
index bf470e0bbbd2dc33775eee839c7ced6c891bed9a..05e1c24422125ee4364c35d9e07ca2699dbc1052 100644 (file)
@@ -288,11 +288,12 @@ public:
         return RawValueProxy<CommonBoolField> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonBoolField value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstBoolField`.");
 
         bt_field_bool_set_value(this->libObjPtr(), static_cast<bt_bool>(val));
+        return *this;
     }
 
     Value value() const noexcept
@@ -368,12 +369,13 @@ public:
         return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
     }
 
-    void valueAsInteger(const std::uint64_t bits) const noexcept
+    CommonBitArrayField valueAsInteger(const std::uint64_t bits) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstBitArrayField`.");
 
         bt_field_bit_array_set_value_as_integer(this->libObjPtr(), bits);
+        return *this;
     }
 
     std::uint64_t valueAsInteger() const noexcept
@@ -460,12 +462,13 @@ public:
         return RawValueProxy<CommonUnsignedIntegerField> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonUnsignedIntegerField value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstUnsignedIntegerField`.");
 
         bt_field_integer_unsigned_set_value(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -546,12 +549,13 @@ public:
         return RawValueProxy<CommonSignedIntegerField> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonSignedIntegerField value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstSignedIntegerField`.");
 
         bt_field_integer_signed_set_value(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -810,12 +814,13 @@ public:
         return RawValueProxy<CommonSinglePrecisionRealField> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonSinglePrecisionRealField value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstSinglePrecisionRealField`.");
 
         bt_field_real_single_precision_set_value(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -888,12 +893,13 @@ public:
         return RawValueProxy<CommonDoublePrecisionRealField> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonDoublePrecisionRealField value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstDoublePrecisionRealField`.");
 
         bt_field_real_double_precision_set_value(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -962,7 +968,7 @@ public:
         return RawValueProxy<CommonStringField> {*this};
     }
 
-    void value(const Value val) const
+    CommonStringField value(const Value val) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStringField`.");
@@ -972,9 +978,11 @@ public:
         if (status == BT_FIELD_STRING_SET_VALUE_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void append(const bt2c::CStringView begin, const std::uint64_t len) const
+    CommonStringField append(const bt2c::CStringView begin, const std::uint64_t len) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStringField`.");
@@ -984,24 +992,27 @@ public:
         if (status == BT_FIELD_STRING_APPEND_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void append(const bt2c::CStringView val) const
+    CommonStringField append(const bt2c::CStringView val) const
     {
-        this->append(val, std::strlen(val));
+        return this->append(val, std::strlen(val));
     }
 
-    void append(const std::string& val) const
+    CommonStringField append(const std::string& val) const
     {
-        this->append(val.data(), val.size());
+        return this->append(val.data(), val.size());
     }
 
-    void clear() const noexcept
+    CommonStringField clear() const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStringField`.");
 
         bt_field_string_clear(this->libObjPtr());
+        return *this;
     }
 
     Value value() const noexcept
@@ -1292,7 +1303,7 @@ public:
         return _ThisCommonArrayField::length();
     }
 
-    void length(const std::uint64_t length) const
+    CommonDynamicArrayField length(const std::uint64_t length) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstDynamicArrayField`.");
@@ -1302,6 +1313,8 @@ public:
         if (status == BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 };
 
@@ -1389,12 +1402,13 @@ public:
         return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
     }
 
-    void hasField(const bool hasField) const noexcept
+    CommonOptionField hasField(const bool hasField) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstOptionField`.");
 
         bt_field_option_set_has_field(this->libObjPtr(), static_cast<bt_bool>(hasField));
+        return *this;
     }
 
     bool hasField() const noexcept
@@ -1492,7 +1506,7 @@ public:
         return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
     }
 
-    void selectOption(const std::uint64_t index) const noexcept
+    CommonVariantField selectOption(const std::uint64_t index) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstVariantField`.");
@@ -1500,6 +1514,7 @@ public:
         const auto status = bt_field_variant_select_option_by_index(this->libObjPtr(), index);
 
         BT_ASSERT_DBG(status == BT_FIELD_VARIANT_SELECT_OPTION_STATUS_OK);
+        return *this;
     }
 
     CommonField<LibObjT> selectedOptionField() const noexcept
index 787888af2e4c930e30dcd332bbd4ff675036f01e..63199bf737de3897f1c0393cef84246beef7ecdf 100644 (file)
@@ -117,7 +117,7 @@ public:
             bt_graph_add_sink_component_with_initialize_method_data);
     }
 
-    void connectPorts(const ConstOutputPort outputPort, const ConstInputPort inputPort) const
+    Graph connectPorts(const ConstOutputPort outputPort, const ConstInputPort inputPort) const
     {
         const auto status = bt_graph_connect_ports(this->libObjPtr(), outputPort.libObjPtr(),
                                                    inputPort.libObjPtr(), nullptr);
@@ -127,9 +127,11 @@ public:
         } else if (status == BT_GRAPH_CONNECT_PORTS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void runOnce() const
+    Graph runOnce() const
     {
         const auto status = bt_graph_run_once(this->libObjPtr());
 
@@ -140,9 +142,11 @@ public:
         } else if (status == BT_GRAPH_RUN_ONCE_STATUS_AGAIN) {
             throw TryAgain {};
         }
+
+        return *this;
     }
 
-    void run() const
+    Graph run() const
     {
         const auto status = bt_graph_run(this->libObjPtr());
 
@@ -153,6 +157,8 @@ public:
         } else if (status == BT_GRAPH_RUN_STATUS_AGAIN) {
             throw TryAgain {};
         }
+
+        return *this;
     }
 
 private:
index 403b7fe7ee87248148507a2a26d9e2eab8f3272c..090520bc601cd1fecc7b538d1a92c899767641ef 100644 (file)
@@ -195,7 +195,7 @@ public:
         return !(*this == other);
     }
 
-    void addRange(const Value lower, const Value upper) const
+    CommonIntegerRangeSet addRange(const Value lower, const Value upper) const
     {
         static_assert(
             !std::is_const<LibObjT>::value,
@@ -206,6 +206,8 @@ public:
         if (status == BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     std::uint64_t length() const noexcept
index a286bc9edac1ce3659ba3d52f405230b1e1ee192..76b3491fd08a49a485268f72bfd2292379ea5684 100644 (file)
@@ -218,13 +218,14 @@ public:
         return _mLen == _mCap;
     }
 
-    void append(ConstMessage::Shared message) noexcept
+    ConstMessageArray& append(ConstMessage::Shared message) noexcept
     {
         BT_ASSERT_DBG(!this->isFull());
 
         /* Move reference to underlying array */
         _mLibArrayPtr[_mLen] = message.release().libObjPtr();
         ++_mLen;
+        return *this;
     }
 
     /*
index 9691ee4e80dd85f39d55cd7ecdb76c2b4cc00543..36c144d09b81ddf1076f7de7dfee97f87e2eaaaf 100644 (file)
@@ -93,13 +93,13 @@ public:
         }
     }
 
-    void seekBeginning() const
+    MessageIterator seekBeginning() const
     {
         const auto status = bt_message_iterator_seek_beginning(this->libObjPtr());
 
         switch (status) {
         case BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_OK:
-            return;
+            break;
         case BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_AGAIN:
             throw TryAgain {};
         case BT_MESSAGE_ITERATOR_SEEK_BEGINNING_STATUS_MEMORY_ERROR:
@@ -109,6 +109,8 @@ public:
         default:
             bt_common_abort();
         }
+
+        return *this;
     }
 
     bool canSeekNsFromOrigin(const std::int64_t nsFromOrigin) const
@@ -132,14 +134,14 @@ public:
         }
     }
 
-    void seekNsFromOrigin(const std::int64_t nsFromOrigin) const
+    MessageIterator seekNsFromOrigin(const std::int64_t nsFromOrigin) const
     {
         const auto status =
             bt_message_iterator_seek_ns_from_origin(this->libObjPtr(), nsFromOrigin);
 
         switch (status) {
         case BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_OK:
-            return;
+            break;
         case BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_AGAIN:
             throw TryAgain {};
         case BT_MESSAGE_ITERATOR_SEEK_NS_FROM_ORIGIN_STATUS_MEMORY_ERROR:
@@ -149,6 +151,8 @@ public:
         default:
             bt_common_abort();
         }
+
+        return *this;
     }
 
     bool canSeekForward() const noexcept
index 3f9d74183e53f7e1d66e399d4f4d3e9c279c49ae..0abd3c5403e0fc69ef539c1df9b63f9e6ea68b3e 100644 (file)
@@ -268,12 +268,13 @@ public:
             internal::CommonStreamBeginningMessageSpec<LibObjT>::stream(this->libObjPtr())};
     }
 
-    void defaultClockSnapshot(const std::uint64_t val) const noexcept
+    CommonStreamBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamBeginningMessage`.");
 
         bt_message_stream_beginning_set_default_clock_snapshot(this->libObjPtr(), val);
+        return *this;
     }
 
     OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept
@@ -382,12 +383,13 @@ public:
         return _Stream {internal::CommonStreamEndMessageSpec<LibObjT>::stream(this->libObjPtr())};
     }
 
-    void defaultClockSnapshot(const std::uint64_t val) const noexcept
+    CommonStreamEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamEndMessage`.");
 
         bt_message_stream_end_set_default_clock_snapshot(this->libObjPtr(), val);
+        return *this;
     }
 
     OptionalBorrowedObject<ConstClockSnapshot> defaultClockSnapshot() const noexcept
@@ -497,12 +499,13 @@ public:
             internal::CommonPacketBeginningMessageSpec<LibObjT>::packet(this->libObjPtr())};
     }
 
-    void defaultClockSnapshot(const std::uint64_t val) const noexcept
+    CommonPacketBeginningMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstPacketBeginningMessage`.");
 
         bt_message_packet_beginning_set_default_clock_snapshot(this->libObjPtr(), val);
+        return *this;
     }
 
     ConstClockSnapshot defaultClockSnapshot() const noexcept
@@ -606,12 +609,13 @@ public:
         return _Packet {internal::CommonPacketEndMessageSpec<LibObjT>::packet(this->libObjPtr())};
     }
 
-    void defaultClockSnapshot(const std::uint64_t val) const noexcept
+    CommonPacketEndMessage defaultClockSnapshot(const std::uint64_t val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstPacketEndMessage`.");
 
         bt_message_packet_end_set_default_clock_snapshot(this->libObjPtr(), val);
+        return *this;
     }
 
     ConstClockSnapshot defaultClockSnapshot() const noexcept
@@ -837,12 +841,13 @@ public:
         return ConstClockSnapshot {libObjPtr};
     }
 
-    void count(const std::uint64_t count) const noexcept
+    CommonDiscardedEventsMessage count(const std::uint64_t count) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstDiscardedEventsMessage`.");
 
         bt_message_discarded_events_set_count(this->libObjPtr(), count);
+        return *this;
     }
 
     bt2s::optional<std::uint64_t> count() const noexcept
@@ -967,12 +972,13 @@ public:
         return ConstClockSnapshot {libObjPtr};
     }
 
-    void count(const std::uint64_t count) const noexcept
+    CommonDiscardedPacketsMessage count(const std::uint64_t count) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstDiscardedPacketsMessage`.");
 
         bt_message_discarded_packets_set_count(this->libObjPtr(), count);
+        return *this;
     }
 
     bt2s::optional<std::uint64_t> count() const noexcept
index e2bbe80742af9a3350cebe23caf2b27c2a211316..e1ab809859461f618510b9e9526ee2637e057aee 100644 (file)
@@ -99,10 +99,11 @@ public:
     }
 
     template <typename T>
-    void data(T& obj) const noexcept
+    SelfComponent data(T& obj) const noexcept
     {
         bt_self_component_set_data(this->libObjPtr(),
                                    const_cast<void *>(static_cast<const void *>(&obj)));
+        return *this;
     }
 
     bt2::TraceClass::Shared createTraceClass() const
@@ -187,13 +188,7 @@ public:
         return this->_selfComponent().template data<T>();
     }
 
-    template <typename T>
-    void data(T& obj) const noexcept
-    {
-        this->_selfComponent().data(obj);
-    }
-
-private:
+protected:
     SelfComponent _selfComponent() const noexcept
     {
         return SelfComponent {this->libObjPtr()};
@@ -328,6 +323,8 @@ public:
 
 class SelfSourceComponent final : public internal::SelfSpecificComponent<bt_self_component_source>
 {
+    using _ThisSelfSpecificComponent = internal::SelfSpecificComponent<bt_self_component_source>;
+
 public:
     using OutputPorts = SelfComponentPorts<bt_self_component_source, bt_self_component_port_output,
                                            const bt_port_output>;
@@ -343,6 +340,15 @@ public:
             bt_self_component_source_as_component_source(this->libObjPtr())};
     }
 
+    using _ThisSelfSpecificComponent::data;
+
+    template <typename T>
+    SelfSourceComponent data(T& obj) const noexcept
+    {
+        this->_selfComponent().data(obj);
+        return *this;
+    }
+
     template <typename DataT>
     OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const;
 
@@ -357,6 +363,8 @@ private:
 
 class SelfFilterComponent final : public internal::SelfSpecificComponent<bt_self_component_filter>
 {
+    using _ThisSelfSpecificComponent = internal::SelfSpecificComponent<bt_self_component_filter>;
+
 public:
     using InputPorts = SelfComponentPorts<bt_self_component_filter, bt_self_component_port_input,
                                           const bt_port_input>;
@@ -374,6 +382,15 @@ public:
             bt_self_component_filter_as_component_filter(this->libObjPtr())};
     }
 
+    using _ThisSelfSpecificComponent::data;
+
+    template <typename T>
+    SelfFilterComponent data(T& obj) const noexcept
+    {
+        this->_selfComponent().data(obj);
+        return *this;
+    }
+
     template <typename DataT>
     InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const;
 
@@ -398,6 +415,8 @@ private:
 
 class SelfSinkComponent final : public internal::SelfSpecificComponent<bt_self_component_sink>
 {
+    using _ThisSelfSpecificComponent = internal::SelfSpecificComponent<bt_self_component_sink>;
+
 public:
     using InputPorts = SelfComponentPorts<bt_self_component_sink, bt_self_component_port_input,
                                           const bt_port_input>;
@@ -412,6 +431,15 @@ public:
         return ConstSinkComponent {bt_self_component_sink_as_component_sink(this->libObjPtr())};
     }
 
+    using _ThisSelfSpecificComponent::data;
+
+    template <typename T>
+    SelfSinkComponent data(T& obj) const noexcept
+    {
+        this->_selfComponent().data(obj);
+        return *this;
+    }
+
     MessageIterator::Shared createMessageIterator(InputPorts::Port port) const;
 
     bool isInterrupted() const noexcept
index e628194ad439950fa1fbf2db56efd55d4c3079ec..5205efafb976f7d00b16ce96a9df4db90d33de29 100644 (file)
@@ -22,10 +22,11 @@ public:
     {
     }
 
-    void canSeekForward(const bool canSeekForward) const noexcept
+    SelfMessageIteratorConfiguration canSeekForward(const bool canSeekForward) const noexcept
     {
         bt_self_message_iterator_configuration_set_can_seek_forward(
             this->libObjPtr(), static_cast<bt_bool>(canSeekForward));
+        return *this;
     }
 };
 
index 12ad078376eb6b4b3f206ab5d2dc70d2c87aa22a..7ad212c11b4b6e0144b4f774d00202faa78e1055 100644 (file)
@@ -65,10 +65,11 @@ public:
     }
 
     template <typename T>
-    void data(T& obj) const noexcept
+    SelfMessageIterator data(T& obj) const noexcept
     {
         bt_self_message_iterator_set_data(this->libObjPtr(),
                                           const_cast<void *>(static_cast<const void *>(&obj)));
+        return *this;
     }
 
     bt2::StreamBeginningMessage::Shared
index 7171138d340ca309ab900c53198dbc954f6a604b..f2678f89e95efedef5c6a0c24893989fffd40707 100644 (file)
@@ -445,7 +445,7 @@ public:
         return bt_stream_get_id(this->libObjPtr());
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonStream name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
 
@@ -454,6 +454,8 @@ public:
         if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -462,11 +464,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonStream userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
 
         bt_stream_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -632,7 +635,7 @@ public:
 
     Class cls() const noexcept;
 
-    void name(const bt2c::CStringView name) const
+    CommonTrace name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
@@ -641,6 +644,8 @@ public:
         if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -648,9 +653,10 @@ public:
         return bt_trace_get_name(this->libObjPtr());
     }
 
-    void uuid(const bt2c::UuidView& uuid) const noexcept
+    CommonTrace uuid(const bt2c::UuidView& uuid) const noexcept
     {
         bt_trace_set_uuid(this->libObjPtr(), uuid.begin());
+        return *this;
     }
 
     bt2s::optional<bt2c::UuidView> uuid() const noexcept
@@ -679,7 +685,7 @@ public:
         return _Spec::streamById(this->libObjPtr(), id);
     }
 
-    void environmentEntry(const bt2c::CStringView name, const std::int64_t val) const
+    CommonTrace environmentEntry(const bt2c::CStringView name, const std::int64_t val) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
@@ -688,9 +694,11 @@ public:
         if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void environmentEntry(const bt2c::CStringView name, const bt2c::CStringView val) const
+    CommonTrace environmentEntry(const bt2c::CStringView name, const bt2c::CStringView val) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
@@ -699,6 +707,8 @@ public:
         if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     std::uint64_t environmentSize() const noexcept
@@ -722,11 +732,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonTrace userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
         bt_trace_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -907,7 +918,7 @@ public:
         return bt_event_class_get_id(this->libObjPtr());
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonEventClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -916,6 +927,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -923,12 +936,13 @@ public:
         return bt_event_class_get_name(this->libObjPtr());
     }
 
-    void logLevel(const LogLevel logLevel) const noexcept
+    CommonEventClass logLevel(const LogLevel logLevel) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
         bt_event_class_set_log_level(this->libObjPtr(),
                                      static_cast<bt_event_class_log_level>(logLevel));
+        return *this;
     }
 
     bt2s::optional<LogLevel> logLevel() const noexcept
@@ -942,7 +956,7 @@ public:
         return bt2s::nullopt;
     }
 
-    void emfUri(const bt2c::CStringView emfUri) const
+    CommonEventClass emfUri(const bt2c::CStringView emfUri) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -951,6 +965,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView emfUri() const noexcept
@@ -958,7 +974,7 @@ public:
         return bt_event_class_get_emf_uri(this->libObjPtr());
     }
 
-    void payloadFieldClass(const StructureFieldClass fc) const
+    CommonEventClass payloadFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -968,6 +984,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> payloadFieldClass() const noexcept
@@ -975,7 +993,7 @@ public:
         return _Spec::payloadFieldClass(this->libObjPtr());
     }
 
-    void specificContextFieldClass(const StructureFieldClass fc) const
+    CommonEventClass specificContextFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -985,6 +1003,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> specificContextFieldClass() const noexcept
@@ -993,11 +1013,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonEventClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
         bt_event_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -1240,7 +1261,7 @@ public:
         return bt_stream_class_get_id(this->libObjPtr());
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonStreamClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1250,6 +1271,8 @@ public:
         if (status == BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -1257,13 +1280,14 @@ public:
         return bt_stream_class_get_name(this->libObjPtr());
     }
 
-    void assignsAutomaticEventClassId(const bool val) const noexcept
+    CommonStreamClass assignsAutomaticEventClassId(const bool val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
 
         bt_stream_class_set_assigns_automatic_event_class_id(this->libObjPtr(),
                                                              static_cast<bt_bool>(val));
+        return *this;
     }
 
     bool assignsAutomaticEventClassId() const noexcept
@@ -1272,13 +1296,14 @@ public:
             bt_stream_class_assigns_automatic_event_class_id(this->libObjPtr()));
     }
 
-    void assignsAutomaticStreamId(const bool val) const noexcept
+    CommonStreamClass assignsAutomaticStreamId(const bool val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
 
         bt_stream_class_set_assigns_automatic_stream_id(this->libObjPtr(),
                                                         static_cast<bt_bool>(val));
+        return *this;
     }
 
     bool assignsAutomaticStreamId() const noexcept
@@ -1286,8 +1311,9 @@ public:
         return static_cast<bool>(bt_stream_class_assigns_automatic_stream_id(this->libObjPtr()));
     }
 
-    void supportsPackets(const bool supportsPackets, const bool withBeginningDefaultClkSnapshot,
-                         const bool withEndDefaultClkSnapshot) const noexcept
+    CommonStreamClass supportsPackets(const bool supportsPackets,
+                                      const bool withBeginningDefaultClkSnapshot,
+                                      const bool withEndDefaultClkSnapshot) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1296,6 +1322,7 @@ public:
                                              static_cast<bt_bool>(supportsPackets),
                                              static_cast<bt_bool>(withBeginningDefaultClkSnapshot),
                                              static_cast<bt_bool>(withEndDefaultClkSnapshot));
+        return *this;
     }
 
     bool supportsPackets() const noexcept
@@ -1315,8 +1342,8 @@ public:
             bt_stream_class_packets_have_end_default_clock_snapshot(this->libObjPtr()));
     }
 
-    void supportsDiscardedEvents(const bool supportsDiscardedEvents,
-                                 const bool withDefaultClkSnapshots) const noexcept
+    CommonStreamClass supportsDiscardedEvents(const bool supportsDiscardedEvents,
+                                              const bool withDefaultClkSnapshots) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1324,6 +1351,7 @@ public:
         bt_stream_class_set_supports_discarded_events(
             this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedEvents),
             static_cast<bt_bool>(withDefaultClkSnapshots));
+        return *this;
     }
 
     bool supportsDiscardedEvents() const noexcept
@@ -1337,8 +1365,8 @@ public:
             bt_stream_class_discarded_events_have_default_clock_snapshots(this->libObjPtr()));
     }
 
-    void supportsDiscardedPackets(const bool supportsDiscardedPackets,
-                                  const bool withDefaultClkSnapshots) const noexcept
+    CommonStreamClass supportsDiscardedPackets(const bool supportsDiscardedPackets,
+                                               const bool withDefaultClkSnapshots) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1346,6 +1374,7 @@ public:
         bt_stream_class_set_supports_discarded_packets(
             this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedPackets),
             static_cast<bt_bool>(withDefaultClkSnapshots));
+        return *this;
     }
 
     bool supportsDiscardedPackets() const noexcept
@@ -1359,7 +1388,7 @@ public:
             bt_stream_class_discarded_packets_have_default_clock_snapshots(this->libObjPtr()));
     }
 
-    void defaultClockClass(const ClockClass clkCls) const
+    CommonStreamClass defaultClockClass(const ClockClass clkCls) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1368,6 +1397,7 @@ public:
             bt_stream_class_set_default_clock_class(this->libObjPtr(), clkCls.libObjPtr());
 
         BT_ASSERT(status == BT_STREAM_CLASS_SET_DEFAULT_CLOCK_CLASS_STATUS_OK);
+        return *this;
     }
 
     OptionalBorrowedObject<_ClockClass> defaultClockClass() const noexcept
@@ -1390,7 +1420,7 @@ public:
         return _Spec::eventClassById(this->libObjPtr(), id);
     }
 
-    void packetContextFieldClass(const StructureFieldClass fc) const
+    CommonStreamClass packetContextFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1401,6 +1431,8 @@ public:
         if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> packetContextFieldClass() const noexcept
@@ -1408,7 +1440,7 @@ public:
         return _Spec::packetContextFieldClass(this->libObjPtr());
     }
 
-    void eventCommonContextFieldClass(const StructureFieldClass fc) const
+    CommonStreamClass eventCommonContextFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1419,6 +1451,8 @@ public:
         if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> eventCommonContextFieldClass() const noexcept
@@ -1427,12 +1461,13 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonStreamClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
 
         bt_stream_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -1830,12 +1865,13 @@ public:
             VariantWithSignedIntegerSelectorFieldClass>(selectorFieldClass);
     }
 
-    void assignsAutomaticStreamClassId(const bool val) const noexcept
+    CommonTraceClass assignsAutomaticStreamClassId(const bool val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
 
         bt_trace_class_set_assigns_automatic_stream_class_id(this->libObjPtr(),
                                                              static_cast<bt_bool>(val));
+        return *this;
     }
 
     bool assignsAutomaticStreamClassId() const noexcept
@@ -1860,11 +1896,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonTraceClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
 
         bt_trace_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
index 7388c3403a7558c0e94fefcd8527a2fdac80c249..80e17dea2fda6ef2fa94925f98fe543ed9a83d72 100644 (file)
@@ -500,11 +500,12 @@ public:
         return static_cast<Value>(bt_value_bool_get(this->libObjPtr()));
     }
 
-    void value(const Value val) const noexcept
+    CommonBoolValue value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstBoolValue`.");
 
         bt_value_bool_set(this->libObjPtr(), static_cast<bt_bool>(val));
+        return *this;
     }
 
     Shared shared() const noexcept
@@ -585,12 +586,13 @@ public:
         return RawValueProxy<CommonUnsignedIntegerValue> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonUnsignedIntegerValue value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstUnsignedIntegerValue`.");
 
         bt_value_integer_unsigned_set(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -676,12 +678,13 @@ public:
         return RawValueProxy<CommonSignedIntegerValue> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonSignedIntegerValue value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstSignedIntegerValue`.");
 
         bt_value_integer_signed_set(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -764,11 +767,12 @@ public:
         return RawValueProxy<CommonRealValue> {*this};
     }
 
-    void value(const Value val) const noexcept
+    CommonRealValue value(const Value val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstRealValue`.");
 
         bt_value_real_set(this->libObjPtr(), val);
+        return *this;
     }
 
     Value value() const noexcept
@@ -851,7 +855,7 @@ public:
         return RawValueProxy<CommonStringValue> {*this};
     }
 
-    void value(const Value val) const
+    CommonStringValue value(const Value val) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStringValue`.");
@@ -861,6 +865,8 @@ public:
         if (status == BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     Value value() const noexcept
@@ -988,16 +994,17 @@ public:
             internal::CommonArrayValueSpec<LibObjT>::elementByIndex(this->libObjPtr(), index)};
     }
 
-    void append(const Value val) const
+    CommonArrayValue append(const Value val) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
 
         const auto status = bt_value_array_append_element(this->libObjPtr(), val.libObjPtr());
 
         this->_handleAppendLibStatus(status);
+        return *this;
     }
 
-    void append(const bool rawVal) const
+    CommonArrayValue append(const bool rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
 
@@ -1005,9 +1012,10 @@ public:
             bt_value_array_append_bool_element(this->libObjPtr(), static_cast<bt_bool>(rawVal));
 
         this->_handleAppendLibStatus(status);
+        return *this;
     }
 
-    void append(const std::uint64_t rawVal) const
+    CommonArrayValue append(const std::uint64_t rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
 
@@ -1015,38 +1023,42 @@ public:
             bt_value_array_append_unsigned_integer_element(this->libObjPtr(), rawVal);
 
         this->_handleAppendLibStatus(status);
+        return *this;
     }
 
-    void append(const std::int64_t rawVal) const
+    CommonArrayValue append(const std::int64_t rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
 
         const auto status = bt_value_array_append_signed_integer_element(this->libObjPtr(), rawVal);
 
         this->_handleAppendLibStatus(status);
+        return *this;
     }
 
-    void append(const double rawVal) const
+    CommonArrayValue append(const double rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
 
         const auto status = bt_value_array_append_real_element(this->libObjPtr(), rawVal);
 
         this->_handleAppendLibStatus(status);
+        return *this;
     }
 
-    void append(const char * const rawVal) const
+    CommonArrayValue append(const char * const rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
 
         const auto status = bt_value_array_append_string_element(this->libObjPtr(), rawVal);
 
         this->_handleAppendLibStatus(status);
+        return *this;
     }
 
-    void append(const bt2c::CStringView rawVal) const
+    CommonArrayValue append(const bt2c::CStringView rawVal) const
     {
-        this->append(rawVal.data());
+        return this->append(rawVal.data());
     }
 
     CommonArrayValue<bt_value> appendEmptyArray() const;
@@ -1286,16 +1298,17 @@ public:
         return static_cast<bool>(bt_value_map_has_entry(this->libObjPtr(), key));
     }
 
-    void insert(const bt2c::CStringView key, const Value val) const
+    CommonMapValue insert(const bt2c::CStringView key, const Value val) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
 
         const auto status = bt_value_map_insert_entry(this->libObjPtr(), key, val.libObjPtr());
 
         this->_handleInsertLibStatus(status);
+        return *this;
     }
 
-    void insert(const bt2c::CStringView key, const bool rawVal) const
+    CommonMapValue insert(const bt2c::CStringView key, const bool rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
 
@@ -1303,9 +1316,10 @@ public:
             bt_value_map_insert_bool_entry(this->libObjPtr(), key, static_cast<bt_bool>(rawVal));
 
         this->_handleInsertLibStatus(status);
+        return *this;
     }
 
-    void insert(const bt2c::CStringView key, const std::uint64_t rawVal) const
+    CommonMapValue insert(const bt2c::CStringView key, const std::uint64_t rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
 
@@ -1313,8 +1327,10 @@ public:
             bt_value_map_insert_unsigned_integer_entry(this->libObjPtr(), key, rawVal);
 
         this->_handleInsertLibStatus(status);
+        return *this;
     }
-    void insert(const bt2c::CStringView key, const std::int64_t rawVal) const
+
+    CommonMapValue insert(const bt2c::CStringView key, const std::int64_t rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
 
@@ -1322,27 +1338,30 @@ public:
             bt_value_map_insert_signed_integer_entry(this->libObjPtr(), key, rawVal);
 
         this->_handleInsertLibStatus(status);
+        return *this;
     }
 
-    void insert(const bt2c::CStringView key, const double rawVal) const
+    CommonMapValue insert(const bt2c::CStringView key, const double rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
 
         const auto status = bt_value_map_insert_real_entry(this->libObjPtr(), key, rawVal);
 
         this->_handleInsertLibStatus(status);
+        return *this;
     }
 
-    void insert(const bt2c::CStringView key, const char *rawVal) const
+    CommonMapValue insert(const bt2c::CStringView key, const char *rawVal) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
 
         const auto status = bt_value_map_insert_string_entry(this->libObjPtr(), key, rawVal);
 
         this->_handleInsertLibStatus(status);
+        return *this;
     }
 
-    void insert(const bt2c::CStringView key, const bt2c::CStringView rawVal) const
+    CommonMapValue insert(const bt2c::CStringView key, const bt2c::CStringView rawVal) const
     {
         return this->insert(key, rawVal.data());
     }
@@ -1350,9 +1369,11 @@ public:
     CommonArrayValue<bt_value> insertEmptyArray(bt2c::CStringView key) const;
     CommonMapValue<bt_value> insertEmptyMap(bt2c::CStringView key) const;
 
-    void forEach(const internal::CommonMapValueForEachUserFunc<CommonValue<LibObjT>>& func) const
+    CommonMapValue
+    forEach(const internal::CommonMapValueForEachUserFunc<CommonValue<LibObjT>>& func) const
     {
         internal::CommonMapValueSpec<LibObjT>::forEach(this->libObjPtr(), func);
+        return *this;
     }
 
     Shared shared() const noexcept
This page took 0.048312 seconds and 4 git commands to generate.