[system] / trunk / pg / lib / Value / Context / Diagnostics.pm Repository:
ViewVC logotype

View of /trunk/pg/lib/Value/Context/Diagnostics.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5125 - (download) (as text) (annotate)
Wed Jul 4 20:26:24 2007 UTC (12 years, 5 months ago) by dpvc
File size: 1743 byte(s)
Use precompiled patterns for efficiency.

    1 #########################################################################
    2 #
    3 #  Implement the list of Value::Diagnostics types
    4 #
    5 package Value::Context::Diagnostics;
    6 use strict;
    7 our @ISA = ("Value::Context::Data");
    8 
    9 sub new {
   10   my $self = shift; my $parent = shift;
   11   $self->SUPER::new($parent,
   12     formulas => {
   13       show => 0,
   14       showTestPoints => 1,
   15       showParameters => 1,
   16       showAbsoluteErrors => 1,
   17       showRelativeErrors => 1,
   18       showGraphs => 1,
   19       graphRelativeErrors => 1,
   20       graphAbsoluteErrors => 1,
   21       clipRelativeError => 5,
   22       clipAbsoluteError => 5,
   23       plotTestPoints => 1,
   24       combineGraphs => 1,
   25       checkNumericStability => 1,
   26     },
   27     graphs => {
   28       divisions => 75,
   29       limits => undef,
   30       size => 250,
   31       grid => [10,10],
   32       axes => [0,0],
   33     },
   34     @_,
   35   );
   36 }
   37 
   38 sub init {
   39   my $self = shift;
   40   $self->{dataName} = 'diagnostics';
   41   $self->{name} = 'diagnostics';
   42   $self->{Name} = 'Diagnostics';
   43   $self->{namePattern} = qr/[-\w_.]+/;
   44 }
   45 
   46 sub update {} # no pattern or tokens needed
   47 sub addToken {}
   48 sub removeToken {}
   49 
   50 sub merge {
   51   my $self = shift; my $type = shift;
   52   my $merge = {%{$self->{context}{$self->{dataName}}}};
   53   foreach my $object (@_) {
   54     my $data = $object->{$self->{dataName}}; next unless $data;
   55     $data = {$type=>{@{$data}}} if ref($data) eq 'ARRAY';
   56     $data = {$type=>{show=>$data}} unless ref($data) eq 'HASH';
   57     $merge->{$type}{show} = 1 if scalar(keys(%{$data}));
   58     foreach my $x (keys %{$data}) {
   59       if (ref($merge->{$x}) ne 'HASH') {$merge->{$x} = $data->{$x}}
   60         else {$merge->{$x} = {%{$merge->{$x}},%{$data->{$x}}}}
   61     }
   62   }
   63   return $merge;
   64 }
   65 
   66 
   67 #########################################################################
   68 
   69 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9