cpp-common/bt2: make `MessageType` a wise enum
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 4 Apr 2024 03:02:27 +0000 (23:02 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: I46182e774ae480b20461ce44add48cea47bb0f3a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12244
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cpp-common/bt2/message.hpp
src/cpp-common/bt2c/fmt.hpp

index 93f8acd61ee311dfff485976007612b58b012418..77321778ad0394e6e81482400219a8f0731524e5 100644 (file)
@@ -16,6 +16,7 @@
 #include "cpp-common/bt2/clock-snapshot.hpp"
 #include "cpp-common/bt2/trace-ir.hpp"
 #include "cpp-common/bt2s/optional.hpp"
+#include "cpp-common/vendor/wise-enum/wise_enum.h"
 
 #include "borrowed-object.hpp"
 #include "internal/utils.hpp"
@@ -68,17 +69,19 @@ class CommonDiscardedPacketsMessage;
 template <typename LibObjT>
 class CommonMessageIteratorInactivityMessage;
 
-enum class MessageType
-{
-    StreamBeginning = BT_MESSAGE_TYPE_STREAM_BEGINNING,
-    StreamEnd = BT_MESSAGE_TYPE_STREAM_END,
-    Event = BT_MESSAGE_TYPE_EVENT,
-    PacketBeginning = BT_MESSAGE_TYPE_PACKET_BEGINNING,
-    PacketEnd = BT_MESSAGE_TYPE_PACKET_END,
-    DiscardedEvents = BT_MESSAGE_TYPE_DISCARDED_EVENTS,
-    DiscardedPackets = BT_MESSAGE_TYPE_DISCARDED_PACKETS,
-    MessageIteratorInactivity = BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY,
-};
+/* clang-format off */
+
+WISE_ENUM_CLASS(MessageType,
+    (StreamBeginning, BT_MESSAGE_TYPE_STREAM_BEGINNING),
+    (StreamEnd, BT_MESSAGE_TYPE_STREAM_END),
+    (Event, BT_MESSAGE_TYPE_EVENT),
+    (PacketBeginning, BT_MESSAGE_TYPE_PACKET_BEGINNING),
+    (PacketEnd, BT_MESSAGE_TYPE_PACKET_END),
+    (DiscardedEvents, BT_MESSAGE_TYPE_DISCARDED_EVENTS),
+    (DiscardedPackets, BT_MESSAGE_TYPE_DISCARDED_PACKETS),
+    (MessageIteratorInactivity, BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY));
+
+/* clang-format on */
 
 template <typename LibObjT>
 class CommonMessage : public BorrowedObject<LibObjT>
index 4633ebca73b03233e1cc2c9ec7e9df120c66d463..a78d7a61af83f37bb7f5b4c96c0035b568401908 100644 (file)
@@ -4,8 +4,6 @@
  * SPDX-License-Identifier: MIT
  */
 
-#include "common/common.h"
-#include "cpp-common/bt2/message.hpp"
 #include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */
 #include "cpp-common/vendor/wise-enum/wise_enum.h"
 
@@ -27,11 +25,6 @@ template <typename T>
     return wise_enum::to_string<T>(val);
 }
 
-inline const char *format_as(const MessageType type)
-{
-    return bt_common_message_type_string(static_cast<bt_message_type>(type));
-}
-
 } /* namespace bt2 */
 
 namespace bt2c {
This page took 0.033882 seconds and 4 git commands to generate.