Fix: C++ bindings typos in lib function name
[babeltrace.git] / src / cpp-common / bt2 / clock-snapshot.hpp
CommitLineData
3aafc165
PP
1/*
2 * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
8#define BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
9
10#include <cstdint>
11#include <babeltrace2/babeltrace.h>
12
13#include "internal/borrowed-obj.hpp"
14#include "lib-error.hpp"
15
16namespace bt2 {
17
18class ConstClockSnapshot final : public internal::BorrowedObj<const bt_clock_snapshot>
19{
20public:
21 explicit ConstClockSnapshot(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr}
22 {
23 }
24
25 ConstClockSnapshot(const ConstClockSnapshot& clkSnapshot) noexcept :
26 _ThisBorrowedObj {clkSnapshot}
27 {
28 }
29
30 ConstClockSnapshot& operator=(const ConstClockSnapshot& clkSnapshot) noexcept
31 {
32 _ThisBorrowedObj::operator=(clkSnapshot);
33 return *this;
34 }
35
36 std::uint64_t value() const noexcept
37 {
38 return bt_clock_snapshot_get_value(this->_libObjPtr());
39 }
40
41 operator std::uint64_t() const noexcept
42 {
43 return this->value();
44 }
45
46 std::int64_t nsFromOrigin() const
47 {
48 std::int64_t nsFromOrigin;
49 const auto status = bt_clock_snapshot_get_ns_from_origin(this->_libObjPtr(), &nsFromOrigin);
50
51 if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
52 throw LibOverflowError {};
53 }
54
55 return nsFromOrigin;
56 }
57};
58
59} // namespace bt2
60
61#endif // BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP
This page took 0.024407 seconds and 4 git commands to generate.