Module: Babeltrace2::BTFieldClass::Enumeration

Included in:
Signed, Unsigned
Defined in:
lib/babeltrace2/trace-ir/field-class.rb

Defined Under Namespace

Classes: Mapping, Signed, Unsigned

Constant Summary collapse

GetMappingLabelsForValueStatus =
BTFieldClassEnumerationGetMappingLabelsForValueStatus
AddMappingStatus =
BTFieldClassEnumerationAddMappingStatus

Instance Method Summary collapse

Instance Method Details

#from_h(h) ⇒ Object



546
547
548
549
550
551
552
553
554
# File 'lib/babeltrace2/trace-ir/field-class.rb', line 546

def from_h(h)
  super
  if h[:mappings]
    h[:mappings].each { |name, ranges|
      add_mapping(name, ranges)
    }
  end
  self
end

#get_mapping(map) ⇒ Object Also known as: mapping



525
526
527
528
529
530
531
532
533
534
# File 'lib/babeltrace2/trace-ir/field-class.rb', line 525

def get_mapping(map)
  case map
  when Integer
    get_mapping_by_index(map)
  when String, Symbol
    get_mapping_by_label(map)
  else
    raise "unsupported mapping query"
  end
end

#get_mapping_countObject Also known as: mapping_count, size



519
520
521
# File 'lib/babeltrace2/trace-ir/field-class.rb', line 519

def get_mapping_count
  Babeltrace2.bt_field_class_enumeration_get_mapping_count(@handle)
end

#to_hObject



537
538
539
540
541
542
543
544
# File 'lib/babeltrace2/trace-ir/field-class.rb', line 537

def to_h
  res = super
  res[:mappings] = get_mapping_count.times.collect { |i|
    mapping = get_mapping_by_index(i)
    [mapping.label, mapping.ranges.each.collect { |r| [r.lower, r.upper] }]
  }.to_h
  res
end