Module: Babeltrace2::BTSelfComponent::Class

Included in:
Filter, Sink, Source
Defined in:
lib/babeltrace2/graph/self-component-class.rb

Defined Under Namespace

Classes: Filter, Sink, Source

Class Method Summary collapse

Class Method Details

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



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/babeltrace2/graph/self-component-class.rb', line 4

def self.from_handle(handle, retain: true, auto_release: true)
  case Babeltrace2.bt_component_class_get_type(handle)
  when :BT_COMPONENT_CLASS_TYPE_SOURCE
    handle = BTSelfComponentClassSourceHandle.new(handle)
    BTSelfComponentClassSource
  when :BT_COMPONENT_CLASS_TYPE_FILTER
    handle = BTSelfComponentClassFilterHandle.new(handle)
    BTSelfComponentClassFilter
  when :BT_COMPONENT_CLASS_TYPE_SINK
    handle = BTSelfComponentClassSinkHandle.new(handle)
    BTSelfComponentClassSink
  else
    raise Error.new("Unknown component class type")
  end.new(handle, retain: retain, auto_release: auto_release)
end