Class: Babeltrace2::BTComponent::Source

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

Direct Known Subclasses

Babeltrace2::BTSelfComponent::Source

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



113
114
115
116
# File 'lib/babeltrace2/graph/component.rb', line 113

def get_class
  handle = Babeltrace2.bt_component_source_borrow_class_const(@handle)
  BTComponentClassSource.new(handle, retain: true)
end

#get_output_port(port) ⇒ Object Also known as: output_port



137
138
139
140
141
142
143
144
145
146
# File 'lib/babeltrace2/graph/component.rb', line 137

def get_output_port(port)
  case port
  when String
    get_output_port_by_name(port)
  when Integer
    get_output_port_by_index(port)
  else
    raise TypeError, "wrong type for port query"
  end
end

#get_output_port_by_index(index) ⇒ Object



123
124
125
126
127
128
129
# File 'lib/babeltrace2/graph/component.rb', line 123

def get_output_port_by_index(index)
  count = get_output_port_count
  index += count if index < 0
  return nil if index >= count || index < 0
  handle = Babeltrace2.bt_component_source_borrow_output_port_by_index_const(@handle, index)
  BTPortOutput.new(handle, retain: true)
end

#get_output_port_by_name(name) ⇒ Object



131
132
133
134
135
# File 'lib/babeltrace2/graph/component.rb', line 131

def get_output_port_by_name(name)
  handle = Babeltrace2.bt_component_source_borrow_output_port_by_name_const(@handle, name)
  return nil if handle.null?
  BTPortOutput.new(handle, retain: true)
end

#get_output_port_countObject Also known as: output_port_count



118
119
120
# File 'lib/babeltrace2/graph/component.rb', line 118

def get_output_port_count
  Babeltrace2.bt_component_source_get_output_port_count(@handle)
end

#output_portsObject



149
150
151
152
153
154
155
# File 'lib/babeltrace2/graph/component.rb', line 149

def output_ports
  output_port_count.times.collect { |index|
    handle = Babeltrace2.bt_component_source_borrow_output_port_by_index_const(
               @handle, index)
    BTPortOutput.new(handle, retain: true)
  }
end