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
11 #include <babeltrace2/babeltrace.h>
13 #include "internal/borrowed-obj.hpp"
14 #include "lib-error.hpp"
18 class ConstClockSnapshot final : public internal::BorrowedObj<const bt_clock_snapshot>
21 explicit ConstClockSnapshot(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr}
25 ConstClockSnapshot(const ConstClockSnapshot& clkSnapshot) noexcept :
26 _ThisBorrowedObj {clkSnapshot}
30 ConstClockSnapshot& operator=(const ConstClockSnapshot& clkSnapshot) noexcept
32 _ThisBorrowedObj::operator=(clkSnapshot);
36 std::uint64_t value() const noexcept
38 return bt_clock_snapshot_get_value(this->libObjPtr());
41 operator std::uint64_t() const noexcept
46 std::int64_t nsFromOrigin() const
48 std::int64_t nsFromOrigin;
49 const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
51 if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
52 throw LibOverflowError {};
61 #endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */