lib: update copyrights
[babeltrace.git] / lib / graph / component-filter.c
CommitLineData
d94d92ac 1/*
e2f7325d 2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
d94d92ac
PP
3 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 *
d94d92ac
PP
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24#define BT_LOG_TAG "COMP-FILTER"
25#include <babeltrace/lib-logging-internal.h>
26
27#include <babeltrace/compiler-internal.h>
c6bd8523 28#include <babeltrace/value.h>
d94d92ac 29#include <babeltrace/graph/self-component-filter.h>
0d72b8c3 30#include <babeltrace/graph/component-filter-const.h>
d94d92ac
PP
31#include <babeltrace/graph/component-filter-internal.h>
32#include <babeltrace/graph/component-internal.h>
33#include <babeltrace/graph/component-class-internal.h>
d94d92ac
PP
34#include <babeltrace/graph/graph.h>
35#include <babeltrace/object.h>
36#include <babeltrace/assert-internal.h>
37#include <babeltrace/assert-pre-internal.h>
38
39BT_HIDDEN
40void bt_component_filter_destroy(struct bt_component *component)
41{
42}
43
44BT_HIDDEN
45struct bt_component *bt_component_filter_create(
0d72b8c3 46 const struct bt_component_class *class)
d94d92ac
PP
47{
48 struct bt_component_filter *filter = NULL;
49
50 filter = g_new0(struct bt_component_filter, 1);
51 if (!filter) {
52 BT_LOGE_STR("Failed to allocate one filter component.");
53 goto end;
54 }
55
56end:
57 return (void *) filter;
58}
59
60uint64_t bt_component_filter_get_output_port_count(
0d72b8c3 61 const struct bt_component_filter *comp)
d94d92ac
PP
62{
63 return bt_component_get_output_port_count((void *) comp);
64}
65
0d72b8c3
PP
66const struct bt_port_output *
67bt_component_filter_borrow_output_port_by_name_const(
68 const struct bt_component_filter *comp, const char *name)
d94d92ac
PP
69{
70 return bt_component_borrow_output_port_by_name(
71 (void *) comp, name);
72}
73
74struct bt_self_component_port_output *
75bt_self_component_filter_borrow_output_port_by_name(
76 struct bt_self_component_filter *comp, const char *name)
77{
78 return (void *) bt_component_borrow_output_port_by_name(
79 (void *) comp, name);
80}
81
0d72b8c3
PP
82const struct bt_port_output *
83bt_component_filter_borrow_output_port_by_index_const(
84 const struct bt_component_filter *comp, uint64_t index)
d94d92ac
PP
85{
86 return bt_component_borrow_output_port_by_index(
87 (void *) comp, index);
88}
89
90struct bt_self_component_port_output *
91bt_self_component_filter_borrow_output_port_by_index(
92 struct bt_self_component_filter *comp, uint64_t index)
93{
94 return (void *) bt_component_borrow_output_port_by_index(
95 (void *) comp, index);
96}
97
98enum bt_self_component_status bt_self_component_filter_add_output_port(
99 struct bt_self_component_filter *self_comp,
100 const char *name, void *user_data,
101 struct bt_self_component_port_output **self_port)
102{
103 struct bt_component *comp = (void *) self_comp;
104 int status = BT_SELF_COMPONENT_STATUS_OK;
105 struct bt_port *port = NULL;
106
107 /* bt_component_add_output_port() logs details and errors */
108 port = (void *) bt_component_add_output_port(comp, name, user_data);
109 if (!port) {
110 status = BT_SELF_COMPONENT_STATUS_NOMEM;
111 goto end;
112 }
113
114 if (self_port) {
115 /* Move reference to user */
116 *self_port = (void *) port;
117 port = NULL;
118 }
119
120end:
121 bt_object_put_ref(port);
122 return status;
123}
124
125uint64_t bt_component_filter_get_input_port_count(
0d72b8c3 126 const struct bt_component_filter *component)
d94d92ac
PP
127{
128 /* bt_component_get_input_port_count() logs details/errors */
129 return bt_component_get_input_port_count((void *) component);
130}
131
0d72b8c3
PP
132const struct bt_port_input *bt_component_filter_borrow_input_port_by_name_const(
133 const struct bt_component_filter *component, const char *name)
d94d92ac
PP
134{
135 /* bt_component_borrow_input_port_by_name() logs details/errors */
136 return bt_component_borrow_input_port_by_name(
137 (void *) component, name);
138}
139
140struct bt_self_component_port_input *
141bt_self_component_filter_borrow_input_port_by_name(
142 struct bt_self_component_filter *component, const char *name)
143{
144 /* bt_component_borrow_input_port_by_name() logs details/errors */
145 return (void *) bt_component_borrow_input_port_by_name(
146 (void *) component, name);
147}
148
0d72b8c3
PP
149const struct bt_port_input *
150bt_component_filter_borrow_input_port_by_index_const(
151 const struct bt_component_filter *component, uint64_t index)
d94d92ac
PP
152{
153 /* bt_component_borrow_input_port_by_index() logs details/errors */
154 return bt_component_borrow_input_port_by_index(
155 (void *) component, index);
156}
157
158struct bt_self_component_port_input *
159bt_self_component_filter_borrow_input_port_by_index(
160 struct bt_self_component_filter *component, uint64_t index)
161{
162 /* bt_component_borrow_input_port_by_index() logs details/errors */
163 return (void *) bt_component_borrow_input_port_by_index(
164 (void *) component, index);
165}
166
167enum bt_self_component_status bt_self_component_filter_add_input_port(
168 struct bt_self_component_filter *self_comp,
169 const char *name, void *user_data,
170 struct bt_self_component_port_input **self_port)
171{
172 int status = BT_SELF_COMPONENT_STATUS_OK;
173 struct bt_port *port = NULL;
174 struct bt_component *comp = (void *) self_comp;
175
176 /* bt_component_add_input_port() logs details/errors */
177 port = (void *) bt_component_add_input_port(comp, name, user_data);
178 if (!port) {
179 status = BT_SELF_COMPONENT_STATUS_NOMEM;
180 goto end;
181 }
182
183 if (self_port) {
184 /* Move reference to user */
185 *self_port = (void *) port;
186 port = NULL;
187 }
188
189end:
190 bt_object_put_ref(port);
191 return status;
192}
This page took 0.029386 seconds and 4 git commands to generate.