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 std::uint64_t value() const noexcept
29 return bt_clock_snapshot_get_value(this->libObjPtr());
32 operator std::uint64_t() const noexcept
37 std::int64_t nsFromOrigin() const
39 std::int64_t nsFromOrigin;
40 const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
42 if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
43 throw OverflowError {};
52 #endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */