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>
14 #include "borrowed-object.hpp"
15 #include "clock-class.hpp"
20 class ConstClockSnapshot final : public BorrowedObject<const bt_clock_snapshot>
23 explicit ConstClockSnapshot(const LibObjPtr libObjPtr) noexcept :
24 _ThisBorrowedObject {libObjPtr}
28 ConstClockClass clockClass() const noexcept
30 return ConstClockClass {bt_clock_snapshot_borrow_clock_class_const(this->libObjPtr())};
33 std::uint64_t value() const noexcept
35 return bt_clock_snapshot_get_value(this->libObjPtr());
38 operator std::uint64_t() const noexcept
43 std::int64_t nsFromOrigin() const
45 std::int64_t nsFromOrigin;
46 const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
48 if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
49 throw OverflowError {};
58 #endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */