Document libbabeltrace2's C API
[babeltrace.git] / src / lib / graph / message / message.h
index a1e529974594aeb14a9e4308c2c783602318acdb..ec7d2a6ca695ed59d48a2641bf4c579582d1f6b3 100644 (file)
@@ -33,7 +33,7 @@
 #include "lib/object.h"
 #include "common/assert.h"
 #include <babeltrace2/graph/graph.h>
-#include <babeltrace2/graph/message-const.h>
+#include <babeltrace2/graph/message.h>
 #include <babeltrace2/trace-ir/stream.h>
 #include "lib/object-pool.h"
 #include <babeltrace2/types.h>
@@ -55,11 +55,23 @@ struct bt_message {
        struct bt_graph *graph;
 };
 
-#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type)                 \
-       BT_ASSERT_PRE(((struct bt_message *) (_msg))->type == (_type), \
-               "Message has the wrong type: expected-type=%s, "        \
-               "%![msg-]+n", bt_message_type_string(_type),    \
-               (_msg))
+#define _BT_ASSERT_PRE_MSG_IS_TYPE_COND(_msg, _type)                   \
+       (((struct bt_message *) (_msg))->type == (_type))
+
+#define _BT_ASSERT_PRE_MSG_IS_TYPE_FMT                                 \
+       "Message has the wrong type: expected-type=%s, %![msg-]+n"
+
+#define BT_ASSERT_PRE_MSG_IS_TYPE(_msg, _type)                         \
+       BT_ASSERT_PRE(                                                  \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)),       \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_FMT,                         \
+               bt_message_type_string(_type), (_msg))
+
+#define BT_ASSERT_PRE_DEV_MSG_IS_TYPE(_msg, _type)                     \
+       BT_ASSERT_PRE_DEV(                                              \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_COND((_msg), (_type)),       \
+               _BT_ASSERT_PRE_MSG_IS_TYPE_FMT,                         \
+               bt_message_type_string(_type), (_msg))
 
 BT_HIDDEN
 void bt_message_init(struct bt_message *message,
@@ -70,7 +82,7 @@ void bt_message_init(struct bt_message *message,
 static inline
 void bt_message_reset(struct bt_message *message)
 {
-       BT_ASSERT(message);
+       BT_ASSERT_DBG(message);
 
 #ifdef BT_DEV_MODE
        message->frozen = BT_FALSE;
@@ -122,19 +134,19 @@ const char *bt_message_type_string(enum bt_message_type type)
 {
        switch (type) {
        case BT_MESSAGE_TYPE_EVENT:
-               return "BT_MESSAGE_TYPE_EVENT";
+               return "EVENT";
        case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
-               return "BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY";
+               return "MESSAGE_ITERATOR_INACTIVITY";
        case BT_MESSAGE_TYPE_STREAM_BEGINNING:
-               return "BT_MESSAGE_TYPE_STREAM_BEGINNING";
+               return "STREAM_BEGINNING";
        case BT_MESSAGE_TYPE_STREAM_END:
-               return "BT_MESSAGE_TYPE_STREAM_END";
+               return "STREAM_END";
        case BT_MESSAGE_TYPE_PACKET_BEGINNING:
-               return "BT_MESSAGE_TYPE_PACKET_BEGINNING";
+               return "PACKET_BEGINNING";
        case BT_MESSAGE_TYPE_PACKET_END:
-               return "BT_MESSAGE_TYPE_PACKET_END";
+               return "PACKET_END";
        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
-               return "BT_MESSAGE_TYPE_DISCARDED_EVENTS";
+               return "DISCARDED_EVENTS";
        default:
                return "(unknown)";
        }
This page took 0.023849 seconds and 4 git commands to generate.