cpp-common/bt2: make `bt2::BorrowedObject::LibObj` public
[babeltrace.git] / src / cpp-common / bt2 / clock-snapshot.hpp
index 26ec9e8368746aa822938e4f7d92303e820cdaff..38ea940b56adcfa4652d0bbfa1b632ac9d099b7c 100644 (file)
@@ -8,34 +8,31 @@
 #define BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
 
 #include <cstdint>
+
 #include <babeltrace2/babeltrace.h>
 
-#include "internal/borrowed-obj.hpp"
-#include "lib-error.hpp"
+#include "borrowed-object.hpp"
+#include "clock-class.hpp"
+#include "exc.hpp"
 
 namespace bt2 {
 
-class ConstClockSnapshot final : public internal::BorrowedObj<const bt_clock_snapshot>
+class ConstClockSnapshot final : public BorrowedObject<const bt_clock_snapshot>
 {
 public:
-    explicit ConstClockSnapshot(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr}
-    {
-    }
-
-    ConstClockSnapshot(const ConstClockSnapshot& clkSnapshot) noexcept :
-        _ThisBorrowedObj {clkSnapshot}
+    explicit ConstClockSnapshot(const LibObjPtr libObjPtr) noexcept :
+        _ThisBorrowedObject {libObjPtr}
     {
     }
 
-    ConstClockSnapshot& operator=(const ConstClockSnapshot& clkSnapshot) noexcept
+    ConstClockClass clockClass() const noexcept
     {
-        _ThisBorrowedObj::operator=(clkSnapshot);
-        return *this;
+        return ConstClockClass {bt_clock_snapshot_borrow_clock_class_const(this->libObjPtr())};
     }
 
     std::uint64_t value() const noexcept
     {
-        return bt_clock_snapshot_get_value(this->_libObjPtr());
+        return bt_clock_snapshot_get_value(this->libObjPtr());
     }
 
     operator std::uint64_t() const noexcept
@@ -46,16 +43,16 @@ public:
     std::int64_t nsFromOrigin() const
     {
         std::int64_t nsFromOrigin;
-        const auto status = bt_clock_snapshot_get_ns_from_origin(this->_libObjPtr(), &nsFromOrigin);
+        const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
 
         if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
-            throw LibOverflowError {};
+            throw OverflowError {};
         }
 
         return nsFromOrigin;
     }
 };
 
-} // namespace bt2
+} /* namespace bt2 */
 
-#endif // BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
+#endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */
This page took 0.023502 seconds and 4 git commands to generate.