Change naming convention for enum class enumerators
[babeltrace.git] / src / cpp-common / bt2 / trace-ir.hpp
index 7171138d340ca309ab900c53198dbc954f6a604b..18124b876de58953400a13b765d4e914044ae4f0 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <babeltrace2/babeltrace.h>
 
+#include "common/macros.h"
 #include "cpp-common/bt2c/c-string-view.hpp"
 #include "cpp-common/bt2s/optional.hpp"
 
@@ -445,7 +446,7 @@ public:
         return bt_stream_get_id(this->libObjPtr());
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonStream name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
 
@@ -454,6 +455,8 @@ public:
         if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -462,11 +465,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonStream userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
 
         bt_stream_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -632,7 +636,7 @@ public:
 
     Class cls() const noexcept;
 
-    void name(const bt2c::CStringView name) const
+    CommonTrace name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
@@ -641,6 +645,8 @@ public:
         if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -648,9 +654,10 @@ public:
         return bt_trace_get_name(this->libObjPtr());
     }
 
-    void uuid(const bt2c::UuidView& uuid) const noexcept
+    CommonTrace uuid(const bt2c::UuidView& uuid) const noexcept
     {
         bt_trace_set_uuid(this->libObjPtr(), uuid.begin());
+        return *this;
     }
 
     bt2s::optional<bt2c::UuidView> uuid() const noexcept
@@ -679,7 +686,7 @@ public:
         return _Spec::streamById(this->libObjPtr(), id);
     }
 
-    void environmentEntry(const bt2c::CStringView name, const std::int64_t val) const
+    CommonTrace environmentEntry(const bt2c::CStringView name, const std::int64_t val) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
@@ -688,9 +695,11 @@ public:
         if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
-    void environmentEntry(const bt2c::CStringView name, const bt2c::CStringView val) const
+    CommonTrace environmentEntry(const bt2c::CStringView name, const bt2c::CStringView val) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
@@ -699,6 +708,8 @@ public:
         if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     std::uint64_t environmentSize() const noexcept
@@ -722,11 +733,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonTrace userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
 
         bt_trace_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -859,25 +871,31 @@ public:
     using Shared = SharedObject<CommonEventClass, LibObjT, internal::EventClassRefFuncs>;
     using UserAttributes = internal::DepUserAttrs<LibObjT>;
 
+    /* Avoid `-Wshadow` error on GCC, conflicting with `bt2::Error` */
+    BT_DIAG_PUSH
+    BT_DIAG_IGNORE_SHADOW
+
     enum class LogLevel
     {
-        EMERGENCY = BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY,
-        ALERT = BT_EVENT_CLASS_LOG_LEVEL_ALERT,
-        CRITICAL = BT_EVENT_CLASS_LOG_LEVEL_CRITICAL,
-        ERR = BT_EVENT_CLASS_LOG_LEVEL_ERROR,
-        WARNING = BT_EVENT_CLASS_LOG_LEVEL_WARNING,
-        NOTICE = BT_EVENT_CLASS_LOG_LEVEL_NOTICE,
-        INFO = BT_EVENT_CLASS_LOG_LEVEL_INFO,
-        DEBUG_SYSTEM = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM,
-        DEBUG_PROGRAM = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM,
-        DEBUG_PROC = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS,
-        DEBUG_MODULE = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE,
-        DEBUG_UNIT = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT,
-        DEBUG_FUNCTION = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION,
-        DEBUG_LINE = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE,
-        DEBUG = BT_EVENT_CLASS_LOG_LEVEL_DEBUG,
+        Emergency = BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY,
+        Alert = BT_EVENT_CLASS_LOG_LEVEL_ALERT,
+        Critical = BT_EVENT_CLASS_LOG_LEVEL_CRITICAL,
+        Error = BT_EVENT_CLASS_LOG_LEVEL_ERROR,
+        Warning = BT_EVENT_CLASS_LOG_LEVEL_WARNING,
+        Notice = BT_EVENT_CLASS_LOG_LEVEL_NOTICE,
+        Info = BT_EVENT_CLASS_LOG_LEVEL_INFO,
+        DebugSystem = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM,
+        DebugProgram = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM,
+        DebugProcess = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS,
+        DebugModule = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE,
+        DebugUnit = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT,
+        DebugFunction = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION,
+        DebugLine = BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE,
+        Debug = BT_EVENT_CLASS_LOG_LEVEL_DEBUG,
     };
 
