babeltrace2 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/babeltrace2.gemspec +13 -0
- data/lib/babeltrace2.rb +49 -0
- data/lib/babeltrace2/error-reporting.rb +432 -0
- data/lib/babeltrace2/func-status.rb +26 -0
- data/lib/babeltrace2/graph/component-class-dev.rb +801 -0
- data/lib/babeltrace2/graph/component-class.rb +134 -0
- data/lib/babeltrace2/graph/component-descriptor-set.rb +78 -0
- data/lib/babeltrace2/graph/component.rb +362 -0
- data/lib/babeltrace2/graph/connection.rb +35 -0
- data/lib/babeltrace2/graph/graph.rb +523 -0
- data/lib/babeltrace2/graph/interrupter.rb +57 -0
- data/lib/babeltrace2/graph/message-iterator-class.rb +374 -0
- data/lib/babeltrace2/graph/message-iterator.rb +253 -0
- data/lib/babeltrace2/graph/message.rb +721 -0
- data/lib/babeltrace2/graph/port.rb +124 -0
- data/lib/babeltrace2/graph/private-query-executor.rb +4 -0
- data/lib/babeltrace2/graph/query-executor.rb +142 -0
- data/lib/babeltrace2/graph/self-component-class.rb +37 -0
- data/lib/babeltrace2/graph/self-component-port.rb +35 -0
- data/lib/babeltrace2/graph/self-component.rb +264 -0
- data/lib/babeltrace2/graph/self-message-iterator.rb +147 -0
- data/lib/babeltrace2/integer-range-set.rb +275 -0
- data/lib/babeltrace2/logging-defs.rb +19 -0
- data/lib/babeltrace2/logging.rb +77 -0
- data/lib/babeltrace2/plugin/plugin-dev.rb +335 -0
- data/lib/babeltrace2/plugin/plugin-loading.rb +459 -0
- data/lib/babeltrace2/trace-ir/clock-class.rb +258 -0
- data/lib/babeltrace2/trace-ir/clock-snapshot.rb +45 -0
- data/lib/babeltrace2/trace-ir/event-class.rb +292 -0
- data/lib/babeltrace2/trace-ir/event.rb +91 -0
- data/lib/babeltrace2/trace-ir/field-class.rb +1416 -0
- data/lib/babeltrace2/trace-ir/field-path.rb +123 -0
- data/lib/babeltrace2/trace-ir/field.rb +871 -0
- data/lib/babeltrace2/trace-ir/packet.rb +57 -0
- data/lib/babeltrace2/trace-ir/stream-class.rb +425 -0
- data/lib/babeltrace2/trace-ir/stream.rb +137 -0
- data/lib/babeltrace2/trace-ir/trace-class.rb +343 -0
- data/lib/babeltrace2/trace-ir/trace.rb +321 -0
- data/lib/babeltrace2/types.rb +667 -0
- data/lib/babeltrace2/util.rb +23 -0
- data/lib/babeltrace2/value.rb +869 -0
- data/lib/babeltrace2/version.rb +126 -0
- metadata +105 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
BT_COMPONENT_CLASS_TYPE_SOURCE = 1 << 0
|
3
|
+
BT_COMPONENT_CLASS_TYPE_FILTER = 1 << 1
|
4
|
+
BT_COMPONENT_CLASS_TYPE_SINK = 1 << 2
|
5
|
+
|
6
|
+
BTComponentClassType = enum :bt_component_class_type,
|
7
|
+
[ :BT_COMPONENT_CLASS_TYPE_SOURCE,
|
8
|
+
BT_COMPONENT_CLASS_TYPE_SOURCE,
|
9
|
+
:BT_COMPONENT_CLASS_TYPE_FILTER,
|
10
|
+
BT_COMPONENT_CLASS_TYPE_FILTER,
|
11
|
+
:BT_COMPONENT_CLASS_TYPE_SINK,
|
12
|
+
BT_COMPONENT_CLASS_TYPE_SINK ]
|
13
|
+
|
14
|
+
attach_function :bt_component_class_get_type,
|
15
|
+
[:bt_component_class_handle],
|
16
|
+
:bt_component_class_type
|
17
|
+
attach_function :bt_component_class_get_name,
|
18
|
+
[:bt_component_class_handle],
|
19
|
+
:string
|
20
|
+
attach_function :bt_component_class_get_description,
|
21
|
+
[:bt_component_class_handle],
|
22
|
+
:string
|
23
|
+
attach_function :bt_component_class_get_help,
|
24
|
+
[:bt_component_class_handle],
|
25
|
+
:string
|
26
|
+
attach_function :bt_component_class_get_ref,
|
27
|
+
[:bt_component_class_handle],
|
28
|
+
:void
|
29
|
+
attach_function :bt_component_class_put_ref,
|
30
|
+
[:bt_component_class_handle],
|
31
|
+
:void
|
32
|
+
|
33
|
+
class BTComponentClass < BTSharedObject
|
34
|
+
Type = BTComponentClassType
|
35
|
+
@get_ref = :bt_component_class_get_ref
|
36
|
+
@put_ref = :bt_component_class_put_ref
|
37
|
+
|
38
|
+
def self.from_handle(handle, retain: true, auto_release: true)
|
39
|
+
case Babeltrace2.bt_component_class_get_type(handle)
|
40
|
+
when :BT_COMPONENT_CLASS_TYPE_SOURCE
|
41
|
+
handle = BTComponentClassSourceHandle.new(handle)
|
42
|
+
BTComponentClassSource
|
43
|
+
when :BT_COMPONENT_CLASS_TYPE_FILTER
|
44
|
+
handle = BTComponentClassFilterHandle.new(handle)
|
45
|
+
BTComponentClassFilter
|
46
|
+
when :BT_COMPONENT_CLASS_TYPE_SINK
|
47
|
+
handle = BTComponentClassSinkHandle.new(handle)
|
48
|
+
BTComponentClassSink
|
49
|
+
else
|
50
|
+
raise Error.new("Unknown component class type")
|
51
|
+
end.new(handle, retain: retain, auto_release: auto_release)
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_type
|
55
|
+
Babeltrace2.bt_component_class_get_type(@handle)
|
56
|
+
end
|
57
|
+
alias type get_type
|
58
|
+
|
59
|
+
def is_source
|
60
|
+
get_type == :BT_COMPONENT_CLASS_TYPE_SOURCE
|
61
|
+
end
|
62
|
+
alias source? is_source
|
63
|
+
|
64
|
+
def is_filter
|
65
|
+
get_type == :BT_COMPONENT_CLASS_TYPE_FILTER
|
66
|
+
end
|
67
|
+
alias filter? is_filter
|
68
|
+
|
69
|
+
def is_sink
|
70
|
+
get_type == :BT_COMPONENT_CLASS_TYPE_SINK
|
71
|
+
end
|
72
|
+
alias sink? is_sink
|
73
|
+
|
74
|
+
def get_name
|
75
|
+
Babeltrace2.bt_component_class_get_name(@handle)
|
76
|
+
end
|
77
|
+
alias name get_name
|
78
|
+
|
79
|
+
def get_description
|
80
|
+
Babeltrace2.bt_component_class_get_description(@handle)
|
81
|
+
end
|
82
|
+
alias description get_description
|
83
|
+
|
84
|
+
def get_help
|
85
|
+
Babeltrace2.bt_component_class_get_help(@handle)
|
86
|
+
end
|
87
|
+
alias help get_help
|
88
|
+
end
|
89
|
+
|
90
|
+
attach_function :bt_component_class_source_get_ref,
|
91
|
+
[:bt_component_class_source_handle],
|
92
|
+
:void
|
93
|
+
attach_function :bt_component_class_source_put_ref,
|
94
|
+
[:bt_component_class_source_handle],
|
95
|
+
:void
|
96
|
+
|
97
|
+
class BTComponentClass
|
98
|
+
class Source < BTComponentClass
|
99
|
+
@get_ref = :bt_component_class_source_get_ref
|
100
|
+
@put_ref = :bt_component_class_source_put_ref
|
101
|
+
end
|
102
|
+
end
|
103
|
+
BTComponentClassSource = BTComponentClass::Source
|
104
|
+
|
105
|
+
attach_function :bt_component_class_filter_get_ref,
|
106
|
+
[:bt_component_class_filter_handle],
|
107
|
+
:void
|
108
|
+
attach_function :bt_component_class_filter_put_ref,
|
109
|
+
[:bt_component_class_filter_handle],
|
110
|
+
:void
|
111
|
+
|
112
|
+
class BTComponentClass
|
113
|
+
class Filter < BTComponentClass
|
114
|
+
@get_ref = :bt_component_class_filter_get_ref
|
115
|
+
@put_ref = :bt_component_class_filter_put_ref
|
116
|
+
end
|
117
|
+
end
|
118
|
+
BTComponentClassFilter = BTComponentClass::Filter
|
119
|
+
|
120
|
+
attach_function :bt_component_class_sink_get_ref,
|
121
|
+
[:bt_component_class_sink_handle],
|
122
|
+
:void
|
123
|
+
attach_function :bt_component_class_sink_put_ref,
|
124
|
+
[:bt_component_class_sink_handle],
|
125
|
+
:void
|
126
|
+
|
127
|
+
class BTComponentClass
|
128
|
+
class Sink < BTComponentClass
|
129
|
+
@get_ref = :bt_component_class_sink_get_ref
|
130
|
+
@put_ref = :bt_component_class_sink_put_ref
|
131
|
+
end
|
132
|
+
end
|
133
|
+
BTComponentClassSink = BTComponentClass::Sink
|
134
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
|
3
|
+
attach_function :bt_component_descriptor_set_create,
|
4
|
+
[],
|
5
|
+
:bt_component_descriptor_set_handle
|
6
|
+
|
7
|
+
BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_OK = BT_FUNC_STATUS_OK
|
8
|
+
BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_MEMORY_ERROR = BT_FUNC_STATUS_MEMORY_ERROR
|
9
|
+
BTComponentDescriptorSetAddDescriptorStatus =
|
10
|
+
enum :bt_component_descriptor_set_add_descriptor_status,
|
11
|
+
[ :BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_OK,
|
12
|
+
BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_OK,
|
13
|
+
:BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_MEMORY_ERROR,
|
14
|
+
BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_MEMORY_ERROR ]
|
15
|
+
|
16
|
+
attach_function :bt_component_descriptor_set_add_descriptor,
|
17
|
+
[ :bt_component_descriptor_set_handle,
|
18
|
+
:bt_component_class_handle,
|
19
|
+
:bt_value_handle ],
|
20
|
+
:bt_component_descriptor_set_add_descriptor_status
|
21
|
+
|
22
|
+
attach_function :bt_component_descriptor_set_add_descriptor_with_initialize_method_data,
|
23
|
+
[ :bt_component_descriptor_set_handle,
|
24
|
+
:bt_component_class_handle,
|
25
|
+
:bt_value_handle,
|
26
|
+
:pointer ],
|
27
|
+
:bt_component_descriptor_set_add_descriptor_status
|
28
|
+
|
29
|
+
attach_function :bt_component_descriptor_set_get_ref,
|
30
|
+
[ :bt_component_descriptor_set_handle ],
|
31
|
+
:void
|
32
|
+
|
33
|
+
attach_function :bt_component_descriptor_set_put_ref,
|
34
|
+
[ :bt_component_descriptor_set_handle ],
|
35
|
+
:void
|
36
|
+
|
37
|
+
class BTComponent
|
38
|
+
DescriptorSetAddDescriptorStatus = BTComponentDescriptorSetAddDescriptorStatus
|
39
|
+
class DescriptorSet < BTSharedObject
|
40
|
+
AddDescriptorStatus = BTComponentDescriptorSetAddDescriptorStatus
|
41
|
+
@get_ref = :bt_component_descriptor_set_get_ref
|
42
|
+
@put_ref = :bt_component_descriptor_set_put_ref
|
43
|
+
|
44
|
+
def initialize(handle = nil, retain: true, auto_release: true)
|
45
|
+
if handle
|
46
|
+
super(handle, retain: retain, auto_release: auto_release)
|
47
|
+
else
|
48
|
+
handle = Babeltrace2.bt_component_descriptor_set_create()
|
49
|
+
raise Babeltrace2.process_error if handle.null?
|
50
|
+
super(handle)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_descriptor(component_class, params: {}, initialize_method_data: nil)
|
55
|
+
params = BTValue.from_value(params)
|
56
|
+
raise "invalid value" unless params.kind_of?(BTValueMap)
|
57
|
+
res = if initialize_method_data
|
58
|
+
Babeltrace2.bt_component_descriptor_set_add_descriptor_with_initialize_method_data(@handle, component_class, params, initialize_method_data)
|
59
|
+
else
|
60
|
+
Babeltrace2.bt_component_descriptor_set_add_descriptor(@handle, component_class, params)
|
61
|
+
end
|
62
|
+
raise Babeltrace2.process_error(res) if res != :BT_COMPONENT_DESCRIPTOR_SET_ADD_DESCRIPTOR_STATUS_OK
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_greatest_operative_mip_version(logging_level = BTLogging.default_level)
|
67
|
+
ptr = FFI::MemoryPointer.new(:uint64)
|
68
|
+
res = Babeltrace2.bt_get_greatest_operative_mip_version(
|
69
|
+
@handle, logging_level, ptr)
|
70
|
+
raise Babeltrace2.process_error(res) if res != :BT_GET_GREATEST_OPERATIVE_MIP_VERSION_STATUS_OK
|
71
|
+
ptr.read_uint64
|
72
|
+
end
|
73
|
+
alias greatest_operative_mip_version get_greatest_operative_mip_version
|
74
|
+
end
|
75
|
+
end
|
76
|
+
BTComponentDescriptorSet = BTComponent::DescriptorSet
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,362 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
|
3
|
+
attach_function :bt_component_get_class_type,
|
4
|
+
[ :bt_component_handle ],
|
5
|
+
:bt_component_class_type
|
6
|
+
|
7
|
+
attach_function :bt_component_borrow_class_const,
|
8
|
+
[ :bt_component_handle ],
|
9
|
+
:bt_component_class_handle
|
10
|
+
|
11
|
+
attach_function :bt_component_get_name,
|
12
|
+
[ :bt_component_handle ],
|
13
|
+
:string
|
14
|
+
|
15
|
+
attach_function :bt_component_get_logging_level,
|
16
|
+
[ :bt_component_handle ],
|
17
|
+
:bt_logging_level
|
18
|
+
|
19
|
+
attach_function :bt_component_get_ref,
|
20
|
+
[ :bt_component_handle ],
|
21
|
+
:void
|
22
|
+
|
23
|
+
attach_function :bt_component_put_ref,
|
24
|
+
[ :bt_component_handle ],
|
25
|
+
:void
|
26
|
+
|
27
|
+
class BTComponent < BTSharedObject
|
28
|
+
ClassType = BTComponentClassType
|
29
|
+
@get_ref = :bt_component_get_ref
|
30
|
+
@put_ref = :bt_component_put_ref
|
31
|
+
|
32
|
+
def self.from_handle(handle, retain: true, auto_release: true)
|
33
|
+
case Babeltrace2.bt_component_get_class_type(handle)
|
34
|
+
when :BT_COMPONENT_CLASS_TYPE_SOURCE
|
35
|
+
handle = BTComponentSourceHandle.new(handle)
|
36
|
+
BTComponentSource
|
37
|
+
when :BT_COMPONENT_CLASS_TYPE_FILTER
|
38
|
+
handle = BTComponentFilterHandle.new(handle)
|
39
|
+
BTComponentFilter
|
40
|
+
when :BT_COMPONENT_CLASS_TYPE_SINK
|
41
|
+
handle = BTComponentSinkHandle.new(handle)
|
42
|
+
BTComponentSink
|
43
|
+
else
|
44
|
+
raise Error.new("unknown component class type")
|
45
|
+
end.new(handle, retain: retain, auto_release: auto_release)
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_class_type
|
49
|
+
Babeltrace2.bt_component_get_class_type(@handle)
|
50
|
+
end
|
51
|
+
alias class_type get_class_type
|
52
|
+
|
53
|
+
def is_source
|
54
|
+
get_class_type == :BT_COMPONENT_CLASS_TYPE_SOURCE
|
55
|
+
end
|
56
|
+
alias source? is_source
|
57
|
+
|
58
|
+
def is_filter
|
59
|
+
get_class_type == :BT_COMPONENT_CLASS_TYPE_FILTER
|
60
|
+
end
|
61
|
+
alias filter? is_filter
|
62
|
+
|
63
|
+
def is_sink
|
64
|
+
get_class_type == :BT_COMPONENT_CLASS_TYPE_SINK
|
65
|
+
end
|
66
|
+
alias sink? is_sink
|
67
|
+
|
68
|
+
def get_class
|
69
|
+
handle = Babeltrace2.bt_component_borrow_class_const(@handle)
|
70
|
+
BTComponentClass.from_handle(handle)
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_name
|
74
|
+
Babeltrace2.bt_component_get_name(@handle)
|
75
|
+
end
|
76
|
+
alias name get_name
|
77
|
+
|
78
|
+
def get_logging_level
|
79
|
+
Babeltrace2.bt_component_get_logging_level(@handle)
|
80
|
+
end
|
81
|
+
alias logging_level get_logging_level
|
82
|
+
end
|
83
|
+
|
84
|
+
attach_function :bt_component_source_borrow_class_const,
|
85
|
+
[ :bt_component_source_handle ],
|
86
|
+
:bt_component_class_source_handle
|
87
|
+
|
88
|
+
attach_function :bt_component_source_get_output_port_count,
|
89
|
+
[ :bt_component_source_handle ],
|
90
|
+
:uint64
|
91
|
+
|
92
|
+
attach_function :bt_component_source_borrow_output_port_by_index_const,
|
93
|
+
[ :bt_component_source_handle,
|
94
|
+
:uint64 ],
|
95
|
+
:bt_port_output_handle
|
96
|
+
|
97
|
+
attach_function :bt_component_source_borrow_output_port_by_name_const,
|
98
|
+
[ :bt_component_source_handle,
|
99
|
+
:string ],
|
100
|
+
:bt_port_output_handle
|
101
|
+
|
102
|
+
attach_function :bt_component_source_get_ref,
|
103
|
+
[ :bt_component_source_handle ],
|
104
|
+
:void
|
105
|
+
|
106
|
+
attach_function :bt_component_source_put_ref,
|
107
|
+
[ :bt_component_source_handle ],
|
108
|
+
:void
|
109
|
+
|
110
|
+
class BTComponent::Source < BTComponent
|
111
|
+
@get_ref = :bt_component_source_get_ref
|
112
|
+
@put_ref = :bt_component_source_put_ref
|
113
|
+
def get_class
|
114
|
+
handle = Babeltrace2.bt_component_source_borrow_class_const(@handle)
|
115
|
+
BTComponentClassSource.new(handle, retain: true)
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_output_port_count
|
119
|
+
Babeltrace2.bt_component_source_get_output_port_count(@handle)
|
120
|
+
end
|
121
|
+
alias output_port_count get_output_port_count
|
122
|
+
|
123
|
+
def get_output_port_by_index(index)
|
124
|
+
count = get_output_port_count
|
125
|
+
index += count if index < 0
|
126
|
+
return nil if index >= count || index < 0
|
127
|
+
handle = Babeltrace2.bt_component_source_borrow_output_port_by_index_const(@handle, index)
|
128
|
+
BTPortOutput.new(handle, retain: true)
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_output_port_by_name(name)
|
132
|
+
handle = Babeltrace2.bt_component_source_borrow_output_port_by_name_const(@handle, name)
|
133
|
+
return nil if handle.null?
|
134
|
+
BTPortOutput.new(handle, retain: true)
|
135
|
+
end
|
136
|
+
|
137
|
+
def get_output_port(port)
|
138
|
+
case port
|
139
|
+
when String
|
140
|
+
get_output_port_by_name(port)
|
141
|
+
when Integer
|
142
|
+
get_output_port_by_index(port)
|
143
|
+
else
|
144
|
+
raise TypeError, "wrong type for port query"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
alias output_port get_output_port
|
148
|
+
|
149
|
+
def output_ports
|
150
|
+
output_port_count.times.collect { |index|
|
151
|
+
handle = Babeltrace2.bt_component_source_borrow_output_port_by_index_const(
|
152
|
+
@handle, index)
|
153
|
+
BTPortOutput.new(handle, retain: true)
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
157
|
+
BTComponentSource = BTComponent::Source
|
158
|
+
|
159
|
+
attach_function :bt_component_filter_borrow_class_const,
|
160
|
+
[ :bt_component_filter_handle ],
|
161
|
+
:bt_component_class_filter_handle
|
162
|
+
|
163
|
+
attach_function :bt_component_filter_get_input_port_count,
|
164
|
+
[ :bt_component_filter_handle ],
|
165
|
+
:uint64
|
166
|
+
|
167
|
+
attach_function :bt_component_filter_borrow_input_port_by_index_const,
|
168
|
+
[ :bt_component_filter_handle,
|
169
|
+
:uint64 ],
|
170
|
+
:bt_port_input_handle
|
171
|
+
|
172
|
+
attach_function :bt_component_filter_borrow_input_port_by_name_const,
|
173
|
+
[ :bt_component_filter_handle,
|
174
|
+
:string ],
|
175
|
+
:bt_port_input_handle
|
176
|
+
|
177
|
+
attach_function :bt_component_filter_get_output_port_count,
|
178
|
+
[ :bt_component_filter_handle ],
|
179
|
+
:uint64
|
180
|
+
|
181
|
+
attach_function :bt_component_filter_borrow_output_port_by_index_const,
|
182
|
+
[ :bt_component_filter_handle,
|
183
|
+
:uint64 ],
|
184
|
+
:bt_port_output_handle
|
185
|
+
|
186
|
+
attach_function :bt_component_filter_borrow_output_port_by_name_const,
|
187
|
+
[ :bt_component_filter_handle,
|
188
|
+
:string ],
|
189
|
+
:bt_port_output_handle
|
190
|
+
|
191
|
+
attach_function :bt_component_filter_get_ref,
|
192
|
+
[ :bt_component_filter_handle ],
|
193
|
+
:void
|
194
|
+
|
195
|
+
attach_function :bt_component_filter_put_ref,
|
196
|
+
[ :bt_component_filter_handle ],
|
197
|
+
:void
|
198
|
+
|
199
|
+
class BTComponent::Filter < BTComponent
|
200
|
+
@get_ref = :bt_component_filter_get_ref
|
201
|
+
@put_ref = :bt_component_filter_put_ref
|
202
|
+
def get_class
|
203
|
+
handle = Babeltrace2.bt_component_filter_borrow_class_const(@handle)
|
204
|
+
BTComponentClassFilter.new(handle, retain: true)
|
205
|
+
end
|
206
|
+
|
207
|
+
def get_output_port_count
|
208
|
+
Babeltrace2.bt_component_filter_get_output_port_count(@handle)
|
209
|
+
end
|
210
|
+
alias output_port_count get_output_port_count
|
211
|
+
|
212
|
+
def get_output_port_by_index(index)
|
213
|
+
count = get_output_port_count
|
214
|
+
index += count if index < 0
|
215
|
+
return nil if index >= count || index < 0
|
216
|
+
handle = Babeltrace2.bt_component_filter_borrow_output_port_by_index_const(@handle, index)
|
217
|
+
BTPortOutput.new(handle, retain: true)
|
218
|
+
end
|
219
|
+
|
220
|
+
def get_output_port_by_name(name)
|
221
|
+
handle = Babeltrace2.bt_component_filter_borrow_output_port_by_name_const(@handle, name)
|
222
|
+
return nil if handle.null?
|
223
|
+
BTPortOutput.new(handle, retain: true)
|
224
|
+
end
|
225
|
+
|
226
|
+
def get_output_port(port)
|
227
|
+
case port
|
228
|
+
when String
|
229
|
+
get_output_port_by_name(port)
|
230
|
+
when Integer
|
231
|
+
get_output_port_by_index(port)
|
232
|
+
else
|
233
|
+
raise TypeError, "wrong type for port query"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def output_ports
|
238
|
+
output_port_count.times.collect { |index|
|
239
|
+
handle = Babeltrace2.bt_component_filter_borrow_output_port_by_index_const(
|
240
|
+
@handle, index)
|
241
|
+
BTPortOutput.new(handle, retain: true)
|
242
|
+
}
|
243
|
+
end
|
244
|
+
alias output_port get_output_port
|
245
|
+
|
246
|
+
def get_input_port_count
|
247
|
+
Babeltrace2.bt_component_filter_get_input_port_count(@handle)
|
248
|
+
end
|
249
|
+
alias input_port_count get_input_port_count
|
250
|
+
|
251
|
+
def get_input_port_by_index(index)
|
252
|
+
count = get_input_port_count
|
253
|
+
index += count if index < 0
|
254
|
+
return nil if index >= count || index < 0
|
255
|
+
handle = Babeltrace2.bt_component_filter_borrow_input_port_by_index_const(@handle, index)
|
256
|
+
BTPortInput.new(handle, retain: true)
|
257
|
+
end
|
258
|
+
|
259
|
+
def get_input_port_by_name(name)
|
260
|
+
handle = Babeltrace2.bt_component_filter_borrow_input_port_by_name_const(@handle, name)
|
261
|
+
return nil if handle.null?
|
262
|
+
BTPortInput.new(handle, retain: true)
|
263
|
+
end
|
264
|
+
|
265
|
+
def get_input_port(port)
|
266
|
+
case port
|
267
|
+
when String
|
268
|
+
get_input_port_by_name(port)
|
269
|
+
when Integer
|
270
|
+
get_input_port_by_index(port)
|
271
|
+
else
|
272
|
+
raise TypeError, "wrong type for port query"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
alias input_port get_input_port
|
276
|
+
|
277
|
+
def input_ports
|
278
|
+
input_port_count.times.collect { |index|
|
279
|
+
handle = Babeltrace2.bt_component_filter_borrow_input_port_by_index_const(
|
280
|
+
@handle, index)
|
281
|
+
BTPortInput.new(handle, retain: true)
|
282
|
+
}
|
283
|
+
end
|
284
|
+
end
|
285
|
+
BTComponentFilter = BTComponent::Filter
|
286
|
+
|
287
|
+
attach_function :bt_component_sink_borrow_class_const,
|
288
|
+
[ :bt_component_sink_handle ],
|
289
|
+
:bt_component_class_sink_handle
|
290
|
+
|
291
|
+
attach_function :bt_component_sink_get_input_port_count,
|
292
|
+
[ :bt_component_sink_handle ],
|
293
|
+
:uint64
|
294
|
+
|
295
|
+
attach_function :bt_component_sink_borrow_input_port_by_index_const,
|
296
|
+
[ :bt_component_sink_handle,
|
297
|
+
:uint64 ],
|
298
|
+
:bt_port_input_handle
|
299
|
+
|
300
|
+
attach_function :bt_component_sink_borrow_input_port_by_name_const,
|
301
|
+
[ :bt_component_sink_handle,
|
302
|
+
:string ],
|
303
|
+
:bt_port_input_handle
|
304
|
+
|
305
|
+
attach_function :bt_component_sink_get_ref,
|
306
|
+
[ :bt_component_sink_handle ],
|
307
|
+
:void
|
308
|
+
|
309
|
+
attach_function :bt_component_sink_put_ref,
|
310
|
+
[ :bt_component_sink_handle ],
|
311
|
+
:void
|
312
|
+
|
313
|
+
class BTComponent::Sink < BTComponent
|
314
|
+
@get_ref = :bt_component_sink_get_ref
|
315
|
+
@put_ref = :bt_component_sink_put_ref
|
316
|
+
def get_class
|
317
|
+
handle = Babeltrace2.bt_component_sink_borrow_class_const(@handle)
|
318
|
+
BTComponentClassSink.new(handle, retain: true)
|
319
|
+
end
|
320
|
+
|
321
|
+
def get_input_port_count
|
322
|
+
Babeltrace2.bt_component_sink_get_input_port_count(@handle)
|
323
|
+
end
|
324
|
+
alias input_port_count get_input_port_count
|
325
|
+
|
326
|
+
def get_input_port_by_index(index)
|
327
|
+
count = get_input_port_count
|
328
|
+
index += count if index < 0
|
329
|
+
return nil if index >= count || index < 0
|
330
|
+
handle = Babeltrace2.bt_component_sink_borrow_input_port_by_index_const(@handle, index)
|
331
|
+
BTPortInput.new(handle, retain: true)
|
332
|
+
end
|
333
|
+
|
334
|
+
def get_input_port_by_name(name)
|
335
|
+
handle = Babeltrace2.bt_component_sink_borrow_input_port_by_name_const(@handle, name)
|
336
|
+
return nil if handle.null?
|
337
|
+
BTPortInput.new(handle, retain: true)
|
338
|
+
end
|
339
|
+
|
340
|
+
def get_input_port(port)
|
341
|
+
case port
|
342
|
+
when String
|
343
|
+
get_input_port_by_name(port)
|
344
|
+
when Integer
|
345
|
+
get_input_port_by_index(port)
|
346
|
+
else
|
347
|
+
raise TypeError, "wrong type for port query"
|
348
|
+
end
|
349
|
+
end
|
350
|
+
alias input_port get_input_port
|
351
|
+
|
352
|
+
def input_ports
|
353
|
+
input_port_count.times.collect { |index|
|
354
|
+
handle = Babeltrace2.bt_component_sink_borrow_input_port_by_index_const(
|
355
|
+
@handle, index)
|
356
|
+
BTPortInput.new(handle, retain: true)
|
357
|
+
}
|
358
|
+
end
|
359
|
+
end
|
360
|
+
BTComponentSink = BTComponent::Sink
|
361
|
+
|
362
|
+
end
|