Move bt_{self_component,message_iterator}_status_string() to `common.h`
[babeltrace.git] / src / lib / graph / component.h
... / ...
CommitLineData
1#ifndef BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
2#define BABELTRACE_GRAPH_COMPONENT_INTERNAL_H
3
4/*
5 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
6 * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27#include "common/macros.h"
28#include <babeltrace2/graph/component-const.h>
29#include "lib/object.h"
30#include <babeltrace2/types.h>
31#include <babeltrace2/logging.h>
32#include "common/assert.h"
33#include <glib.h>
34#include <stdio.h>
35
36#include "component-class.h"
37#include "port.h"
38
39typedef void (*bt_component_destroy_listener_func)(
40 struct bt_component *class, void *data);
41
42struct bt_component_destroy_listener {
43 bt_component_destroy_listener_func func;
44 void *data;
45};
46
47struct bt_graph;
48
49struct bt_component {
50 struct bt_object base;
51 struct bt_component_class *class;
52 GString *name;
53 bt_logging_level log_level;
54
55 /*
56 * Internal destroy function specific to a source, filter, or
57 * sink component object.
58 */
59 void (*destroy)(struct bt_component *);
60
61 /* User-defined data */
62 void *user_data;
63
64 /* Input and output ports (weak references) */
65 GPtrArray *input_ports;
66 GPtrArray *output_ports;
67
68 /* Array of struct bt_component_destroy_listener */
69 GArray *destroy_listeners;
70
71 bool initialized;
72};
73
74static inline
75struct bt_graph *bt_component_borrow_graph(struct bt_component *comp)
76{
77 BT_ASSERT(comp);
78 return (void *) bt_object_borrow_parent(&comp->base);
79}
80
81BT_HIDDEN
82int bt_component_create(struct bt_component_class *component_class,
83 const char *name, bt_logging_level log_level,
84 struct bt_component **component);
85
86BT_HIDDEN
87enum bt_self_component_status bt_component_accept_port_connection(
88 struct bt_component *component, struct bt_port *self_port,
89 struct bt_port *other_port);
90
91BT_HIDDEN
92enum bt_self_component_status bt_component_port_connected(
93 struct bt_component *comp,
94 struct bt_port *self_port, struct bt_port *other_port);
95
96BT_HIDDEN
97void bt_component_set_graph(struct bt_component *component,
98 struct bt_graph *graph);
99
100BT_HIDDEN
101uint64_t bt_component_get_input_port_count(const struct bt_component *comp);
102
103BT_HIDDEN
104uint64_t bt_component_get_output_port_count(const struct bt_component *comp);
105
106BT_HIDDEN
107struct bt_port_input *bt_component_borrow_input_port_by_index(
108 struct bt_component *comp, uint64_t index);
109
110BT_HIDDEN
111struct bt_port_output *bt_component_borrow_output_port_by_index(
112 struct bt_component *comp, uint64_t index);
113
114BT_HIDDEN
115struct bt_port_input *bt_component_borrow_input_port_by_name(
116 struct bt_component *comp, const char *name);
117
118BT_HIDDEN
119struct bt_port_output *bt_component_borrow_output_port_by_name(
120 struct bt_component *comp, const char *name);
121
122BT_HIDDEN
123enum bt_self_component_status bt_component_add_input_port(
124 struct bt_component *component, const char *name,
125 void *user_data, struct bt_port **port);
126
127BT_HIDDEN
128enum bt_self_component_status bt_component_add_output_port(
129 struct bt_component *component, const char *name,
130 void *user_data, struct bt_port **port);
131
132BT_HIDDEN
133void bt_component_remove_port(struct bt_component *component,
134 struct bt_port *port);
135
136BT_HIDDEN
137void bt_component_add_destroy_listener(struct bt_component *component,
138 bt_component_destroy_listener_func func, void *data);
139
140BT_HIDDEN
141void bt_component_remove_destroy_listener(struct bt_component *component,
142 bt_component_destroy_listener_func func, void *data);
143
144#endif /* BABELTRACE_GRAPH_COMPONENT_INTERNAL_H */
This page took 0.023472 seconds and 4 git commands to generate.