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
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/babeltrace2/graph/graph.rb', line 400 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
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/babeltrace2/graph/graph.rb', line 364 def add_filter_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ptr = FFI::MemoryPointer.new(:pointer) res = if initialize_method_data Babeltrace2.bt_graph_add_filter_component_with_initialize_method_data( @handle, component_class, name, BTValue.from_value(params), initialize_method_data, logging_level, ptr) else Babeltrace2.bt_graph_add_filter_component( @handle, component_class, name, BTValue.from_value(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
482 483 484 485 486 487 488 489 490 |
# File 'lib/babeltrace2/graph/graph.rb', line 482 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
512 513 514 515 516 517 518 519 520 |
# File 'lib/babeltrace2/graph/graph.rb', line 512 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
470 471 472 473 474 |
# File 'lib/babeltrace2/graph/graph.rb', line 470 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
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/babeltrace2/graph/graph.rb', line 422 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
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/babeltrace2/graph/graph.rb', line 382 def add_sink_component(component_class, name, params: {}, logging_level: BTLogging.default_level, initialize_method_data: nil) ptr = FFI::MemoryPointer.new(:pointer) res = if initialize_method_data Babeltrace2.bt_graph_add_sink_component_with_initialize_method_data( @handle, component_class, name, BTValue.from_value(params), initialize_method_data, logging_level, ptr) else Babeltrace2.bt_graph_add_sink_component( @handle, component_class, name, BTValue.from_value(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
492 493 494 495 496 497 498 499 500 |
# File 'lib/babeltrace2/graph/graph.rb', line 492 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 |
# 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) res = if initialize_method_data Babeltrace2.bt_graph_add_source_component_with_initialize_method_data( @handle, component_class, name, BTValue.from_value(params), initialize_method_data, logging_level, ptr) else Babeltrace2.bt_graph_add_source_component( @handle, component_class, name, BTValue.from_value(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
502 503 504 505 506 507 508 509 510 |
# File 'lib/babeltrace2/graph/graph.rb', line 502 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
439 440 441 442 443 444 445 446 |
# File 'lib/babeltrace2/graph/graph.rb', line 439 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
476 477 478 479 |
# File 'lib/babeltrace2/graph/graph.rb', line 476 def get_default_interrupter handle = Babeltrace2.bt_graph_borrow_default_interrupter(@handle) BTInterrupter.new(handle, retain: true) end |
#run ⇒ Object
448 449 450 451 452 453 454 |
# File 'lib/babeltrace2/graph/graph.rb', line 448 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
456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/babeltrace2/graph/graph.rb', line 456 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 |