Class: Babeltrace2::BTComponent::Filter

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

Direct Known Subclasses

Babeltrace2::BTSelfComponent::Filter

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



202
203
204
205
# File 'lib/babeltrace2/graph/component.rb', line 202

def get_class
  handle = Babeltrace2.bt_component_filter_borrow_class_const(@handle)
  BTComponentClassFilter.new(handle, retain: true)
end

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



265
266
267
268
269
270
271
272
273
274
# File 'lib/babeltrace2/graph/component.rb', line 265

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



251
252
253
254
255
256
257
# File 'lib/babeltrace2/graph/component.rb', line 251

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_filter_borrow_input_port_by_index_const(@handle, index)
  BTPortInput.new(handle, retain: true)
end

#get_input_port_by_name(name) ⇒ Object



259
260
261
262
263
# File 'lib/babeltrace2/graph/component.rb', line 259

def get_input_port_by_name(name)
  handle = Babeltrace2.bt_component_filter_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



246
247
248
# File 'lib/babeltrace2/graph/component.rb', line 246

def get_input_port_count
  Babeltrace2.bt_component_filter_get_input_port_count(@handle)
end

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



226
227
228
229
230
231
232
233
234
235
# File 'lib/babeltrace2/graph/component.rb', line 226

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



212
213
214
215
216
217
218
# File 'lib/babeltrace2/graph/component.rb', line 212

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_filter_borrow_output_port_by_index_const(@handle, index)
  BTPortOutput.new(handle, retain: true)
end

#get_output_port_by_name(name) ⇒ Object



220
221
222
223
224
# File 'lib/babeltrace2/graph/component.rb', line 220

def get_output_port_by_name(name)
  handle = Babeltrace2.bt_component_filter_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



207
208
209
# File 'lib/babeltrace2/graph/component.rb', line 207

def get_output_port_count
  Babeltrace2.bt_component_filter_get_output_port_count(@handle)
end

#input_portsObject



277
278
279
280
281
282
283
# File 'lib/babeltrace2/graph/component.rb', line 277

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

#output_portsObject



237
238
239
240
241
242
243
# File 'lib/babeltrace2/graph/component.rb', line 237

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