lib: merge `assert-pre.h` and `assert-post.h` into `assert-cond.h`
[babeltrace.git] / src / lib / graph / message / message.c
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
5 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 */
7
8 #define BT_LOG_TAG "LIB/MSG"
9 #include "lib/logging.h"
10
11 #include "common/assert.h"
12 #include "lib/assert-cond.h"
13 #include <babeltrace2/graph/message.h>
14 #include "lib/graph/message/message.h"
15 #include "lib/graph/graph.h"
16
17 BT_HIDDEN
18 void bt_message_init(struct bt_message *message,
19 enum bt_message_type type,
20 bt_object_release_func release,
21 struct bt_graph *graph)
22 {
23 message->type = type;
24 bt_object_init_shared(&message->base, release);
25 message->graph = graph;
26
27 if (graph) {
28 bt_graph_add_message(graph, message);
29 }
30 }
31
32 enum bt_message_type bt_message_get_type(
33 const struct bt_message *message)
34 {
35 BT_ASSERT_PRE_DEV_NON_NULL(message, "Message");
36 return message->type;
37 }
38
39 BT_HIDDEN
40 void bt_message_unlink_graph(struct bt_message *msg)
41 {
42 BT_ASSERT(msg);
43 msg->graph = NULL;
44 }
45
46 void bt_message_get_ref(const struct bt_message *message)
47 {
48 bt_object_get_ref(message);
49 }
50
51 void bt_message_put_ref(const struct bt_message *message)
52 {
53 bt_object_put_ref(message);
54 }
This page took 0.030041 seconds and 4 git commands to generate.