cpp-common/bt2: move some enum classes out of enclosing classes
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 3 Apr 2024 20:12:12 +0000 (16:12 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Settle on the standard of having these enumerations out of the classes
that use them.

Change-Id: I241bdca560bf7f9e892d8884c86662166ad2d2c4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12240
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/bt2/component-class.hpp
src/cpp-common/bt2/error.hpp
src/cpp-common/bt2/field-path.hpp
src/cpp-common/bt2/trace-ir.hpp

index 3d30ad35f0f79ed758dae3a2a850bdd7e48dd5cd..2933d74f737fd6d6e56d13f672549029579cd8f6 100644 (file)
@@ -33,6 +33,13 @@ struct ComponentClassRefFuncs final
 
 } /* namespace internal */
 
+enum class ComponentClassType
+{
+    Source = BT_COMPONENT_CLASS_TYPE_SOURCE,
+    Filter = BT_COMPONENT_CLASS_TYPE_FILTER,
+    Sink = BT_COMPONENT_CLASS_TYPE_SINK,
+};
+
 template <typename LibObjT>
 class CommonSourceComponentClass;
 
@@ -52,13 +59,6 @@ public:
     using typename _ThisBorrowedObject::LibObjPtr;
     using Shared = SharedObject<CommonComponentClass, LibObjT, internal::ComponentClassRefFuncs>;
 
