Class: Babeltrace2::BTComponent::Sink

Inherits:
Babeltrace2::BTComponent show all
Defined in:
lib/babeltrace2/graph/component.rb

Direct Known Subclasses

Babeltrace2::BTSelfComponent::Sink

Constant Summary

Constants inherited from Babeltrace2::BTComponent

ClassType, DescriptorSetAddDescriptorStatus

Instance Attribute Summary

Attributes inherited from Babeltrace2::BTObject

#handle

Instance Method Summary collapse

Methods inherited from Babeltrace2::BTComponent

from_handle, #get_class_type, #get_logging_level, #get_name, #is_filter, #is_sink, #is_source

Methods inherited from Babeltrace2::BTSharedObject

inherited, #initialize

Methods inherited from Babeltrace2::BTObject

#==, #initialize, #to_ptr

Constructor Details

This class inherits a constructor from Babeltrace2::BTSharedObject

Instance Method Details

#get_classObject



316
317
318
319
# File 'lib/babeltrace2/graph/component.rb', line 316

def get_class
  handle = Babeltrace2.bt_component_sink_borrow_class_const(@handle)
  BTComponentClassSink.new(handle, retain: true)
end

#get_input_port(port) ⇒ Object Also known as: input_port



340
341
342
343
344
345
346
347
348
349
# File 'lib/babeltrace2/graph/component.rb', line 340

def get_input_port(port)
  case port
  when String
    get_input_port_by_name(port)
  when Integer
    get_input_port_by_index(port)
  else
    raise TypeError, "wrong type for port query"
  end
end

#get_input_port_by_index(index) ⇒ Object



326
327
328
329
330
331
332
# File 'lib/babeltrace2/graph/component.rb', line 326

def get_input_port_by_index(index)
  count = get_input_port_count
  index += count if index < 0
  return nil if index >= count || index < 0
  handle = Babeltrace2.bt_component_sink_borrow_input_port_by_index_const(@handle, index)
  BTPortInput.new(handle, retain: true)
end

#get_input_port_by_name(name) ⇒ Object



334
335
336
337
338
# File 'lib/babeltrace2/graph/component.rb', line 334

def get_input_port_by_name(name)
  handle = Babeltrace2.bt_component_sink_borrow_input_port_by_name_const(@handle, name)
  return nil if handle.null?
  BTPortInput.new(handle, retain: true)
end

#get_input_port_countObject Also known as: input_port_count



321
322
323
# File 'lib/babeltrace2/graph/component.rb', line 321

def get_input_port_count
  Babeltrace2.bt_component_sink_get_input_port_count(@handle)
end

#input_portsObject



352
353
354
355
356
357
358
# File 'lib/babeltrace2/graph/component.rb', line 352

def input_ports
  input_port_count.times.collect { |index|
    handle = Babeltrace2.bt_component_sink_borrow_input_port_by_index_const(
               @handle, index)
    BTPortInput.new(handle, retain: true)
  }
end