| 1 | # | ||||||||||
| 2 | # This file is part of Soar-WM | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is copyright (c) 2012 by Nathan Glenn. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||
| 8 | # | ||||||||||
| 9 | # ABSTRACT: Traverse Soar working memory dumps | ||||||||||
| 10 | package Soar::WM; | ||||||||||
| 11 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 4 | ▶ | use Soar::WM::Slurp qw(read_wm); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 4 | ▶ | use Soar::WM::Element; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 4 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 4 | ▶ | use base 'Exporter'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 4 | our @EXPORT_OK = qw( wm_root_from_file wm_root ); | |||||||||
| 20 | |||||||||||
| 21 | 4 | our $VERSION = '0.04'; # VERSION | |||||||||
| 22 | |||||||||||
| 23 | 4 | ▶ | print 'root is ' . __PACKAGE__->wm_root_from_file( $ARGV[0] )->id unless caller; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 26 | 1 | my ($class, @slurp_args) = @_; | |||||||||
| 27 | 1 | my ( $wme_hash, $root_name ) = read_wm(@slurp_args); | |||||||||
| 28 | 1 | my $wm = bless $wme_hash, $class; | |||||||||
| 29 | 1 | $wm->{'#root_name'} = $root_name; | |||||||||
| 30 | 1 | return $wm; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | ▶ | sub get_wme { | ||||||||
|
Subroutine
get_wme: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 34 | 1 | my ($self, $id) = @_; | |||||||||
| 35 | 1 | return Soar::WM::Element->new($self, uc $id); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | #return a Soar::WM::Element object for the root | ||||||||||
| 39 | 2 | ▶ | sub wm_root_from_file { | ||||||||
|
Subroutine
wm_root_from_file: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | 2 | my ($file) = @_; | |||||||||
| 41 | 2 | ▶ | if ( !$file ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 1 | carp 'missing file name argument'; | |||||||||
| 43 | 1 | return; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 1 | return wm_root( file => $file ); | |||||||||
| 47 | |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | #args should be file=>xx or text=>xx. | ||||||||||
| 51 | 3 | ▶ | sub wm_root { | ||||||||
|
Subroutine
wm_root: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 3 | my @slurp_args = @_; | |||||||||
| 53 | 3 | my ( $wme_hash, $root_name ) = read_wm(@slurp_args); | |||||||||
| 54 | |||||||||||
| 55 | 3 | my $wm = bless $wme_hash, __PACKAGE__; | |||||||||
| 56 | 3 | return Soar::WM::Element->new( $wm, $root_name ); | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | |||||||||||
| 61 | 4 | 1; | |||||||||
| 62 | |||||||||||
| 63 | __END__ | ||||||||||