+    BT_DIAG_POP
+
     explicit CommonEventClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
     {
     }
@@ -907,7 +925,7 @@ public:
         return bt_event_class_get_id(this->libObjPtr());
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonEventClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -916,6 +934,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -923,12 +943,13 @@ public:
         return bt_event_class_get_name(this->libObjPtr());
     }
 
-    void logLevel(const LogLevel logLevel) const noexcept
+    CommonEventClass logLevel(const LogLevel logLevel) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
         bt_event_class_set_log_level(this->libObjPtr(),
                                      static_cast<bt_event_class_log_level>(logLevel));
+        return *this;
     }
 
     bt2s::optional<LogLevel> logLevel() const noexcept
@@ -942,7 +963,7 @@ public:
         return bt2s::nullopt;
     }
 
-    void emfUri(const bt2c::CStringView emfUri) const
+    CommonEventClass emfUri(const bt2c::CStringView emfUri) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -951,6 +972,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView emfUri() const noexcept
@@ -958,7 +981,7 @@ public:
         return bt_event_class_get_emf_uri(this->libObjPtr());
     }
 
-    void payloadFieldClass(const StructureFieldClass fc) const
+    CommonEventClass payloadFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -968,6 +991,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> payloadFieldClass() const noexcept
@@ -975,7 +1000,7 @@ public:
         return _Spec::payloadFieldClass(this->libObjPtr());
     }
 
-    void specificContextFieldClass(const StructureFieldClass fc) const
+    CommonEventClass specificContextFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -985,6 +1010,8 @@ public:
         if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> specificContextFieldClass() const noexcept
@@ -993,11 +1020,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonEventClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
         bt_event_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -1240,7 +1268,7 @@ public:
         return bt_stream_class_get_id(this->libObjPtr());
     }
 
-    void name(const bt2c::CStringView name) const
+    CommonStreamClass name(const bt2c::CStringView name) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1250,6 +1278,8 @@ public:
         if (status == BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     bt2c::CStringView name() const noexcept
@@ -1257,13 +1287,14 @@ public:
         return bt_stream_class_get_name(this->libObjPtr());
     }
 
-    void assignsAutomaticEventClassId(const bool val) const noexcept
+    CommonStreamClass assignsAutomaticEventClassId(const bool val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
 
         bt_stream_class_set_assigns_automatic_event_class_id(this->libObjPtr(),
                                                              static_cast<bt_bool>(val));
+        return *this;
     }
 
     bool assignsAutomaticEventClassId() const noexcept
@@ -1272,13 +1303,14 @@ public:
             bt_stream_class_assigns_automatic_event_class_id(this->libObjPtr()));
     }
 
-    void assignsAutomaticStreamId(const bool val) const noexcept
+    CommonStreamClass assignsAutomaticStreamId(const bool val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
 
         bt_stream_class_set_assigns_automatic_stream_id(this->libObjPtr(),
                                                         static_cast<bt_bool>(val));
+        return *this;
     }
 
     bool assignsAutomaticStreamId() const noexcept
@@ -1286,8 +1318,9 @@ public:
         return static_cast<bool>(bt_stream_class_assigns_automatic_stream_id(this->libObjPtr()));
     }
 
-    void supportsPackets(const bool supportsPackets, const bool withBeginningDefaultClkSnapshot,
-                         const bool withEndDefaultClkSnapshot) const noexcept
+    CommonStreamClass supportsPackets(const bool supportsPackets,
+                                      const bool withBeginningDefaultClkSnapshot,
+                                      const bool withEndDefaultClkSnapshot) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1296,6 +1329,7 @@ public:
                                              static_cast<bt_bool>(supportsPackets),
                                              static_cast<bt_bool>(withBeginningDefaultClkSnapshot),
                                              static_cast<bt_bool>(withEndDefaultClkSnapshot));
