Commit | Line | Data |
---|---|---|
6cdbfd7a | 1 | /* |
0235b0db MJ |
2 | * SPDX-License-Identifier: MIT |
3 | * | |
e2f7325d | 4 | * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com> |
6cdbfd7a | 5 | * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
6cdbfd7a JG |
6 | */ |
7 | ||
350ad6c1 | 8 | #define BT_LOG_TAG "LIB/MSG" |
c2d9d9cf | 9 | #include "lib/logging.h" |
f6ccaed9 | 10 | |
578e048b | 11 | #include "common/assert.h" |
d98421f2 | 12 | #include "lib/assert-cond.h" |
43c59509 | 13 | #include <babeltrace2/graph/message.h> |
578e048b MJ |
14 | #include "lib/graph/message/message.h" |
15 | #include "lib/graph/graph.h" | |
6cdbfd7a | 16 | |
78586d8a | 17 | BT_HIDDEN |
d6e69534 PP |
18 | void bt_message_init(struct bt_message *message, |
19 | enum bt_message_type type, | |
5c563278 PP |
20 | bt_object_release_func release, |
21 | struct bt_graph *graph) | |
78586d8a | 22 | { |
d6e69534 | 23 | message->type = type; |
d6e69534 PP |
24 | bt_object_init_shared(&message->base, release); |
25 | message->graph = graph; | |
5c563278 PP |
26 | |
27 | if (graph) { | |
d6e69534 | 28 | bt_graph_add_message(graph, message); |
5c563278 | 29 | } |
78586d8a JG |
30 | } |
31 | ||
d6e69534 PP |
32 | enum bt_message_type bt_message_get_type( |
33 | const struct bt_message *message) | |
6cdbfd7a | 34 | { |
bdb288b3 | 35 | BT_ASSERT_PRE_DEV_NON_NULL(message, "Message"); |
d6e69534 | 36 | return message->type; |
6cdbfd7a | 37 | } |
5c563278 PP |
38 | |
39 | BT_HIDDEN | |
d6e69534 | 40 | void bt_message_unlink_graph(struct bt_message *msg) |
5c563278 | 41 | { |
d6e69534 PP |
42 | BT_ASSERT(msg); |
43 | msg->graph = NULL; | |
5c563278 | 44 | } |
c5b9b441 | 45 | |
d6e69534 | 46 | void bt_message_get_ref(const struct bt_message *message) |
c5b9b441 | 47 | { |
d6e69534 | 48 | bt_object_get_ref(message); |
c5b9b441 PP |
49 | } |
50 | ||
d6e69534 | 51 | void bt_message_put_ref(const struct bt_message *message) |
c5b9b441 | 52 | { |
d6e69534 | 53 | bt_object_put_ref(message); |
c5b9b441 | 54 | } |