Module: CacheXML

Defined in:
lib/thinp_xml/cache/emit.rb,
lib/thinp_xml/cache/parse.rb,
lib/thinp_xml/cache/builder.rb,
lib/thinp_xml/cache/metadata.rb

Overview


Defined Under Namespace

Modules: CacheEmitterDetail, CacheParseDetail Classes: Builder, Hint, Mapping, Metadata, Superblock

Constant Summary collapse

SUPERBLOCK_FIELDS =
[[:uuid, :string],
[:block_size, :int],
[:nr_cache_blocks, :int],
[:policy, :string],
[:hint_width, :int]]
MAPPING_FIELDS =
[[:cache_block, :int],
[:origin_block, :int],
[:dirty, :bool]]
HINT_FIELDS =
[[:cache_block, :int],
[:encoded_data, :string]]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.field_names(flds) ⇒ Object



15
16
17
# File 'lib/thinp_xml/cache/metadata.rb', line 15

def self.field_names(flds)
  flds.map {|p| p[0]}
end

Instance Method Details

#read_xml(io) ⇒ Object



63
64
65
66
67
# File 'lib/thinp_xml/cache/parse.rb', line 63

def read_xml(io)
  l = CacheParseDetail::Listener.new
  REXML::Document.parse_stream(io, l)
  l.
end

#write_xml(metadata, io) ⇒ Object




54
55
56
57
58
59
60
# File 'lib/thinp_xml/cache/emit.rb', line 54

def write_xml(, io)
  e = CacheEmitterDetail::CacheEmitter.new(io)
  e.emit_superblock(.superblock) do
    e.emit_mappings(.mappings)
    e.emit_hints(.hints)
  end
end