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"
19 class ConstClockSnapshot final : public BorrowedObject<const bt_clock_snapshot>
22 explicit ConstClockSnapshot(const _LibObjPtr libObjPtr) noexcept :
23 _ThisBorrowedObject {libObjPtr}
27 ConstClockSnapshot(const ConstClockSnapshot& clkSnapshot) noexcept :
28 _ThisBorrowedObject {clkSnapshot}
32 ConstClockSnapshot& operator=(const ConstClockSnapshot& clkSnapshot) noexcept
34 _ThisBorrowedObject::operator=(clkSnapshot);
38 std::uint64_t value() const noexcept
40 return bt_clock_snapshot_get_value(this->libObjPtr());
43 operator std::uint64_t() const noexcept
48 std::int64_t nsFromOrigin() const
50 std::int64_t nsFromOrigin;
51 const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
53 if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
54 throw OverflowError {};
63 #endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */