| 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 | void bt_message_init(struct bt_message *message, |
| 18 | enum bt_message_type type, |
| 19 | bt_object_release_func release, |
| 20 | struct bt_graph *graph) |
| 21 | { |
| 22 | message->type = type; |
| 23 | bt_object_init_shared(&message->base, release); |
| 24 | message->graph = graph; |
| 25 | |
| 26 | if (graph) { |
| 27 | bt_graph_add_message(graph, message); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | BT_EXPORT |
| 32 | enum bt_message_type bt_message_get_type( |
| 33 | const struct bt_message *message) |
| 34 | { |
| 35 | BT_ASSERT_PRE_DEV_MSG_NON_NULL(message); |
| 36 | return message->type; |
| 37 | } |
| 38 | |
| 39 | void bt_message_unlink_graph(struct bt_message *msg) |
| 40 | { |
| 41 | BT_ASSERT(msg); |
| 42 | msg->graph = NULL; |
| 43 | } |
| 44 | |
| 45 | BT_EXPORT |
| 46 | void bt_message_get_ref(const struct bt_message *message) |
| 47 | { |
| 48 | bt_object_get_ref(message); |
| 49 | } |
| 50 | |
| 51 | BT_EXPORT |
| 52 | void bt_message_put_ref(const struct bt_message *message) |
| 53 | { |
| 54 | bt_object_put_ref(message); |
| 55 | } |