X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Fclock-class.hpp;h=f9814a78b58c0df128cf5a214d2f835012288592;hb=aa5aac94c5ec89c7f361cf37c4df668229704180;hp=bd127dfa673a0e58cde6f43597111884520d13a6;hpb=ac30a4709ff225c8c93337ee61709b33d3772d76;p=babeltrace.git diff --git a/src/cpp-common/bt2/clock-class.hpp b/src/cpp-common/bt2/clock-class.hpp index bd127dfa..f9814a78 100644 --- a/src/cpp-common/bt2/clock-class.hpp +++ b/src/cpp-common/bt2/clock-class.hpp @@ -8,14 +8,13 @@ #define BABELTRACE_CPP_COMMON_BT2_CLOCK_CLASS_HPP #include -#include #include #include -#include "cpp-common/optional.hpp" -#include "cpp-common/string_view.hpp" -#include "cpp-common/uuid-view.hpp" +#include "cpp-common/bt2c/c-string-view.hpp" +#include "cpp-common/bt2c/uuid.hpp" +#include "cpp-common/bt2s/optional.hpp" #include "borrowed-object.hpp" #include "exc.hpp" @@ -64,10 +63,10 @@ struct CommonClockClassSpec final } /* namespace internal */ -class ClockClassOffset final +class ClockOffset final { public: - explicit ClockClassOffset(const std::int64_t seconds, const std::uint64_t cycles) : + explicit ClockOffset(const std::int64_t seconds, const std::uint64_t cycles) : _mSeconds {seconds}, _mCycles {cycles} { } @@ -92,13 +91,13 @@ class CommonClockClass final : public BorrowedObject { private: using typename BorrowedObject::_ThisBorrowedObject; - using typename BorrowedObject::_LibObjPtr; public: + using typename BorrowedObject::LibObjPtr; using Shared = SharedObject; using UserAttributes = internal::DepUserAttrs; - explicit CommonClockClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} + explicit CommonClockClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} { } @@ -132,20 +131,21 @@ public: return bt_clock_class_get_frequency(this->libObjPtr()); } - void offset(const ClockClassOffset& offset) const noexcept + void offsetFromOrigin(const ClockOffset& offsetFromOrigin) const noexcept { static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - bt_clock_class_set_offset(this->libObjPtr(), offset.seconds(), offset.cycles()); + bt_clock_class_set_offset(this->libObjPtr(), offsetFromOrigin.seconds(), + offsetFromOrigin.cycles()); } - ClockClassOffset offset() const noexcept + ClockOffset offsetFromOrigin() const noexcept { std::int64_t seconds; std::uint64_t cycles; bt_clock_class_get_offset(this->libObjPtr(), &seconds, &cycles); - return ClockClassOffset {seconds, cycles}; + return ClockOffset {seconds, cycles}; } void precision(const std::uint64_t precision) const noexcept @@ -173,7 +173,7 @@ public: return static_cast(bt_clock_class_origin_is_unix_epoch(this->libObjPtr())); } - void name(const char * const name) const + void name(const bt2c::CStringView name) const { static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); @@ -184,23 +184,12 @@ public: } } - void name(const std::string& name) const + bt2c::CStringView name() const noexcept { - this->name(name.data()); + return bt_clock_class_get_name(this->libObjPtr()); } - nonstd::optional name() const noexcept - { - const auto name = bt_clock_class_get_name(this->libObjPtr()); - - if (name) { - return name; - } - - return nonstd::nullopt; - } - - void description(const char * const description) const + void description(const bt2c::CStringView description) const { static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); @@ -211,20 +200,9 @@ public: } } - void description(const std::string& description) const + bt2c::CStringView description() const noexcept { - this->description(description.data()); - } - - nonstd::optional description() const noexcept - { - const auto description = bt_clock_class_get_description(this->libObjPtr()); - - if (description) { - return description; - } - - return nonstd::nullopt; + return bt_clock_class_get_description(this->libObjPtr()); } void uuid(const std::uint8_t * const uuid) const noexcept @@ -232,15 +210,15 @@ public: bt_clock_class_set_uuid(this->libObjPtr(), uuid); } - nonstd::optional uuid() const noexcept + bt2s::optional uuid() const noexcept { const auto uuid = bt_clock_class_get_uuid(this->libObjPtr()); if (uuid) { - return bt2_common::UuidView {uuid}; + return bt2c::UuidView {uuid}; } - return nonstd::nullopt; + return bt2s::nullopt; } template