babeltrace2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/babeltrace2.gemspec +13 -0
  4. data/lib/babeltrace2.rb +49 -0
  5. data/lib/babeltrace2/error-reporting.rb +432 -0
  6. data/lib/babeltrace2/func-status.rb +26 -0
  7. data/lib/babeltrace2/graph/component-class-dev.rb +801 -0
  8. data/lib/babeltrace2/graph/component-class.rb +134 -0
  9. data/lib/babeltrace2/graph/component-descriptor-set.rb +78 -0
  10. data/lib/babeltrace2/graph/component.rb +362 -0
  11. data/lib/babeltrace2/graph/connection.rb +35 -0
  12. data/lib/babeltrace2/graph/graph.rb +523 -0
  13. data/lib/babeltrace2/graph/interrupter.rb +57 -0
  14. data/lib/babeltrace2/graph/message-iterator-class.rb +374 -0
  15. data/lib/babeltrace2/graph/message-iterator.rb +253 -0
  16. data/lib/babeltrace2/graph/message.rb +721 -0
  17. data/lib/babeltrace2/graph/port.rb +124 -0
  18. data/lib/babeltrace2/graph/private-query-executor.rb +4 -0
  19. data/lib/babeltrace2/graph/query-executor.rb +142 -0
  20. data/lib/babeltrace2/graph/self-component-class.rb +37 -0
  21. data/lib/babeltrace2/graph/self-component-port.rb +35 -0
  22. data/lib/babeltrace2/graph/self-component.rb +264 -0
  23. data/lib/babeltrace2/graph/self-message-iterator.rb +147 -0
  24. data/lib/babeltrace2/integer-range-set.rb +275 -0
  25. data/lib/babeltrace2/logging-defs.rb +19 -0
  26. data/lib/babeltrace2/logging.rb +77 -0
  27. data/lib/babeltrace2/plugin/plugin-dev.rb +335 -0
  28. data/lib/babeltrace2/plugin/plugin-loading.rb +459 -0
  29. data/lib/babeltrace2/trace-ir/clock-class.rb +258 -0
  30. data/lib/babeltrace2/trace-ir/clock-snapshot.rb +45 -0
  31. data/lib/babeltrace2/trace-ir/event-class.rb +292 -0
  32. data/lib/babeltrace2/trace-ir/event.rb +91 -0
  33. data/lib/babeltrace2/trace-ir/field-class.rb +1416 -0
  34. data/lib/babeltrace2/trace-ir/field-path.rb +123 -0
  35. data/lib/babeltrace2/trace-ir/field.rb +871 -0
  36. data/lib/babeltrace2/trace-ir/packet.rb +57 -0
  37. data/lib/babeltrace2/trace-ir/stream-class.rb +425 -0
  38. data/lib/babeltrace2/trace-ir/stream.rb +137 -0
  39. data/lib/babeltrace2/trace-ir/trace-class.rb +343 -0
  40. data/lib/babeltrace2/trace-ir/trace.rb +321 -0
  41. data/lib/babeltrace2/types.rb +667 -0
  42. data/lib/babeltrace2/util.rb +23 -0
  43. data/lib/babeltrace2/value.rb +869 -0
  44. data/lib/babeltrace2/version.rb +126 -0
  45. metadata +105 -0
