X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Ffield-path.hpp;h=fc087593b881ecbaef878ccdea4642c4c3884de4;hb=bd6e66fd0c3012ad6bcb03cdb3fb687767fb6ccf;hp=aac6ffd16ca48113debb2429e55c2f75cc46b741;hpb=02f1b80317d17a9c72a82f0138b9f8143506c1ba;p=babeltrace.git diff --git a/src/cpp-common/bt2/field-path.hpp b/src/cpp-common/bt2/field-path.hpp index aac6ffd1..fc087593 100644 --- a/src/cpp-common/bt2/field-path.hpp +++ b/src/cpp-common/bt2/field-path.hpp @@ -13,9 +13,9 @@ #include "common/assert.h" -#include "borrowed-obj.hpp" -#include "common-iter.hpp" -#include "internal/shared-obj.hpp" +#include "borrowed-object-iterator.hpp" +#include "borrowed-object.hpp" +#include "shared-object.hpp" namespace bt2 { @@ -28,23 +28,14 @@ enum class FieldPathItemType CURRENT_OPTION_CONTENT = BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT, }; -class ConstFieldPathItem : public BorrowedObj +class ConstFieldPathItem : public BorrowedObject { public: - explicit ConstFieldPathItem(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr} + explicit ConstFieldPathItem(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} { } - ConstFieldPathItem(const ConstFieldPathItem& fpItem) noexcept : _ThisBorrowedObj {fpItem} - { - } - - ConstFieldPathItem& operator=(const ConstFieldPathItem& fpItem) noexcept - { - _ThisBorrowedObj::operator=(fpItem); - return *this; - } - FieldPathItemType type() const noexcept { return static_cast(this->_libType()); @@ -77,23 +68,12 @@ private: class ConstIndexFieldPathItem final : public ConstFieldPathItem { public: - explicit ConstIndexFieldPathItem(const _LibObjPtr libObjPtr) noexcept : + explicit ConstIndexFieldPathItem(const LibObjPtr libObjPtr) noexcept : ConstFieldPathItem {libObjPtr} { BT_ASSERT_DBG(this->isIndex()); } - ConstIndexFieldPathItem(const ConstIndexFieldPathItem& fpItem) noexcept : - ConstFieldPathItem {fpItem} - { - } - - ConstIndexFieldPathItem& operator=(const ConstIndexFieldPathItem& fpItem) noexcept - { - ConstFieldPathItem::operator=(fpItem); - return *this; - } - std::uint64_t index() const noexcept { return bt_field_path_item_index_get_index(this->libObjPtr()); @@ -102,7 +82,6 @@ public: inline ConstIndexFieldPathItem ConstFieldPathItem::asIndex() const noexcept { - BT_ASSERT_DBG(this->isIndex()); return ConstIndexFieldPathItem {this->libObjPtr()}; } @@ -110,12 +89,12 @@ namespace internal { struct FieldPathRefFuncs final { - static void get(const bt_field_path * const libObjPtr) + static void get(const bt_field_path * const libObjPtr) noexcept { bt_field_path_get_ref(libObjPtr); } - static void put(const bt_field_path * const libObjPtr) + static void put(const bt_field_path * const libObjPtr) noexcept { bt_field_path_put_ref(libObjPtr); } @@ -123,13 +102,11 @@ struct FieldPathRefFuncs final } /* namespace internal */ -class ConstFieldPath final : public BorrowedObj +class ConstFieldPath final : public BorrowedObject { public: - using Shared = - internal::SharedObj; - - using Iterator = CommonIterator; + using Shared = SharedObject; + using Iterator = BorrowedObjectIterator; enum class Scope { @@ -139,18 +116,8 @@ public: EVENT_PAYLOAD = BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD, }; - explicit ConstFieldPath(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr} - { - } - - ConstFieldPath(const ConstFieldPath& fieldPath) noexcept : _ThisBorrowedObj {fieldPath} - { - } - - ConstFieldPath& operator=(const ConstFieldPath& fieldPath) noexcept + explicit ConstFieldPath(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} { - _ThisBorrowedObj::operator=(fieldPath); - return *this; } Scope rootScope() const noexcept @@ -158,7 +125,7 @@ public: return static_cast(bt_field_path_get_root_scope(this->libObjPtr())); } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_field_path_get_item_count(this->libObjPtr()); } @@ -176,7 +143,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Shared shared() const noexcept