cpp-common/bt2: add and use `bt2::internal::Dep*` type alias templates
[babeltrace.git] / src / cpp-common / bt2 / clock-class.hpp
index 5e0e949dbc8b8cbc4017aa1d302bc880cce728d3..48ff132e062ba5ba3ba7d206119fa560014817fb 100644 (file)
@@ -101,8 +101,7 @@ private:
 public:
     using Shared = SharedObject<_ThisCommonClockClass, LibObjT, internal::ClockClassRefFuncs>;
 
-    using UserAttributes =
-        typename std::conditional<std::is_const<LibObjT>::value, ConstMapValue, MapValue>::type;
+    using UserAttributes = internal::DepUserAttrs<LibObjT>;
 
     explicit CommonClockClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
     {
@@ -121,9 +120,14 @@ public:
         return *this;
     }
 
-    void frequency(const std::uint64_t frequency) noexcept
+    CommonClockClass<const bt_clock_class> asConst() const noexcept
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        return CommonClockClass<const bt_clock_class> {*this};
+    }
+
+    void frequency(const std::uint64_t frequency) const noexcept
+    {
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_frequency(this->libObjPtr(), frequency);
     }
@@ -133,9 +137,9 @@ public:
         return bt_clock_class_get_frequency(this->libObjPtr());
     }
 
-    void offset(const ClockClassOffset& offset) noexcept
+    void offset(const ClockClassOffset& offset) const noexcept
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_offset(this->libObjPtr(), offset.seconds(), offset.cycles());
     }
@@ -149,9 +153,9 @@ public:
         return ClockClassOffset {seconds, cycles};
     }
 
-    void precision(const std::uint64_t precision) noexcept
+    void precision(const std::uint64_t precision) const noexcept
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_precision(this->libObjPtr(), precision);
     }
@@ -161,9 +165,9 @@ public:
         return bt_clock_class_get_precision(this->libObjPtr());
     }
 
-    void originIsUnixEpoch(const bool originIsUnixEpoch) noexcept
+    void originIsUnixEpoch(const bool originIsUnixEpoch) const noexcept
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_origin_is_unix_epoch(this->libObjPtr(),
                                                 static_cast<bt_bool>(originIsUnixEpoch));
@@ -174,9 +178,9 @@ public:
         return static_cast<bool>(bt_clock_class_origin_is_unix_epoch(this->libObjPtr()));
     }
 
-    void name(const char * const name)
+    void name(const char * const name) const
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         const auto status = bt_clock_class_set_name(this->libObjPtr(), name);
 
@@ -185,7 +189,7 @@ public:
         }
     }
 
-    void name(const std::string& name)
+    void name(const std::string& name) const
     {
         this->name(name.data());
     }
@@ -201,9 +205,9 @@ public:
         return nonstd::nullopt;
     }
 
-    void description(const char * const description)
+    void description(const char * const description) const
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         const auto status = bt_clock_class_set_description(this->libObjPtr(), description);
 
@@ -212,7 +216,7 @@ public:
         }
     }
 
-    void description(const std::string& description)
+    void description(const std::string& description) const
     {
         this->description(description.data());
     }
@@ -228,7 +232,7 @@ public:
         return nonstd::nullopt;
     }
 
-    void uuid(const std::uint8_t * const uuid) noexcept
+    void uuid(const std::uint8_t * const uuid) const noexcept
     {
         bt_clock_class_set_uuid(this->libObjPtr(), uuid);
     }
@@ -245,20 +249,14 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs)
+    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
-        static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+        static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
 
         bt_clock_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
     }
 
-    ConstMapValue userAttributes() const noexcept
-    {
-        return ConstMapValue {internal::CommonClockClassSpec<const bt_clock_class>::userAttributes(
-            this->libObjPtr())};
-    }
-
-    UserAttributes userAttributes() noexcept
+    UserAttributes userAttributes() const noexcept
     {
         return UserAttributes {
             internal::CommonClockClassSpec<LibObjT>::userAttributes(this->libObjPtr())};
This page took 0.028582 seconds and 4 git commands to generate.