Rename `BT_LOG_LEVEL` -> `BT_MINIMAL_LOG_LEVEL`
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_trace_class.i
CommitLineData
6945df9a
SM
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2016 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/* From trace-class-const.h */
26
27typedef enum bt_trace_class_status {
28 BT_TRACE_CLASS_STATUS_OK = 0,
29 BT_TRACE_CLASS_STATUS_NOMEM = -12,
30} bt_trace_class_status;
31
32typedef void (* bt_trace_class_destruction_listener_func)(
33 const bt_trace_class *trace_class, void *data);
34
35extern bt_bool bt_trace_class_assigns_automatic_stream_class_id(
36 const bt_trace_class *trace_class);
37
38extern const char *bt_trace_class_get_name(
39 const bt_trace_class *trace_class);
40
41extern bt_uuid bt_trace_class_get_uuid(
42 const bt_trace_class *trace_class);
43
44extern uint64_t bt_trace_class_get_environment_entry_count(
45 const bt_trace_class *trace_class);
46
47extern void bt_trace_class_borrow_environment_entry_by_index_const(
48 const bt_trace_class *trace_class, uint64_t index,
fbbe9302 49 const char **OUT, const bt_value **OUT);
6945df9a
SM
50
51extern const bt_value *
52bt_trace_class_borrow_environment_entry_value_by_name_const(
53 const bt_trace_class *trace_class, const char *name);
54
55extern uint64_t bt_trace_class_get_stream_class_count(
56 const bt_trace_class *trace_class);
57
58extern const bt_stream_class *
59bt_trace_class_borrow_stream_class_by_index_const(
60 const bt_trace_class *trace_class, uint64_t index);
61
62extern const bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const(
63 const bt_trace_class *trace_class, uint64_t id);
64
65extern bt_trace_class_status bt_trace_class_add_destruction_listener(
66 const bt_trace_class *trace_class,
67 bt_trace_class_destruction_listener_func listener,
68 void *data, uint64_t *listener_id);
69
70extern bt_trace_class_status bt_trace_class_remove_destruction_listener(
71 const bt_trace_class *trace_class, uint64_t listener_id);
72
73extern void bt_trace_class_get_ref(const bt_trace_class *trace_class);
74
75extern void bt_trace_class_put_ref(const bt_trace_class *trace_class);
76
77/* From trace-class.h */
78
79extern bt_trace_class *bt_trace_class_create(bt_self_component *self_comp);
80
81extern void bt_trace_class_set_assigns_automatic_stream_class_id(
82 bt_trace_class *trace_class, bt_bool value);
83
84extern bt_trace_class_status bt_trace_class_set_name(
85 bt_trace_class *trace_class, const char *name);
86
87extern void bt_trace_class_set_uuid(bt_trace_class *trace_class,
88 bt_uuid uuid);
89
90extern bt_trace_class_status bt_trace_class_set_environment_entry_integer(
91 bt_trace_class *trace_class,
92 const char *name, int64_t value);
93
94extern bt_trace_class_status bt_trace_class_set_environment_entry_string(
95 bt_trace_class *trace_class,
96 const char *name, const char *value);
97
98extern bt_stream_class *bt_trace_class_borrow_stream_class_by_index(
99 bt_trace_class *trace_class, uint64_t index);
100
101extern bt_stream_class *bt_trace_class_borrow_stream_class_by_id(
102 bt_trace_class *trace_class, uint64_t id);
103
104/* Helper functions for Python */
105%{
106static void
107trace_class_destroyed_listener(const bt_trace_class *trace_class, void *py_callable)
108{
109 PyObject *py_trace_class_ptr = NULL;
110 PyObject *py_res = NULL;
111
112 py_trace_class_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace_class),
113 SWIGTYPE_p_bt_trace_class, 0);
114 if (!py_trace_class_ptr) {
115 BT_LOGF_STR("Failed to create a SWIG pointer object.");
116 abort();
117 }
118
119 py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_class_ptr);
120 if (py_res != NULL) {
121 BT_ASSERT(py_res == Py_None);
122 } else {
123 bt2_py_loge_exception();
124 }
125
126 Py_DECREF(py_trace_class_ptr);
127 Py_XDECREF(py_res);
128}
129
130uint64_t bt_py3_trace_class_add_destruction_listener(bt_trace_class *trace_class,
131 PyObject *py_callable)
132{
133 uint64_t id = UINT64_C(-1);
134 bt_trace_class_status status;
135
136 BT_ASSERT(trace_class);
137 BT_ASSERT(py_callable);
138
139 status = bt_trace_class_add_destruction_listener(
140 trace_class, trace_class_destroyed_listener, py_callable, &id);
141 if (status != BT_TRACE_CLASS_STATUS_OK) {
142 BT_LOGF_STR("Failed to add trace class destruction listener.");
143 abort();
144 }
145
146 Py_INCREF(py_callable);
147
148 return id;
149}
150%}
151
152uint64_t bt_py3_trace_class_add_destruction_listener(bt_trace_class *trace_class,
153 PyObject *py_callable);
This page took 0.032601 seconds and 4 git commands to generate.