@@ -0,0 +1,35 @@
1
+ module Babeltrace2
2
+
3
+ attach_function :bt_connection_borrow_downstream_port_const,
4
+ [ :bt_connection_handle ],
5
+ :bt_port_input_handle
6
+
7
+ attach_function :bt_connection_borrow_upstream_port_const,
8
+ [ :bt_connection_handle ],
9
+ :bt_port_output_handle
10
+
11
+ attach_function :bt_connection_get_ref,
12
+ [ :bt_connection_handle ],
13
+ :void
14
+
15
+ attach_function :bt_connection_put_ref,
16
+ [ :bt_connection_handle ],
17
+ :void
18
+
19
+ class BTConnection < BTSharedObject
20
+ @get_ref = :bt_connection_get_ref
21
+ @put_ref = :bt_connection_put_ref
22
+
23
+ def get_downstream_port
24
+ handle = Babeltrace2.bt_connection_borrow_downstream_port_const(@handle)
25
+ BTPortInput.new(handle, retain: true)
26
+ end
27
+ alias downstream_port get_downstream_port
28
+
29
+ def get_upstream_port
30
+ handle = Babeltrace2.bt_connection_borrow_upstream_port_const(@handle)
31
+ BTPortOutput.new(handle, retain: true)
32
+ end
33
+ alias upstream_port get_upstream_port
34
+ end
35
+ end
@@ -0,0 +1,523 @@
1
+ module Babeltrace2
2
+
3
+ attach_function :bt_graph_get_ref,
4
+ [:bt_graph_handle],
5
+ :void
6
+ attach_function :bt_graph_put_ref,
7
+ [:bt_graph_handle],
8
+ :void
9
+ attach_function :bt_graph_create,
10
+ [:uint64],
11
+ :bt_graph_handle
12
+
13
+ BTGraphAddComponentStatus = enum :bt_graph_add_component_status,
14
+ [ :BT_GRAPH_ADD_COMPONENT_STATUS_OK, BT_FUNC_STATUS_OK,
15
+ :BT_GRAPH_ADD_COMPONENT_STATUS_MEMORY_ERROR, BT_FUNC_STATUS_MEMORY_ERROR,
16
+ :BT_GRAPH_ADD_COMPONENT_STATUS_ERROR, BT_FUNC_STATUS_ERROR ]
17
+
18
+ attach_function :bt_graph_add_source_component,
19
+ [ :bt_graph_handle,
20
+ :bt_component_class_source_handle,
21
+ :string, :bt_value_map_handle, :bt_logging_level,
22
+ :pointer ],
23
+ :bt_graph_add_component_status
24
+
25
+ attach_function :bt_graph_add_source_component_with_initialize_method_data,
26
+ [ :bt_graph_handle,
27
+ :bt_component_class_source_handle,
28
+ :string, :bt_value_map_handle, :pointer,
29
+ :bt_logging_level, :pointer ],
30
+ :bt_graph_add_component_status
31
+
32
+ attach_function :bt_graph_add_filter_component,
33
+ [ :bt_graph_handle,
34
+ :bt_component_class_filter_handle,
35
+ :string, :bt_value_map_handle, :bt_logging_level,
36
+ :pointer ],
37
+ :bt_graph_add_component_status
38
+
39
+ attach_function :bt_graph_add_filter_component_with_initialize_method_data,
40
+ [ :bt_graph_handle,
41
+ :bt_component_class_filter_handle,
42
+ :string, :bt_value_map_handle, :pointer,
43
+ :bt_logging_level, :pointer ],
44
+ :bt_graph_add_component_status
45
+
46
+ attach_function :bt_graph_add_sink_component,
47
+ [ :bt_graph_handle,
48
+ :bt_component_class_sink_handle,
49
+ :string, :bt_value_map_handle, :bt_logging_level,
50
+ :pointer ],
51
+ :bt_graph_add_component_status
52
+
53
+ attach_function :bt_graph_add_sink_component_with_initialize_method_data,
54
+ [ :bt_graph_handle,
55
+ :bt_component_class_sink_handle,
56
+ :string, :bt_value_map_handle, :pointer,
57
+ :bt_logging_level, :pointer ],
58
+ :bt_graph_add_component_status
59
+
60
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_OK = BT_FUNC_STATUS_OK
61
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
62
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_ERROR = BT_FUNC_STATUS_ERROR
63
+ BTGraphSimpleSinkComponentInitializeFuncStatus =
64
+ enum :bt_graph_simple_sink_component_initialize_func_status,
65
+ [ :BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_OK,
66
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_OK,
67
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_MEMORY_ERROR,
68
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_MEMORY_ERROR,
69
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_ERROR,
70
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_ERROR ]
71
+
72
+ callback :bt_graph_simple_sink_component_initialize_func,
73
+ [ :bt_message_iterator_handle, :pointer ],
74
+ :bt_graph_simple_sink_component_initialize_func_status
75
+
76
+ def self._wrap_graph_simple_sink_component_initialize_func(method)
77
+ lambda { |message_iterator, user_data|
78
+ begin
79
+ method.call(BTMessageIterator.new(message_iterator,
80
+ retain: false, auto_release: false), user_data)
81
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_OK
82
+ rescue Exception => e
83
+ Babeltrace2.stack_ruby_error(e, source: message_iterator)
84
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_INITIALIZE_FUNC_STATUS_ERROR
85
+ end
86
+ }
87
+ end
88
+
89
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_OK = BT_FUNC_STATUS_OK
90
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_END = BT_FUNC_STATUS_END
91
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_AGAIN = BT_FUNC_STATUS_AGAIN
92
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
93
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_ERROR = BT_FUNC_STATUS_ERROR
94
+ BTGraphSimpleSinkComponentConsumeFuncStatus =
95
+ enum :bt_graph_simple_sink_component_consume_func_status,
96
+ [ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_OK,
97
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_OK,
98
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_END,
99
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_END,
100
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_AGAIN,
101
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_AGAIN,
102
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_MEMORY_ERROR,
103
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_MEMORY_ERROR,
104
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_ERROR,
105
+ BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_ERROR ]
106
+
107
+ callback :bt_graph_simple_sink_component_consume_func,
108
+ [ :bt_message_iterator_handle, :pointer ],
109
+ :bt_graph_simple_sink_component_consume_func_status
110
+
111
+ def self._wrap_graph_simple_sink_component_consume_func(method)
112
+ lambda { |message_iterator, user_data|
113
+ begin
114
+ method.call(BTMessageIterator.new(message_iterator,
115
+ retain: false, auto_release: false), user_data)
116
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_OK
117
+ rescue StopIteration
118
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_END
119
+ rescue Exception => e
120
+ Babeltrace2.stack_ruby_error(e, source: message_iterator)
121
+ :BT_GRAPH_SIMPLE_SINK_COMPONENT_CONSUME_FUNC_STATUS_ERROR
122
+ end
123
+ }
124
+ end
125
+
126
+ callback :bt_graph_simple_sink_component_finalize_func,
127
+ [ :pointer ],
128
+ :void
129
+
130
+ attach_function :bt_graph_add_simple_sink_component,
131
+ [ :bt_graph_handle, :string,
132
+ :bt_graph_simple_sink_component_initialize_func,
133
+ :bt_graph_simple_sink_component_consume_func,
134
+ :bt_graph_simple_sink_component_finalize_func,
135
+ :pointer, :pointer ],
136
+ :bt_graph_add_component_status
137
+
138
+ BT_GRAPH_CONNECT_PORTS_STATUS_OK = BT_FUNC_STATUS_OK
139
+ BT_GRAPH_CONNECT_PORTS_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
140
+ BT_GRAPH_CONNECT_PORTS_STATUS_ERROR = BT_FUNC_STATUS_ERROR
141
+ BTGraphConnectPortsStatus =
142
+ enum :bt_graph_connect_ports_status,
143
+ [ :BT_GRAPH_CONNECT_PORTS_STATUS_OK,
144
+ BT_GRAPH_CONNECT_PORTS_STATUS_OK,
145
+ :BT_GRAPH_CONNECT_PORTS_STATUS_MEMORY_ERROR,
146
+ BT_GRAPH_CONNECT_PORTS_STATUS_MEMORY_ERROR,
147
+ :BT_GRAPH_CONNECT_PORTS_STATUS_ERROR,
148
+ BT_GRAPH_CONNECT_PORTS_STATUS_ERROR ]
149
+
150
+ attach_function :bt_graph_connect_ports,
151
+ [ :bt_graph_handle,
152
+ :bt_port_output_handle,
153
+ :bt_port_input_handle,
154
+ :pointer ],
155
+ :bt_graph_connect_ports_status
156
+
157
+ BT_GRAPH_RUN_STATUS_OK = BT_FUNC_STATUS_OK
158
+ BT_GRAPH_RUN_STATUS_AGAIN = BT_FUNC_STATUS_AGAIN
159
+ BT_GRAPH_RUN_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
160
+ BT_GRAPH_RUN_STATUS_ERROR = BT_FUNC_STATUS_ERROR
161
+ BTGraphRunStatus = enum :bt_graph_run_status,
162
+ [ :BT_GRAPH_RUN_STATUS_OK,
163
+ BT_GRAPH_RUN_STATUS_OK,
164
+ :BT_GRAPH_RUN_STATUS_AGAIN,
165
+ BT_GRAPH_RUN_STATUS_AGAIN,
166
+ :BT_GRAPH_RUN_STATUS_MEMORY_ERROR,
167
+ BT_GRAPH_RUN_STATUS_MEMORY_ERROR,
168
+ :BT_GRAPH_RUN_STATUS_ERROR,
169
+ BT_GRAPH_RUN_STATUS_ERROR ]
170
+
171
+ attach_function :bt_graph_run,
172
+ [ :bt_graph_handle ],
173
+ :bt_graph_run_status
174
+
175
+ BT_GRAPH_RUN_ONCE_STATUS_OK = BT_FUNC_STATUS_OK
176
+ BT_GRAPH_RUN_ONCE_STATUS_END = BT_FUNC_STATUS_END
177
+ BT_GRAPH_RUN_ONCE_STATUS_AGAIN = BT_FUNC_STATUS_AGAIN
178
+ BT_GRAPH_RUN_ONCE_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
179
+ BT_GRAPH_RUN_ONCE_STATUS_ERROR = BT_FUNC_STATUS_ERROR
180
+ BTGraphRunOnceStatus = enum :bt_graph_run_once_status,
181
+ [ :BT_GRAPH_RUN_ONCE_STATUS_OK,
182
+ BT_GRAPH_RUN_ONCE_STATUS_OK,
183
+ :BT_GRAPH_RUN_ONCE_STATUS_END,
184
+ BT_GRAPH_RUN_ONCE_STATUS_END,
185
+ :BT_GRAPH_RUN_ONCE_STATUS_AGAIN,
186
+ BT_GRAPH_RUN_ONCE_STATUS_AGAIN,
187
+ :BT_GRAPH_RUN_ONCE_STATUS_MEMORY_ERROR,
188
+ BT_GRAPH_RUN_ONCE_STATUS_MEMORY_ERROR,
189
+ :BT_GRAPH_RUN_ONCE_STATUS_ERROR,
190
+ BT_GRAPH_RUN_ONCE_STATUS_ERROR ]
191
+
192
+ attach_function :bt_graph_run_once,
193
+ [ :bt_graph_handle ],
194
+ :bt_graph_run_once_status
195
+
196
+ BT_GRAPH_ADD_INTERRUPTER_STATUS_OK = BT_FUNC_STATUS_OK
197
+ BT_GRAPH_ADD_INTERRUPTER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
198
+ BTGraphAddInterrupterStatus = enum :bt_graph_add_interrupter_status,
199
+ [ :BT_GRAPH_ADD_INTERRUPTER_STATUS_OK,
200
+ BT_GRAPH_ADD_INTERRUPTER_STATUS_OK,
201
+ :BT_GRAPH_ADD_INTERRUPTER_STATUS_MEMORY_ERROR,
202
+ BT_GRAPH_ADD_INTERRUPTER_STATUS_MEMORY_ERROR ]
203
+
204
+ attach_function :bt_graph_add_interrupter,
205
+ [ :bt_graph_handle, :bt_interrupter_handle ],
206
+ :bt_graph_add_interrupter_status
207
+
208
+ attach_function :bt_graph_borrow_default_interrupter,
209
+ [ :bt_graph_handle ],
210
+ :bt_interrupter_handle
211
+
212
+ BT_GRAPH_ADD_LISTENER_STATUS_OK = BT_FUNC_STATUS_OK
213
+ BT_GRAPH_ADD_LISTENER_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
214
+ BTGraphAddListenerStatus = enum :bt_graph_add_listener_status,
215
+ [ :BT_GRAPH_ADD_LISTENER_STATUS_OK,
216
+ BT_GRAPH_ADD_LISTENER_STATUS_OK,
217
+ :BT_GRAPH_ADD_LISTENER_STATUS_MEMORY_ERROR,
218
+ BT_GRAPH_ADD_LISTENER_STATUS_MEMORY_ERROR ]
219
+
220
+ BT_GRAPH_LISTENER_FUNC_STATUS_OK = BT_FUNC_STATUS_OK
221
+ BT_GRAPH_LISTENER_FUNC_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
222
+ BT_GRAPH_LISTENER_FUNC_STATUS_ERROR = BT_FUNC_STATUS_ERROR
223
+ BTGraphListenerFuncStatus = enum :bt_graph_listener_func_status,
224
+ [ :BT_GRAPH_LISTENER_FUNC_STATUS_OK,
225
+ BT_GRAPH_LISTENER_FUNC_STATUS_OK,
226
+ :BT_GRAPH_LISTENER_FUNC_STATUS_MEMORY_ERROR,
227
+ BT_GRAPH_LISTENER_FUNC_STATUS_MEMORY_ERROR,
228
+ :BT_GRAPH_LISTENER_FUNC_STATUS_ERROR,
229
+ BT_GRAPH_LISTENER_FUNC_STATUS_ERROR ]
230
+
231
+ callback :bt_graph_filter_component_input_port_added_listener_func,
232
+ [ :bt_component_filter_handle, :bt_port_input_handle,
233
+ :pointer ],
234
+ :bt_graph_listener_func_status
235
+
236
+ def self._wrap_graph_component_port_added_listener_func(
237
+ component_class, port_class, category, handle, method)
238
+ id = handle.to_i
239
+ method_wrapper = lambda { |component, port, user_data|
240
+ begin
241
+ method.call(component_class.new(component, retain: false, auto_release: false),
242
+ port_class.new(port, retain: false, auto_release: false),
243
+ user_data)
244
+ :BT_GRAPH_LISTENER_FUNC_STATUS_OK
245
+ rescue Exception => e
246
+ Babeltrace2.stack_ruby_error(e, source: component)
247
+ :BT_GRAPH_LISTENER_FUNC_STATUS_ERROR
248
+ end
249
+ }
250
+ arr = @@callbacks[id][category]
251
+ if arr.nil?
252
+ arr = []
253
+ @@callbacks[id][category] = arr
254
+ end
255
+ arr.push method_wrapper
256
+ method_wrapper
257
+ end
258
+
259
+ def self._wrap_graph_filter_component_input_port_added_listener_func(handle, method)
260
+ _wrap_graph_component_port_added_listener_func(
261
+ BTComponentFilter, BTPortInput, :filter_component_input_port_added_listener_funcs,
262
+ handle, method)
263
+ end
264
+
265
+ attach_function :bt_graph_add_filter_component_input_port_added_listener,
266
+ [ :bt_graph_handle,
267
+ :bt_graph_filter_component_input_port_added_listener_func,
268
+ :pointer, :pointer ],
269
+ :bt_graph_add_listener_status
270
+
271
+ callback :bt_graph_sink_component_input_port_added_listener_func,
272
+ [ :bt_component_sink_handle, :bt_port_input_handle,
273
+ :pointer ],
274
+ :bt_graph_listener_func_status
275
+
276
+ def self._wrap_graph_sink_component_input_port_added_listener_func(handle, method)
277
+ _wrap_graph_component_port_added_listener_func(
278
+ BTComponentSink, BTPortInput, :sink_component_input_port_added_listener_funcs,
279
+ handle, method)
280
+ end
281
+
282
+ attach_function :bt_graph_add_sink_component_input_port_added_listener,
283
+ [ :bt_graph_handle,
284
+ :bt_graph_sink_component_input_port_added_listener_func,
285
+ :pointer, :pointer ],
286
+ :bt_graph_add_listener_status
287
+
288
+ callback :bt_graph_source_component_output_port_added_listener_func,
289
+ [ :bt_component_source_handle, :bt_port_output_handle,
290
+ :pointer ],
291
+ :bt_graph_listener_func_status
292
+
293
+ def self._wrap_graph_source_component_output_port_added_listener_func(handle, method)
294
+ _wrap_graph_component_port_added_listener_func(
295
+ BTComponentSource, BTPortOutput, :source_component_output_port_added_listener_funcs,
296
+ handle, method)
297
+ end
298
+
299
+ attach_function :bt_graph_add_source_component_output_port_added_listener,
300
+ [ :bt_graph_handle,
301
+ :bt_graph_source_component_output_port_added_listener_func,
302
+ :pointer, :pointer ],
303
+ :bt_graph_add_listener_status
304
+
305
+ callback :bt_graph_filter_component_output_port_added_listener_func,
306
+ [ :bt_component_filter_handle, :bt_port_output_handle,
307
+ :pointer ],
308
+ :bt_graph_listener_func_status
309
+
310
+ def self._wrap_graph_filter_component_output_port_added_listener_func(handle, method)
311
+ _wrap_graph_component_port_added_listener_func(
312
+ BTComponentFilter, BTPortOutput, :filter_component_output_port_added_listener_funcs,
313
+ handle, method)
314
+ end
315
+
316
+ attach_function :bt_graph_add_filter_component_output_port_added_listener,
317
+ [ :bt_graph_handle,
318
+ :bt_graph_filter_component_output_port_added_listener_func,
319
+ :pointer, :pointer ],
320
+ :bt_graph_add_listener_status
321
+
322
+ class BTGraph < BTSharedObject
323
+ AddComponentStatus = BTGraphAddComponentStatus
324
+ SimpleSinkComponentInitializeFuncStatus = BTGraphSimpleSinkComponentInitializeFuncStatus
325
+ SimpleSinkComponentConsumeFuncStatus = BTGraphSimpleSinkComponentConsumeFuncStatus
326
+ ConnectPortsStatus = BTGraphConnectPortsStatus
327
+ RunStatus = BTGraphRunStatus
328
+ RunOnceStatus = BTGraphRunOnceStatus
329
+ AddInterrupterStatus = BTGraphAddInterrupterStatus
330
+ AddListenerStatus = BTGraphAddListenerStatus
331
+ ListenerFuncStatus = BTGraphListenerFuncStatus
332
+ @get_ref = :bt_graph_get_ref
333
+ @put_ref = :bt_graph_put_ref
334
+
335
+ def initialize(handle = nil, retain: true, auto_release: true,
336
+ mip_version: 0)
337
+ if handle
338
+ super(handle, retain: retain, auto_release: auto_release)
339
+ else
340
+ handle = Babeltrace2.bt_graph_create(mip_version)
341
+ raise Babeltrace2.process_error if handle.null?
342
+ super(handle)
343
+ end
344
+ end
345
+
346
+ def add_source_component(component_class, name, params: {},
347
+ logging_level: BTLogging.default_level,
348
+ initialize_method_data: nil)
349
+ ptr = FFI::MemoryPointer.new(:pointer)
350
+ res = if initialize_method_data
351
+ Babeltrace2.bt_graph_add_source_component_with_initialize_method_data(
352
+ @handle, component_class, name, BTValue.from_value(params),
353
+ initialize_method_data, logging_level, ptr)
354
+ else
355
+ Babeltrace2.bt_graph_add_source_component(
356
+ @handle, component_class, name, BTValue.from_value(params),
357
+ logging_level, ptr)
358
+ end
359
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
360
+ BTComponentSource.new(BTComponentSourceHandle.new(ptr.read_pointer), retain: true)
361
+ end
362
+ alias add_source add_source_component
363
+
364
+ def add_filter_component(component_class, name, params: {},
365
+ logging_level: BTLogging.default_level,
366
+ initialize_method_data: nil)
367
+ ptr = FFI::MemoryPointer.new(:pointer)
368
+ res = if initialize_method_data
369
+ Babeltrace2.bt_graph_add_filter_component_with_initialize_method_data(
370
+ @handle, component_class, name, BTValue.from_value(params),
371
+ initialize_method_data, logging_level, ptr)
372
+ else
373
+ Babeltrace2.bt_graph_add_filter_component(
374
+ @handle, component_class, name, BTValue.from_value(params),
375
+ logging_level, ptr)
376
+ end
377
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
378
+ BTComponentFilter.new(BTComponentFilterHandle.new(ptr.read_pointer), retain: true)
379
+ end
380
+ alias add_filter add_filter_component
381
+
382
+ def add_sink_component(component_class, name, params: {},
383
+ logging_level: BTLogging.default_level,
384
+ initialize_method_data: nil)
385
+ ptr = FFI::MemoryPointer.new(:pointer)
386
+ res = if initialize_method_data
387
+ Babeltrace2.bt_graph_add_sink_component_with_initialize_method_data(
388
+ @handle, component_class, name, BTValue.from_value(params),
389
+ initialize_method_data, logging_level, ptr)
390
+ else
391
+ Babeltrace2.bt_graph_add_sink_component(
392
+ @handle, component_class, name, BTValue.from_value(params),
393
+ logging_level, ptr)
394
+ end
395
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
396
+ BTComponentSink.new(BTComponentSinkHandle.new(ptr.read_pointer), retain: true)
397
+ end
398
+ alias add_sink add_sink_component
399
+
400
+ def add_component(component_class, name, params: {},
401
+ logging_level: BTLogging.default_level,
402
+ initialize_method_data: nil)
403
+ case component_class.type
404
+ when :BT_COMPONENT_CLASS_TYPE_SOURCE
405
+ add_source_component(component_class, name, params: params,
406
+ logging_level: logging_level,
407
+ initialize_method_data: initialize_method_data)
408
+ when :BT_COMPONENT_CLASS_TYPE_FILTER
409
+ add_filter_component(component_class, name, params: params,
410
+ logging_level: logging_level,
411
+ initialize_method_data: initialize_method_data)
412
+ when :BT_COMPONENT_CLASS_TYPE_SINK
413
+ add_sink_component(component_class, name, params: params,
414
+ logging_level: logging_level,
415
+ initialize_method_data: initialize_method_data)
416
+ else
417
+ raise "invalid component type"
418
+ end
419
+ end
420
+ alias add add_component
421
+
422
+ def add_simple_sink_component(name, consume_func, initialize_func: nil, finalize_func: nil, user_data: nil)
423
+ initialize_func =
424
+ Babeltrace2._wrap_graph_simple_sink_component_initialize_func(initialize_func) if initialize_func
425
+ consume_func =
426
+ Babeltrace2._wrap_graph_simple_sink_component_consume_func(consume_func)
427
+ ptr = FFI::MemoryPointer.new(:pointer)
428
+ res = Babeltrace2.bt_graph_add_simple_sink_component(@handle, name, initialize_func, consume_func, finalize_func, user_data, ptr)
429
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK
430
+ handle = BTComponentSinkHandle.new(ptr.read_pointer)
431
+ id = handle.to_i
432
+ Babeltrace2._callbacks[id][:initialize_func] = initialize_func
433
+ Babeltrace2._callbacks[id][:consume_func] = consume_func
434
+ Babeltrace2._callbacks[id][:finalize_func] = finalize_func
435
+ BTComponentSink.new(handle, retain: true)
436
+ end
437
+ alias add_simple_sink add_simple_sink_component
438
+
439
+ def connect_ports(upstream_port, downstream_port)
440
+ raise "upstream port already connected" if upstream_port.connected?
441
+ raise "downstream port already connected" if downstream_port.connected?
442
+ ptr = FFI::MemoryPointer.new(:pointer)
443
+ res = Babeltrace2.bt_graph_connect_ports(@handle, upstream_port, downstream_port, ptr)
444
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_CONNECT_PORTS_STATUS_OK
445
+ BTConnection.new(BTConnectionHandle.new(ptr.read_pointer), retain: true)
446
+ end
447
+
448
+ def run
449
+ while ((res = Babeltrace2.bt_graph_run(@handle)) == :BT_GRAPH_RUN_STATUS_AGAIN)
450
+ sleep BT_SLEEP_TIME
451
+ end
452
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_RUN_STATUS_OK
453
+ self
454
+ end
455
+
456
+ def run_once
457
+ while ((res = Babeltrace2.bt_graph_run_once(@handle)) == :BT_GRAPH_RUN_ONCE_STATUS_AGAIN)
458
+ sleep BT_SLEEP_TIME
459
+ end
460
+ case res
461
+ when :BT_GRAPH_RUN_ONCE_STATUS_OK
462
+ self
463
+ when :BT_GRAPH_RUN_ONCE_STATUS_END
464
+ raise StopIteration
465
+ else
466
+ raise Babeltrace2.process_error(res)
467
+ end
468
+ end
469
+
470
+ def add_interrupter(interrupter)
471
+ res = Babeltrace2.bt_graph_add_interrupter(@handle, interrupter)
472
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_INTERRUPTER_STATUS_OK
473
+ self
474
+ end
475
+
476
+ def get_default_interrupter
477
+ handle = Babeltrace2.bt_graph_borrow_default_interrupter(@handle)
478
+ BTInterrupter.new(handle, retain: true)
479
+ end
480
+ alias default_interrupter get_default_interrupter
481
+
482
+ def add_filter_component_input_port_added_listener(user_func, user_data: nil)
483
+ ptr = FFI::MemoryPointer.new(:uint64)
484
+ user_func = Babeltrace2._wrap_graph_filter_component_input_port_added_listener_func(
485
+ @handle, user_func)
486
+ res = Babeltrace2.bt_graph_add_filter_component_input_port_added_listener(
487
+ @handle, user_func, user_data, ptr)
488
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK
489
+ ptr.read_uint64
490
+ end
491
+
492
+ def add_sink_component_input_port_added_listener(user_func, user_data: nil)
493
+ ptr = FFI::MemoryPointer.new(:uint64)
494
+ user_func = Babeltrace2._wrap_graph_sink_component_input_port_added_listener_func(
495
+ @handle, user_func)
496
+ res = Babeltrace2.bt_graph_add_sink_component_input_port_added_listener(
497
+ @handle, user_func, user_data, ptr)
498
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK
499
+ ptr.read_uint64
500
+ end
501
+
502
+ def add_source_component_output_port_added_listener(user_func, user_data: nil)
503
+ ptr = FFI::MemoryPointer.new(:uint64)
504
+ user_func = Babeltrace2._wrap_graph_source_component_output_port_added_listener_func(
505
+ @handle, user_func)
506
+ res = Babeltrace2.bt_graph_add_source_component_output_port_added_listener(
507
+ @handle, user_func, user_data, ptr)
508
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK
509
+ ptr.read_uint64
510
+ end
511
+
512
+ def add_filter_component_output_port_added_listener(user_func, user_data: nil)
513
+ ptr = FFI::MemoryPointer.new(:uint64)
514
+ user_func = Babeltrace2._wrap_graph_filter_component_output_port_added_listener_func(
515
+ @handle, user_func)
516
+ res = Babeltrace2.bt_graph_add_filter_component_output_port_added_listener(
517
+ @handle, user_func, user_data, ptr)
518
+ raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK
519
+ ptr.read_uint64
520
+ end
521
+ end
522
+ end
523
+