lib: set component's initial log level when adding it to the graph
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_component.i
CommitLineData
6945df9a
SM
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25/* Output argument typemap for self port output (always appends) */
26%typemap(in, numinputs=0)
27 (bt_self_component_port_input **OUT)
28 (bt_self_component_port_input *temp_self_port = NULL) {
29 $1 = &temp_self_port;
30}
31
32%typemap(argout) bt_self_component_port_input **OUT {
33 if (*$1) {
34 /* SWIG_Python_AppendOutput() steals the created object */
35 $result = SWIG_Python_AppendOutput($result,
36 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
37 SWIGTYPE_p_bt_self_component_port_input, 0));
38 } else {
39 /* SWIG_Python_AppendOutput() steals Py_None */
40 Py_INCREF(Py_None);
41 $result = SWIG_Python_AppendOutput($result, Py_None);
42 }
43}
44
45/* Output argument typemap for self port output (always appends) */
46%typemap(in, numinputs=0)
47 (bt_self_component_port_output **OUT)
48 (bt_self_component_port_output *temp_self_port = NULL) {
49 $1 = &temp_self_port;
50}
51
52%typemap(argout) (bt_self_component_port_output **OUT) {
53 if (*$1) {
54 /* SWIG_Python_AppendOutput() steals the created object */
55 $result = SWIG_Python_AppendOutput($result,
56 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
57 SWIGTYPE_p_bt_self_component_port_output, 0));
58 } else {
59 /* SWIG_Python_AppendOutput() steals Py_None */
60 Py_INCREF(Py_None);
61 $result = SWIG_Python_AppendOutput($result, Py_None);
62 }
63}
64
2e00bc76
SM
65/* Typemaps used for user data attached to self component ports. */
66
67/*
68 * The user data Python object is kept as the user data of the port, we pass
69 * the PyObject pointer directly to the port creation function.
70 */
71%typemap(in) void *PY_SELF_PORT_USER_DATA {
72 $1 = $input;
73}
74
75/*
76 * The port, if created successfully, now owns a reference to the Python object,
77 * we reflect that here.
78 */
79%typemap(argout) void *PY_SELF_PORT_USER_DATA {
80 if (PyLong_AsLong($result) == BT_SELF_COMPONENT_STATUS_OK) {
81 Py_INCREF($1);
82 }
83}
84
6945df9a
SM
85/* From component-const.h */
86
87extern const char *bt_component_get_name(const bt_component *component);
88
e874da19
PP
89extern bt_logging_level bt_component_get_logging_level(
90 const bt_component *component);
91
6945df9a
SM
92extern const bt_component_class *bt_component_borrow_class_const(
93 const bt_component *component);
94
95extern bt_component_class_type bt_component_get_class_type(
96 const bt_component *component);
97
98bt_bool bt_component_is_source(const bt_component *component);
99
100bt_bool bt_component_is_filter(const bt_component *component);
101
102bt_bool bt_component_is_sink(const bt_component *component);
103
104extern bt_bool bt_component_graph_is_canceled(
105 const bt_component *component);
106
107extern void bt_component_get_ref(const bt_component *component);
108
109extern void bt_component_put_ref(const bt_component *component);
110
111/* From component-source-const.h */
112
113const bt_component *bt_component_source_as_component_const(
114 const bt_component_source *component);
115
752d0e47
SM
116extern const bt_component_class_source *
117bt_component_source_borrow_class_const(
118 const bt_component_source *component);
119
6945df9a
SM
120extern uint64_t bt_component_source_get_output_port_count(
121 const bt_component_source *component);
122
123extern const bt_port_output *
124bt_component_source_borrow_output_port_by_name_const(
125 const bt_component_source *component, const char *name);
126
127extern const bt_port_output *
128bt_component_source_borrow_output_port_by_index_const(
129 const bt_component_source *component, uint64_t index);
130
131extern void bt_component_source_get_ref(
132 const bt_component_source *component_source);
133
134extern void bt_component_source_put_ref(
135 const bt_component_source *component_source);
136
137/* From component-filter-const.h */
138
139const bt_component *bt_component_filter_as_component_const(
140 const bt_component_filter *component);
141
752d0e47
SM
142extern const bt_component_class_filter *
143bt_component_filter_borrow_class_const(
144 const bt_component_filter *component);
145
6945df9a
SM
146extern uint64_t bt_component_filter_get_input_port_count(
147 const bt_component_filter *component);
148
149extern const bt_port_input *
150bt_component_filter_borrow_input_port_by_name_const(
151 const bt_component_filter *component, const char *name);
152
153extern const bt_port_input *
154bt_component_filter_borrow_input_port_by_index_const(
155 const bt_component_filter *component, uint64_t index);
156
157extern uint64_t bt_component_filter_get_output_port_count(
158 const bt_component_filter *component);
159
160extern const bt_port_output *
161bt_component_filter_borrow_output_port_by_name_const(
162 const bt_component_filter *component, const char *name);
163
164extern const bt_port_output *
165bt_component_filter_borrow_output_port_by_index_const(
166 const bt_component_filter *component, uint64_t index);
167
168extern void bt_component_filter_get_ref(
169 const bt_component_filter *component_filter);
170
171extern void bt_component_filter_put_ref(
172 const bt_component_filter *component_filter);
173
174/* From component-sink-const.h */
175
176const bt_component *bt_component_sink_as_component_const(
177 const bt_component_sink *component);
178
752d0e47
SM
179extern const bt_component_class_sink *
180bt_component_sink_borrow_class_const(
181 const bt_component_sink *component);
182
6945df9a
SM
183extern uint64_t bt_component_sink_get_input_port_count(
184 const bt_component_sink *component);
185
186extern const bt_port_input *
187bt_component_sink_borrow_input_port_by_name_const(
188 const bt_component_sink *component, const char *name);
189
190extern const bt_port_input *
191bt_component_sink_borrow_input_port_by_index_const(
192 const bt_component_sink *component, uint64_t index);
193
194extern void bt_component_sink_get_ref(
195 const bt_component_sink *component_sink);
196
197extern void bt_component_sink_put_ref(
198 const bt_component_sink *component_sink);
199
200/* From self-component.h */
201
202typedef enum bt_self_component_status {
203 BT_SELF_COMPONENT_STATUS_OK = 0,
204 BT_SELF_COMPONENT_STATUS_END = 1,
205 BT_SELF_COMPONENT_STATUS_AGAIN = 11,
206 BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111,
207 BT_SELF_COMPONENT_STATUS_ERROR = -1,
208 BT_SELF_COMPONENT_STATUS_NOMEM = -12,
209} bt_self_component_status;
210
211const bt_component *bt_self_component_as_component(
212 bt_self_component *self_component);
213
214extern void *bt_self_component_get_data(
215 const bt_self_component *self_component);
216
217extern void bt_self_component_set_data(
218 bt_self_component *self_component, void *data);
219
220/* From self-component-source.h */
221
222bt_self_component *bt_self_component_source_as_self_component(
223 bt_self_component_source *self_comp_source);
224
225const bt_component_source *
226bt_self_component_source_as_component_source(
227 bt_self_component_source *self_comp_source);
228
229extern bt_self_component_port_output *
230bt_self_component_source_borrow_output_port_by_name(
231 bt_self_component_source *self_component,
232 const char *name);
233
234extern bt_self_component_port_output *
235bt_self_component_source_borrow_output_port_by_index(
236 bt_self_component_source *self_component,
237 uint64_t index);
238
239extern bt_self_component_status
240bt_self_component_source_add_output_port(
241 bt_self_component_source *self_component,
2e00bc76 242 const char *name, void *PY_SELF_PORT_USER_DATA,
6945df9a
SM
243 bt_self_component_port_output **OUT);
244
245/* From self-component-filter.h */
246
247bt_self_component *bt_self_component_filter_as_self_component(
248 bt_self_component_filter *self_comp_filter);
249
250const bt_component_filter *
251bt_self_component_filter_as_component_filter(
252 bt_self_component_filter *self_comp_filter);
253
254extern bt_self_component_port_output *
255bt_self_component_filter_borrow_output_port_by_name(
256 bt_self_component_filter *self_component,
257 const char *name);
258
259extern bt_self_component_port_output *
260bt_self_component_filter_borrow_output_port_by_index(
261 bt_self_component_filter *self_component,
262 uint64_t index);
263
264extern bt_self_component_status
265bt_self_component_filter_add_output_port(
266 bt_self_component_filter *self_component,
2e00bc76 267 const char *name, void *PY_SELF_PORT_USER_DATA,
6945df9a
SM
268 bt_self_component_port_output **OUT);
269
270extern bt_self_component_port_input *
271bt_self_component_filter_borrow_input_port_by_name(
272 bt_self_component_filter *self_component,
273 const char *name);
274
275extern bt_self_component_port_input *
276bt_self_component_filter_borrow_input_port_by_index(
277 bt_self_component_filter *self_component,
278 uint64_t index);
279
280extern bt_self_component_status
281bt_self_component_filter_add_input_port(
282 bt_self_component_filter *self_component,
2e00bc76 283 const char *name, void *PY_SELF_PORT_USER_DATA,
6945df9a
SM
284 bt_self_component_port_input **OUT);
285
286/* From self-component-sink.h */
287
288bt_self_component *bt_self_component_sink_as_self_component(
289 bt_self_component_sink *self_comp_sink);
290
291const bt_component_sink *
292bt_self_component_sink_as_component_sink(
293 bt_self_component_sink *self_comp_sink);
294
295extern bt_self_component_port_input *
296bt_self_component_sink_borrow_input_port_by_name(
297 bt_self_component_sink *self_component,
298 const char *name);
299
300extern bt_self_component_port_input *
301bt_self_component_sink_borrow_input_port_by_index(
302 bt_self_component_sink *self_component, uint64_t index);
303
304extern bt_self_component_status
305bt_self_component_sink_add_input_port(
306 bt_self_component_sink *self_component,
2e00bc76 307 const char *name, void *PY_SELF_PORT_USER_DATA,
6945df9a 308 bt_self_component_port_input **OUT);
This page took 0.038475 seconds and 4 git commands to generate.