Commit | Line | Data |
---|---|---|
81447b5b PP |
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 | ||
81447b5b PP |
25 | /* Type */ |
26 | struct bt_ctf_trace; | |
27 | ||
28 | /* Functions */ | |
29 | struct bt_ctf_trace *bt_ctf_trace_create(void); | |
f6a5e476 PP |
30 | const char *bt_ctf_trace_get_name(struct bt_ctf_trace *trace_class); |
31 | int bt_ctf_trace_set_name(struct bt_ctf_trace *trace_class, | |
81447b5b | 32 | const char *name); |
f6a5e476 PP |
33 | enum bt_ctf_byte_order bt_ctf_trace_get_native_byte_order( |
34 | struct bt_ctf_trace *trace_class); | |
35 | int bt_ctf_trace_set_native_byte_order(struct bt_ctf_trace *trace_class, | |
36 | enum bt_ctf_byte_order native_byte_order); | |
37 | BTUUID bt_ctf_trace_get_uuid( | |
38 | struct bt_ctf_trace *trace_class); | |
39 | int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace_class, | |
40 | BTUUID uuid); | |
41 | int64_t bt_ctf_trace_get_environment_field_count( | |
42 | struct bt_ctf_trace *trace_class); | |
81447b5b | 43 | const char * |
f6a5e476 PP |
44 | bt_ctf_trace_get_environment_field_name_by_index( |
45 | struct bt_ctf_trace *trace_class, uint64_t index); | |
81447b5b | 46 | struct bt_value * |
f6a5e476 PP |
47 | bt_ctf_trace_get_environment_field_value_by_index(struct bt_ctf_trace *trace_class, |
48 | uint64_t index); | |
81447b5b PP |
49 | struct bt_value * |
50 | bt_ctf_trace_get_environment_field_value_by_name( | |
f6a5e476 | 51 | struct bt_ctf_trace *trace_class, const char *name); |
81447b5b | 52 | int bt_ctf_trace_set_environment_field( |
f6a5e476 | 53 | struct bt_ctf_trace *trace_class, const char *name, |
81447b5b PP |
54 | struct bt_value *value); |
55 | struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type( | |
f6a5e476 PP |
56 | struct bt_ctf_trace *trace_class); |
57 | int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace_class, | |
81447b5b | 58 | struct bt_ctf_field_type *packet_header_type); |
f6a5e476 PP |
59 | int64_t bt_ctf_trace_get_clock_class_count( |
60 | struct bt_ctf_trace *trace_class); | |
61 | struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_index( | |
62 | struct bt_ctf_trace *trace_class, uint64_t index); | |
81447b5b | 63 | struct bt_ctf_clock_class *bt_ctf_trace_get_clock_class_by_name( |
f6a5e476 PP |
64 | struct bt_ctf_trace *trace_class, const char *name); |
65 | int bt_ctf_trace_add_clock_class(struct bt_ctf_trace *trace_class, | |
81447b5b | 66 | struct bt_ctf_clock_class *clock_class); |
f6a5e476 PP |
67 | int64_t bt_ctf_trace_get_stream_class_count( |
68 | struct bt_ctf_trace *trace_class); | |
69 | struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_index( | |
70 | struct bt_ctf_trace *trace_class, uint64_t index); | |
81447b5b | 71 | struct bt_ctf_stream_class *bt_ctf_trace_get_stream_class_by_id( |
f6a5e476 PP |
72 | struct bt_ctf_trace *trace_class, uint64_t id); |
73 | int bt_ctf_trace_add_stream_class(struct bt_ctf_trace *trace_class, | |
81447b5b | 74 | struct bt_ctf_stream_class *stream_class); |
f6a5e476 PP |
75 | int64_t bt_ctf_trace_get_stream_count(struct bt_ctf_trace *trace_class); |
76 | struct bt_ctf_stream *bt_ctf_trace_get_stream_by_index( | |
77 | struct bt_ctf_trace *trace_class, uint64_t index); | |
78 | int bt_ctf_trace_is_static(struct bt_ctf_trace *trace_class); | |
79 | int bt_ctf_trace_set_is_static(struct bt_ctf_trace *trace_class); | |
80 | ||
81 | /* Helper functions for Python */ | |
82 | %{ | |
83 | void trace_is_static_listener(struct bt_ctf_trace *trace, void *py_callable) | |
84 | { | |
85 | PyObject *py_trace_ptr = NULL; | |
86 | PyObject *py_res = NULL; | |
87 | ||
88 | py_trace_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace), | |
89 | SWIGTYPE_p_bt_ctf_trace, 0); | |
90 | if (!py_trace_ptr) { | |
91 | BT_LOGF_STR("Failed to create a SWIG pointer object."); | |
92 | abort(); | |
93 | } | |
94 | ||
95 | py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr); | |
96 | assert(py_res == Py_None); | |
97 | Py_DECREF(py_trace_ptr); | |
98 | Py_DECREF(py_res); | |
99 | } | |
100 | ||
101 | void trace_listener_removed(struct bt_ctf_trace *trace, void *py_callable) | |
102 | { | |
103 | assert(py_callable); | |
104 | Py_DECREF(py_callable); | |
105 | } | |
106 | ||
107 | static int bt_py3_trace_add_is_staitc_listener(unsigned long long trace_addr, | |
108 | PyObject *py_callable) | |
109 | { | |
110 | struct bt_ctf_trace *trace = (void *) trace_addr; | |
111 | int ret = 0; | |
112 | ||
113 | assert(trace); | |
114 | assert(py_callable); | |
115 | ret = bt_ctf_trace_add_is_static_listener(trace, | |
116 | trace_is_static_listener, trace_listener_removed, py_callable); | |
117 | if (ret >= 0) { | |
118 | Py_INCREF(py_callable); | |
119 | } | |
120 | ||
121 | return ret; | |
122 | } | |
123 | %} | |
124 | ||
125 | int bt_py3_trace_add_is_staitc_listener(unsigned long long trace_addr, | |
126 | PyObject *py_callable); |