Change naming convention for enum class enumerators
[babeltrace.git] / src / cpp-common / bt2 / field-path.hpp
index 75f98c68ea548dbe6f9accaa098cdde0fcd0ed16..d203245f9a6c8a154852581be2bb4c90cf668f27 100644 (file)
@@ -8,12 +8,14 @@
 #define BABELTRACE_CPP_COMMON_BT2_FIELD_PATH_HPP
 
 #include <cstdint>
+
 #include <babeltrace2/babeltrace.h>
 
 #include "common/assert.h"
-#include "common-iter.hpp"
-#include "internal/borrowed-obj.hpp"
-#include "internal/shared-obj.hpp"
+
+#include "borrowed-object-iterator.hpp"
+#include "borrowed-object.hpp"
+#include "shared-object.hpp"
 
 namespace bt2 {
 
@@ -21,28 +23,19 @@ class ConstIndexFieldPathItem;
 
 enum class FieldPathItemType
 {
-    INDEX = BT_FIELD_PATH_ITEM_TYPE_INDEX,
-    CURRENT_ARRAY_ELEMENT = BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT,
-    CURRENT_OPTION_CONTENT = BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT,
+    Index = BT_FIELD_PATH_ITEM_TYPE_INDEX,
+    CurrentArrayElement = BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT,
+    CurrentOptionContent = BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT,
 };
 
-class ConstFieldPathItem : public internal::BorrowedObj<const bt_field_path_item>
+class ConstFieldPathItem : public BorrowedObject<const bt_field_path_item>
 {
 public:
-    explicit ConstFieldPathItem(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr}
-    {
-    }
-
-    ConstFieldPathItem(const ConstFieldPathItem& fpItem) noexcept : _ThisBorrowedObj {fpItem}
+    explicit ConstFieldPathItem(const LibObjPtr libObjPtr) noexcept :
+        _ThisBorrowedObject {libObjPtr}
     {
     }
 
-    ConstFieldPathItem& operator=(const ConstFieldPathItem& fpItem) noexcept
-    {
-        _ThisBorrowedObj::operator=(fpItem);
-        return *this;
-    }
-
     FieldPathItemType type() const noexcept
     {
         return static_cast<FieldPathItemType>(this->_libType());
@@ -75,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());
@@ -100,7 +82,6 @@ public:
 
 inline ConstIndexFieldPathItem ConstFieldPathItem::asIndex() const noexcept
 {
-    BT_ASSERT_DBG(this->isIndex());
     return ConstIndexFieldPathItem {this->libObjPtr()};
 }
 
@@ -108,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);
     }
@@ -121,34 +102,22 @@ struct FieldPathRefFuncs final
 
 } /* namespace internal */
 
-class ConstFieldPath final : public internal::BorrowedObj<const bt_field_path>
+class ConstFieldPath final : public BorrowedObject<const bt_field_path>
 {
 public:
-    using Shared =
-        internal::SharedObj<ConstFieldPath, const bt_field_path, internal::FieldPathRefFuncs>;
-
-    using Iterator = CommonIterator<ConstFieldPath, ConstFieldPathItem>;
+    using Shared = SharedObject<ConstFieldPath, const bt_field_path, internal::FieldPathRefFuncs>;
+    using Iterator = BorrowedObjectIterator<ConstFieldPath>;
 
     enum class Scope
     {
-        PACKET_CONTEXT = BT_FIELD_PATH_SCOPE_PACKET_CONTEXT,
-        EVENT_COMMON_CONTEXT = BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT,
-        EVENT_SPECIFIC_CONTEXT = BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT,
-        EVENT_PAYLOAD = BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD,
+        PacketContext = BT_FIELD_PATH_SCOPE_PACKET_CONTEXT,
+        EventCommonContext = BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT,
+        EventSpecificContext = BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT,
+        EventPayload = 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
@@ -156,7 +125,7 @@ public:
         return static_cast<Scope>(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());
     }
@@ -174,12 +143,12 @@ public:
 
     Iterator end() const noexcept
     {
-        return Iterator {*this, this->size()};
+        return Iterator {*this, this->length()};
     }
 
     Shared shared() const noexcept
     {
-        return Shared {*this};
+        return Shared::createWithRef(*this);
     }
 };
 
This page took 0.047496 seconds and 4 git commands to generate.