Class: Babeltrace2::BTGraph
- Inherits:
-
BTSharedObject
- Object
- BTObject
- BTSharedObject
- Babeltrace2::BTGraph
- Defined in:
- lib/babeltrace2/graph/graph.rb
Constant Summary collapse
- AddComponentStatus =
BTGraphAddComponentStatus- SimpleSinkComponentInitializeFuncStatus =
BTGraphSimpleSinkComponentInitializeFuncStatus- SimpleSinkComponentConsumeFuncStatus =
BTGraphSimpleSinkComponentConsumeFuncStatus- ConnectPortsStatus =
BTGraphConnectPortsStatus- RunStatus =
BTGraphRunStatus- RunOnceStatus =
BTGraphRunOnceStatus- AddInterrupterStatus =
BTGraphAddInterrupterStatus- AddListenerStatus =
BTGraphAddListenerStatus- ListenerFuncStatus =
BTGraphListenerFuncStatus
Instance Attribute Summary
Attributes inherited from BTObject
Instance Method Summary collapse
- #add_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object (also: #add)
- #add_filter_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object (also: #add_filter)
- #add_filter_component_input_port_added_listener(user_func, user_data: nil) ⇒ Object
- #add_filter_component_output_port_added_listener(user_func, user_data: nil) ⇒ Object
- #add_interrupter(interrupter) ⇒ Object
- #add_simple_sink_component(name, consume_func, initialize_func: nil, finalize_func: nil, user_data: nil) ⇒ Object (also: #add_simple_sink)
- #add_sink_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object (also: #add_sink)
- #add_sink_component_input_port_added_listener(user_func, user_data: nil) ⇒ Object
- #add_source_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object (also: #add_source)
- #add_source_component_output_port_added_listener(user_func, user_data: nil) ⇒ Object
- #connect_ports(upstream_port, downstream_port) ⇒ Object
- #get_default_interrupter ⇒ Object (also: #default_interrupter)
-
#initialize(handle = nil, retain: true, auto_release: true, mip_version: 0) ⇒ BTGraph
constructor
A new instance of BTGraph.
- #run ⇒ Object
- #run_once ⇒ Object
Methods inherited from BTSharedObject
Methods inherited from BTObject
Constructor Details
#initialize(handle = nil, retain: true, auto_release: true, mip_version: 0) ⇒ BTGraph
Returns a new instance of BTGraph.
335 336 337 338 339 340 341 342 343 344 |
# File 'lib/babeltrace2/graph/graph.rb', line 335 def initialize(handle = nil, retain: true, auto_release: true, mip_version: 0) if handle super(handle, retain: retain, auto_release: auto_release) else handle = Babeltrace2.bt_graph_create(mip_version) raise Babeltrace2.process_error if handle.null? super(handle) end end |
Instance Method Details
#add_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object Also known as: add
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/babeltrace2/graph/graph.rb', line 403 def add_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) case component_class.type when :BT_COMPONENT_CLASS_TYPE_SOURCE add_source_component(component_class, name, params: params, logging_level: logging_level, initialize_method_data: initialize_method_data) when :BT_COMPONENT_CLASS_TYPE_FILTER add_filter_component(component_class, name, params: params, logging_level: logging_level, initialize_method_data: initialize_method_data) when :BT_COMPONENT_CLASS_TYPE_SINK add_sink_component(component_class, name, params: params, logging_level: logging_level, initialize_method_data: initialize_method_data) else raise "invalid component type" end end |
#add_filter_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object Also known as: add_filter
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/babeltrace2/graph/graph.rb', line 365 def add_filter_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ptr = FFI::MemoryPointer.new(:pointer) bt_params = BTValue.from_value(params) res = if initialize_method_data Babeltrace2.bt_graph_add_filter_component_with_initialize_method_data( @handle, component_class, name, bt_params, initialize_method_data, logging_level, ptr) else Babeltrace2.bt_graph_add_filter_component( @handle, component_class, name, bt_params, logging_level, ptr) end raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK BTComponentFilter.new(BTComponentFilterHandle.new(ptr.read_pointer), retain: true) end |
#add_filter_component_input_port_added_listener(user_func, user_data: nil) ⇒ Object
485 486 487 488 489 490 491 492 493 |
# File 'lib/babeltrace2/graph/graph.rb', line 485 def add_filter_component_input_port_added_listener(user_func, user_data: nil) ptr = FFI::MemoryPointer.new(:uint64) user_func = Babeltrace2._wrap_graph_filter_component_input_port_added_listener_func( @handle, user_func) res = Babeltrace2.bt_graph_add_filter_component_input_port_added_listener( @handle, user_func, user_data, ptr) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK ptr.read_uint64 end |
#add_filter_component_output_port_added_listener(user_func, user_data: nil) ⇒ Object
515 516 517 518 519 520 521 522 523 |
# File 'lib/babeltrace2/graph/graph.rb', line 515 def add_filter_component_output_port_added_listener(user_func, user_data: nil) ptr = FFI::MemoryPointer.new(:uint64) user_func = Babeltrace2._wrap_graph_filter_component_output_port_added_listener_func( @handle, user_func) res = Babeltrace2.bt_graph_add_filter_component_output_port_added_listener( @handle, user_func, user_data, ptr) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK ptr.read_uint64 end |
#add_interrupter(interrupter) ⇒ Object
473 474 475 476 477 |
# File 'lib/babeltrace2/graph/graph.rb', line 473 def add_interrupter(interrupter) res = Babeltrace2.bt_graph_add_interrupter(@handle, interrupter) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_INTERRUPTER_STATUS_OK self end |
#add_simple_sink_component(name, consume_func, initialize_func: nil, finalize_func: nil, user_data: nil) ⇒ Object Also known as: add_simple_sink
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/babeltrace2/graph/graph.rb', line 425 def add_simple_sink_component(name, consume_func, initialize_func: nil, finalize_func: nil, user_data: nil) initialize_func = Babeltrace2._wrap_graph_simple_sink_component_initialize_func(initialize_func) if initialize_func consume_func = Babeltrace2._wrap_graph_simple_sink_component_consume_func(consume_func) ptr = FFI::MemoryPointer.new(:pointer) res = Babeltrace2.bt_graph_add_simple_sink_component(@handle, name, initialize_func, consume_func, finalize_func, user_data, ptr) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK handle = BTComponentSinkHandle.new(ptr.read_pointer) id = handle.to_i Babeltrace2._callbacks[id][:initialize_func] = initialize_func Babeltrace2._callbacks[id][:consume_func] = consume_func Babeltrace2._callbacks[id][:finalize_func] = finalize_func BTComponentSink.new(handle, retain: true) end |
#add_sink_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object Also known as: add_sink
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/babeltrace2/graph/graph.rb', line 384 def add_sink_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ptr = FFI::MemoryPointer.new(:pointer) bt_params = BTValue.from_value(params) res = if initialize_method_data Babeltrace2.bt_graph_add_sink_component_with_initialize_method_data( @handle, component_class, name, bt_params, initialize_method_data, logging_level, ptr) else Babeltrace2.bt_graph_add_sink_component( @handle, component_class, name, bt_params, logging_level, ptr) end raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK BTComponentSink.new(BTComponentSinkHandle.new(ptr.read_pointer), retain: true) end |
#add_sink_component_input_port_added_listener(user_func, user_data: nil) ⇒ Object
495 496 497 498 499 500 501 502 503 |
# File 'lib/babeltrace2/graph/graph.rb', line 495 def add_sink_component_input_port_added_listener(user_func, user_data: nil) ptr = FFI::MemoryPointer.new(:uint64) user_func = Babeltrace2._wrap_graph_sink_component_input_port_added_listener_func( @handle, user_func) res = Babeltrace2.bt_graph_add_sink_component_input_port_added_listener( @handle, user_func, user_data, ptr) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK ptr.read_uint64 end |
#add_source_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ⇒ Object Also known as: add_source
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/babeltrace2/graph/graph.rb', line 346 def add_source_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ptr = FFI::MemoryPointer.new(:pointer) bt_params = BTValue.from_value(params) res = if initialize_method_data Babeltrace2.bt_graph_add_source_component_with_initialize_method_data( @handle, component_class, name, bt_params, initialize_method_data, logging_level, ptr) else Babeltrace2.bt_graph_add_source_component( @handle, component_class, name, bt_params, logging_level, ptr) end raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_COMPONENT_STATUS_OK BTComponentSource.new(BTComponentSourceHandle.new(ptr.read_pointer), retain: true) end |
#add_source_component_output_port_added_listener(user_func, user_data: nil) ⇒ Object
505 506 507 508 509 510 511 512 513 |
# File 'lib/babeltrace2/graph/graph.rb', line 505 def add_source_component_output_port_added_listener(user_func, user_data: nil) ptr = FFI::MemoryPointer.new(:uint64) user_func = Babeltrace2._wrap_graph_source_component_output_port_added_listener_func( @handle, user_func) res = Babeltrace2.bt_graph_add_source_component_output_port_added_listener( @handle, user_func, user_data, ptr) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_ADD_LISTENER_STATUS_OK ptr.read_uint64 end |
#connect_ports(upstream_port, downstream_port) ⇒ Object
442 443 444 445 446 447 448 449 |
# File 'lib/babeltrace2/graph/graph.rb', line 442 def connect_ports(upstream_port, downstream_port) raise "upstream port already connected" if upstream_port.connected? raise "downstream port already connected" if downstream_port.connected? ptr = FFI::MemoryPointer.new(:pointer) res = Babeltrace2.bt_graph_connect_ports(@handle, upstream_port, downstream_port, ptr) raise Babeltrace2.process_error(res) if res != :BT_GRAPH_CONNECT_PORTS_STATUS_OK BTConnection.new(BTConnectionHandle.new(ptr.read_pointer), retain: true) end |
#get_default_interrupter ⇒ Object Also known as: default_interrupter
479 480 481 482 |
# File 'lib/babeltrace2/graph/graph.rb', line 479 def get_default_interrupter handle = Babeltrace2.bt_graph_borrow_default_interrupter(@handle) BTInterrupter.new(handle, retain: true) end |
#run ⇒ Object
451 452 453 454 455 456 457 |
# File 'lib/babeltrace2/graph/graph.rb', line 451 def run while ((res = Babeltrace2.bt_graph_run(@handle)) == :BT_GRAPH_RUN_STATUS_AGAIN) sleep BT_SLEEP_TIME end raise Babeltrace2.process_error(res) if res != :BT_GRAPH_RUN_STATUS_OK self end |
#run_once ⇒ Object
459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/babeltrace2/graph/graph.rb', line 459 def run_once while ((res = Babeltrace2.bt_graph_run_once(@handle)) == :BT_GRAPH_RUN_ONCE_STATUS_AGAIN) sleep BT_SLEEP_TIME end case res when :BT_GRAPH_RUN_ONCE_STATUS_OK self when :BT_GRAPH_RUN_ONCE_STATUS_END raise StopIteration else raise Babeltrace2.process_error(res) end end |