From 33f209287c8708cf14de930e4ce494e4edd054fa Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 3 Apr 2024 16:12:12 -0400 Subject: [PATCH] cpp-common/bt2: move some enum classes out of enclosing classes Settle on the standard of having these enumerations out of the classes that use them. Change-Id: I241bdca560bf7f9e892d8884c86662166ad2d2c4 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12240 Reviewed-by: Philippe Proulx Tested-by: jenkins --- src/cpp-common/bt2/component-class.hpp | 14 +++---- src/cpp-common/bt2/error.hpp | 38 ++++++++--------- src/cpp-common/bt2/field-path.hpp | 20 ++++----- src/cpp-common/bt2/trace-ir.hpp | 56 +++++++++++++------------- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/src/cpp-common/bt2/component-class.hpp b/src/cpp-common/bt2/component-class.hpp index 3d30ad35..2933d74f 100644 --- a/src/cpp-common/bt2/component-class.hpp +++ b/src/cpp-common/bt2/component-class.hpp @@ -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 class CommonSourceComponentClass; @@ -52,13 +59,6 @@ public: using typename _ThisBorrowedObject::LibObjPtr; using Shared = SharedObject; - 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} { diff --git a/src/cpp-common/bt2/error.hpp b/src/cpp-common/bt2/error.hpp index 030ff239..b9c8c817 100644 --- a/src/cpp-common/bt2/error.hpp +++ b/src/cpp-common/bt2/error.hpp @@ -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 { 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(bt_error_cause_get_actor_type(this->libObjPtr())); + return static_cast(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( + return static_cast( 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( + return static_cast( 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( + return static_cast( bt_error_cause_message_iterator_actor_get_component_class_type(this->libObjPtr())); } diff --git a/src/cpp-common/bt2/field-path.hpp b/src/cpp-common/bt2/field-path.hpp index d203245f..75a5b873 100644 --- a/src/cpp-common/bt2/field-path.hpp +++ b/src/cpp-common/bt2/field-path.hpp @@ -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 { public: using Shared = SharedObject; using Iterator = BorrowedObjectIterator; - 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(bt_field_path_get_root_scope(this->libObjPtr())); + return static_cast(bt_field_path_get_root_scope(this->libObjPtr())); } std::uint64_t length() const noexcept diff --git a/src/cpp-common/bt2/trace-ir.hpp b/src/cpp-common/bt2/trace-ir.hpp index 18124b87..07c65924 100644 --- a/src/cpp-common/bt2/trace-ir.hpp +++ b/src/cpp-common/bt2/trace-ir.hpp @@ -855,6 +855,31 @@ using DepStructFc = DepType class CommonEventClass final : public BorrowedObject { @@ -871,31 +896,6 @@ public: using Shared = SharedObject; using UserAttributes = internal::DepUserAttrs; - /* 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::value, "Not available with `bt2::ConstEventClass`."); @@ -952,12 +952,12 @@ public: return *this; } - bt2s::optional logLevel() const noexcept + bt2s::optional logLevel() const noexcept { bt_event_class_log_level libLogLevel; if (bt_event_class_get_log_level(this->libObjPtr(), &libLogLevel)) { - return static_cast(libLogLevel); + return static_cast(libLogLevel); } return bt2s::nullopt; -- 2.34.1