Class: Babeltrace2::BTField::Variant
Defined Under Namespace
Classes: WithSelectorField, WithoutSelectorField
Constant Summary
TYPE_MAP
Instance Attribute Summary
#handle
Instance Method Summary
collapse
from_handle, #get_class, #get_class_type
#==, #initialize, #to_ptr
Instance Method Details
#get_option_count ⇒ Object
Also known as:
option_count
798
799
800
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 798
def get_option_count
@option_count ||= get_class.get_option_count
end
|
#get_selected_option_class ⇒ Object
Also known as:
selected_option_class
824
825
826
827
828
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 824
def get_selected_option_class
handle = Babeltrace2.bt_field_variant_borrow_selected_option_class_const(@handle)
return nil if handle.null?
BTFieldClassVariantOption.new(handle)
end
|
#get_selected_option_field ⇒ Object
Also known as:
selected_option_field
812
813
814
815
816
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 812
def get_selected_option_field
handle = Babeltrace2.bt_field_variant_borrow_selected_option_field(@handle)
return nil if handle.null?
BTField.from_handle(handle)
end
|
#get_selected_option_index ⇒ Object
Also known as:
selected_option_index
819
820
821
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 819
def get_selected_option_index
Babeltrace2.bt_field_variant_get_selected_option_index(@handle)
end
|
#select_option_by_index(index) ⇒ Object
803
804
805
806
807
808
809
810
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 803
def select_option_by_index(index)
count = get_option_count
index += count if index < 0
raise "invalid index" if index >= count || index < 0
res = Babeltrace2.bt_field_variant_select_option_by_index(@handle, index)
raise Babeltrace2.process_error(res) if res != :BT_FIELD_VARIANT_SELECT_OPTION_STATUS_OK
self
end
|
#to_s ⇒ Object
837
838
839
840
841
842
843
844
845
846
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 837
def to_s
s = "{"
opt = get_selected_option_field
if opt
name = selected_option_class.name
name = name.inspect if name.kind_of?(Symbol)
s << "#{name}: #{opt.to_s}"
end
s << "}"
end
|
#value ⇒ Object
831
832
833
834
835
|
# File 'lib/babeltrace2/trace-ir/field.rb', line 831
def value
f = get_selected_option_field
return nil unless f
{ selected_option_class.name => f.value }
end
|