-    enum class Type
-    {
-        Source = BT_COMPONENT_CLASS_TYPE_SOURCE,
-        Filter = BT_COMPONENT_CLASS_TYPE_FILTER,
-        Sink = BT_COMPONENT_CLASS_TYPE_SINK,
-    };
-
     explicit CommonComponentClass(const LibObjPtr libObjPtr) noexcept :
         _ThisBorrowedObject {libObjPtr}
     {
index 030ff239a9aaa2eeae88d6eeaedb82e3a121e14c..b9c8c81759848917d28bcecbe5176d4f12b1b176 100644 (file)
@@ -25,39 +25,39 @@ class ConstComponentClassErrorCause;
 class ConstComponentErrorCause;
 class ConstMessageIteratorErrorCause;
 
+enum class ErrorCauseActorType
+{
+    Unknown = BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN,
+    Component = BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT,
+    ComponentClass = BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS,
+    MessageIterator = BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR,
+};
+
 class ConstErrorCause : public BorrowedObject<const bt_error_cause>
 {
 public:
-    enum class ActorType
-    {
-        Unknown = BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN,
-        Component = BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT,
-        ComponentClass = BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS,
-        MessageIterator = BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR,
-    };
-
     explicit ConstErrorCause(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
     {
     }
 
-    ActorType actorType() const noexcept
+    ErrorCauseActorType actorType() const noexcept
     {
-        return static_cast<ActorType>(bt_error_cause_get_actor_type(this->libObjPtr()));
+        return static_cast<ErrorCauseActorType>(bt_error_cause_get_actor_type(this->libObjPtr()));
     }
 
     bool actorTypeIsComponentClass() const noexcept
     {
-        return this->actorType() == ActorType::ComponentClass;
+        return this->actorType() == ErrorCauseActorType::ComponentClass;
     }
 
     bool actorTypeIsComponent() const noexcept
     {
-        return this->actorType() == ActorType::Component;
+        return this->actorType() == ErrorCauseActorType::Component;
     }
 
     bool actorTypeIsMessageIterator() const noexcept
     {
-        return this->actorType() == ActorType::MessageIterator;
+        return this->actorType() == ErrorCauseActorType::MessageIterator;
     }
 
     ConstComponentClassErrorCause asComponentClass() const noexcept;
@@ -93,9 +93,9 @@ public:
         BT_ASSERT(this->actorTypeIsComponentClass());
     }
 
-    bt2::ComponentClass::Type componentClassType() const noexcept
+    bt2::ComponentClassType componentClassType() const noexcept
     {
-        return static_cast<bt2::ComponentClass::Type>(
+        return static_cast<bt2::ComponentClassType>(
             bt_error_cause_component_class_actor_get_component_class_type(this->libObjPtr()));
     }
 
@@ -128,9 +128,9 @@ public:
         return bt_error_cause_component_actor_get_component_name(this->libObjPtr());
     }
 
-    bt2::ComponentClass::Type componentClassType() const noexcept
+    bt2::ComponentClassType componentClassType() const noexcept
     {
-        return static_cast<bt2::ComponentClass::Type>(
+        return static_cast<bt2::ComponentClassType>(
             bt_error_cause_component_actor_get_component_class_type(this->libObjPtr()));
     }
 
@@ -168,9 +168,9 @@ public:
         return bt_error_cause_message_iterator_actor_get_component_name(this->libObjPtr());
     }
 
-    bt2::ComponentClass::Type componentClassType() const noexcept
+    bt2::ComponentClassType componentClassType() const noexcept
     {
-        return static_cast<bt2::ComponentClass::Type>(
+        return static_cast<bt2::ComponentClassType>(
             bt_error_cause_message_iterator_actor_get_component_class_type(this->libObjPtr()));
     }
 
index d203245f9a6c8a154852581be2bb4c90cf668f27..75a5b873f2fa3fa90df46355ddc92f6c90803a8f 100644 (file)
@@ -102,27 +102,27 @@ struct FieldPathRefFuncs final
 
 } /* namespace internal */
 
+enum class FieldPathScope
+{
+    PacketContext = BT_FIELD_PATH_SCOPE_PACKET_CONTEXT,
+    EventCommonContext = BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT,
+    EventSpecificContext = BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT,
+    EventPayload = BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD,
+};
+
 class ConstFieldPath final : public BorrowedObject<const bt_field_path>
 {
 public:
     using Shared = SharedObject<ConstFieldPath, const bt_field_path, internal::FieldPathRefFuncs>;
     using Iterator = BorrowedObjectIterator<ConstFieldPath>;
 
-    enum class Scope
-    {
-        PacketContext = BT_FIELD_PATH_SCOPE_PACKET_CONTEXT,
-        EventCommonContext = BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT,
-        EventSpecificContext = BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT,
-        EventPayload = BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD,
-    };
-
     explicit ConstFieldPath(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
     {
     }
 
-    Scope rootScope() const noexcept
+    FieldPathScope rootScope() const noexcept
     {
-        return static_cast<Scope>(bt_field_path_get_root_scope(this->libObjPtr()));
+        return static_cast<FieldPathScope>(bt_field_path_get_root_scope(this->libObjPtr()));
     }
 
     std::uint64_t length() const noexcept
index 18124b876de58953400a13b765d4e914044ae4f0..07c65924d931b4a27dd3d7da6402b8dbe10fccdd 100644 (file)
@@ -855,6 +855,31 @@ using DepStructFc = DepType<LibObjT, StructureFieldClass, ConstStructureFieldCla
 
 } /* namespace internal */
 
+/* Avoid `-Wshadow` error on GCC, conflicting with `bt2::Error` */
+BT_DIAG_PUSH
+BT_DIAG_IGNORE_SHADOW
+
+enum class EventClassLogLevel
+{
+    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
+
 template <typename LibObjT>
 class CommonEventClass final : public BorrowedObject<LibObjT>
 {
@@ -871,31 +896,6 @@ 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,
-        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}
     {
     }
@@ -943,7 +943,7 @@ public:
         return bt_event_class_get_name(this->libObjPtr());
     }
 
-    CommonEventClass logLevel(const LogLevel logLevel) const noexcept
+    CommonEventClass logLevel(const EventClassLogLevel logLevel) const noexcept
     {
         static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
 
@@ -952,12 +952,12 @@ public:
         return *this;
     }
 
-    bt2s::optional<LogLevel> logLevel() const noexcept
+    bt2s::optional<EventClassLogLevel> logLevel() const noexcept
     {
         bt_event_class_log_level libLogLevel;
 
         if (bt_event_class_get_log_level(this->libObjPtr(), &libLogLevel)) {
-            return static_cast<LogLevel>(libLogLevel);
+            return static_cast<EventClassLogLevel>(libLogLevel);
         }
 
         return bt2s::nullopt;
This page took 0.028994 seconds and 4 git commands to generate.