+        return *this;
     }
 
     bool supportsPackets() const noexcept
@@ -1315,8 +1349,8 @@ public:
             bt_stream_class_packets_have_end_default_clock_snapshot(this->libObjPtr()));
     }
 
-    void supportsDiscardedEvents(const bool supportsDiscardedEvents,
-                                 const bool withDefaultClkSnapshots) const noexcept
+    CommonStreamClass supportsDiscardedEvents(const bool supportsDiscardedEvents,
+                                              const bool withDefaultClkSnapshots) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1324,6 +1358,7 @@ public:
         bt_stream_class_set_supports_discarded_events(
             this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedEvents),
             static_cast<bt_bool>(withDefaultClkSnapshots));
+        return *this;
     }
 
     bool supportsDiscardedEvents() const noexcept
@@ -1337,8 +1372,8 @@ public:
             bt_stream_class_discarded_events_have_default_clock_snapshots(this->libObjPtr()));
     }
 
-    void supportsDiscardedPackets(const bool supportsDiscardedPackets,
-                                  const bool withDefaultClkSnapshots) const noexcept
+    CommonStreamClass supportsDiscardedPackets(const bool supportsDiscardedPackets,
+                                               const bool withDefaultClkSnapshots) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1346,6 +1381,7 @@ public:
         bt_stream_class_set_supports_discarded_packets(
             this->libObjPtr(), static_cast<bt_bool>(supportsDiscardedPackets),
             static_cast<bt_bool>(withDefaultClkSnapshots));
+        return *this;
     }
 
     bool supportsDiscardedPackets() const noexcept
@@ -1359,7 +1395,7 @@ public:
             bt_stream_class_discarded_packets_have_default_clock_snapshots(this->libObjPtr()));
     }
 
-    void defaultClockClass(const ClockClass clkCls) const
+    CommonStreamClass defaultClockClass(const ClockClass clkCls) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1368,6 +1404,7 @@ public:
             bt_stream_class_set_default_clock_class(this->libObjPtr(), clkCls.libObjPtr());
 
         BT_ASSERT(status == BT_STREAM_CLASS_SET_DEFAULT_CLOCK_CLASS_STATUS_OK);
+        return *this;
     }
 
     OptionalBorrowedObject<_ClockClass> defaultClockClass() const noexcept
@@ -1390,7 +1427,7 @@ public:
         return _Spec::eventClassById(this->libObjPtr(), id);
     }
 
-    void packetContextFieldClass(const StructureFieldClass fc) const
+    CommonStreamClass packetContextFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1401,6 +1438,8 @@ public:
         if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> packetContextFieldClass() const noexcept
@@ -1408,7 +1447,7 @@ public:
         return _Spec::packetContextFieldClass(this->libObjPtr());
     }
 
-    void eventCommonContextFieldClass(const StructureFieldClass fc) const
+    CommonStreamClass eventCommonContextFieldClass(const StructureFieldClass fc) const
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
@@ -1419,6 +1458,8 @@ public:
         if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
             throw MemoryError {};
         }
+
+        return *this;
     }
 
     OptionalBorrowedObject<_StructureFieldClass> eventCommonContextFieldClass() const noexcept
@@ -1427,12 +1468,13 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonStreamClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value,
                       "Not available with `bt2::ConstStreamClass`.");
 
         bt_stream_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
@@ -1830,12 +1872,13 @@ public:
             VariantWithSignedIntegerSelectorFieldClass>(selectorFieldClass);
     }
 
-    void assignsAutomaticStreamClassId(const bool val) const noexcept
+    CommonTraceClass assignsAutomaticStreamClassId(const bool val) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
 
         bt_trace_class_set_assigns_automatic_stream_class_id(this->libObjPtr(),
                                                              static_cast<bt_bool>(val));
+        return *this;
     }
 
     bool assignsAutomaticStreamClassId() const noexcept
@@ -1860,11 +1903,12 @@ public:
     }
 
     template <typename LibValT>
-    void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
+    CommonTraceClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTraceClass`.");
 
         bt_trace_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
+        return *this;
     }
 
     UserAttributes userAttributes() const noexcept
This page took 0.042803 seconds and 4 git commands to generate.