Class: Babeltrace2::BTPort

Inherits:
BTSharedObject show all
Defined in:
lib/babeltrace2/graph/port.rb

Direct Known Subclasses

Input, Output

Defined Under Namespace

Classes: Input, Output

Constant Summary collapse

Type =
BTPortType

Instance Attribute Summary

Attributes inherited from BTObject

#handle

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BTSharedObject

inherited, #initialize

Methods inherited from BTObject

#==, #initialize, #to_ptr

Constructor Details

This class inherits a constructor from Babeltrace2::BTSharedObject

Class Method Details

.from_handle(handle, retain: true, auto_release: true) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/babeltrace2/graph/port.rb', line 44

def self.from_handle(handle, retain: true, auto_release: true)
  case Babeltrace2.bt_port_get_type(handle)
  when :BT_PORT_TYPE_INPUT
    handle = BTPortInputHandle.new(handle)
    BTPortInput
  when :BT_PORT_TYPE_OUTPUT
    handle = BTPortOuputHandle.new(handle)
    BTPortOutput
  else
    raise Error.new("Unknown port type")
  end.new(handle, retain: retain, auto_release: auto_release)
end

Instance Method Details

#get_componentObject Also known as: component



79
80
81
82
# File 'lib/babeltrace2/graph/port.rb', line 79

def get_component
  handle = Babeltrace2.bt_port_borrow_component_const(@handle)
  BTComponent.from_handle(handle)
end

#get_connectionObject Also known as: connection



72
73
74
75
76
# File 'lib/babeltrace2/graph/port.rb', line 72

def get_connection
  handle = Babeltrace2.bt_port_borrow_connection_const(@handle)
  return nil if handle.null?
  BTConnection.new(handle, retain: true, auto_release: true)
end

#get_nameObject Also known as: name



85
86
87
# File 'lib/babeltrace2/graph/port.rb', line 85

def get_name
  Babeltrace2.bt_port_get_name(@handle)
end

#get_typeObject Also known as: type



57
58
59
# File 'lib/babeltrace2/graph/port.rb', line 57

def get_type
  Babeltrace2.bt_port_get_type(@handle)
end

#is_connectedObject Also known as: connected?



90
91
92
# File 'lib/babeltrace2/graph/port.rb', line 90

def is_connected
  Babeltrace2.bt_port_is_connected(@handle) != BT_FALSE
end

#is_inputObject Also known as: input?



62
63
64
# File 'lib/babeltrace2/graph/port.rb', line 62

def is_input
  get_type == :BT_PORT_TYPE_INPUT
end

#is_outputObject Also known as: output?



67
68
69
# File 'lib/babeltrace2/graph/port.rb', line 67

def is_output
  get_type == :BT_PORT_TYPE_OUTPUT
end