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



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

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



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

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



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

def get_mapping_count
  Babeltrace2.bt_field_class_enumeration_get_mapping_count(@handle)
end

#to_hObject



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

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