2 * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: MIT
7 #ifndef BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
12 #include <babeltrace2/babeltrace.h>
15 #include "internal/borrowed-obj.hpp"
19 class ConstClockSnapshot final : public internal::BorrowedObj<const bt_clock_snapshot>
22 explicit ConstClockSnapshot(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr}
26 ConstClockSnapshot(const ConstClockSnapshot& clkSnapshot) noexcept :
27 _ThisBorrowedObj {clkSnapshot}
31 ConstClockSnapshot& operator=(const ConstClockSnapshot& clkSnapshot) noexcept
33 _ThisBorrowedObj::operator=(clkSnapshot);
37 std::uint64_t value() const noexcept
39 return bt_clock_snapshot_get_value(this->libObjPtr());
42 operator std::uint64_t() const noexcept
47 std::int64_t nsFromOrigin() const
49 std::int64_t nsFromOrigin;
50 const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
52 if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
53 throw OverflowError {};
62 #endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */