|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package VS::RuleEngine::InputHandler;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
32
 | 
 
 | 
 
 | 
  
32
  
 | 
 
 | 
164
 | 
 use strict;  | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
    | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1146
 | 
    | 
| 
4
 | 
32
 | 
 
 | 
 
 | 
  
32
  
 | 
 
 | 
158
 | 
 use warnings;  | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67
 | 
    | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1102
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
6
 | 
32
 | 
 
 | 
 
 | 
  
32
  
 | 
 
 | 
156
 | 
 use Carp qw(croak);  | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
60
 | 
    | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1780
 | 
    | 
| 
7
 | 
32
 | 
 
 | 
 
 | 
  
32
  
 | 
 
 | 
173
 | 
 use Scalar::Util qw(refaddr blessed);  | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
52
 | 
    | 
| 
 
 | 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22796
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my %Global;  | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my %Local;  | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my %InputCache;  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
14
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
  
1
  
 | 
87
 | 
     my ($pkg, %inputs) = @_;  | 
| 
15
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
102
 | 
     my $self = bless \%inputs, $pkg;  | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
17
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
251
 | 
     $InputCache{refaddr $self} = {};  | 
| 
18
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
186
 | 
     $Global{refaddr $self} = undef;  | 
| 
19
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
95
 | 
     $Local{refaddr $self} = undef;  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
21
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
117
 | 
     return $self;  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _clear {  | 
| 
25
 | 
36
 | 
 
 | 
 
 | 
  
36
  
 | 
 
 | 
130
 | 
     my $self = shift;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
27
 | 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
81
 | 
     my $caller = caller;  | 
| 
28
 | 
36
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
234
 | 
     croak "You are not allowed to clear the input" if $caller ne "VS::RuleEngine::Runloop";  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
30
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
163
 | 
     $InputCache{refaddr $self} = {};  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub set_global {  | 
| 
34
 | 
36
 | 
 
 | 
 
 | 
  
36
  
 | 
  
1
  
 | 
114
 | 
     my ($self, $global) = @_;  | 
| 
35
 | 
36
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
428
 | 
     croak "Not a VS::RuleEngine::Data instance" unless blessed $global && $global->isa("VS::RuleEngine::Data");  | 
| 
36
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
152
 | 
     $Global{refaddr $self} = $global;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub set_local {  | 
| 
40
 | 
36
 | 
 
 | 
 
 | 
  
36
  
 | 
  
1
  
 | 
110
 | 
     my ($self, $local) = @_;  | 
| 
41
 | 
36
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
334
 | 
     croak "Not a VS::RuleEngine::Data instance" unless blessed $local && $local->isa("VS::RuleEngine::Data");  | 
| 
42
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
164
 | 
     $Local{refaddr $self} = $local;  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub DESTROY {  | 
| 
46
 | 
35
 | 
 
 | 
 
 | 
  
35
  
 | 
 
 | 
257
 | 
     my $self = shift;  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
48
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
182
 | 
     delete $InputCache{refaddr $self};  | 
| 
49
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
184
 | 
     delete $Global{refaddr $self};  | 
| 
50
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
151
 | 
     delete $Local{refaddr $self};  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub get {  | 
| 
54
 | 
37
 | 
 
 | 
 
 | 
  
37
  
 | 
  
1
  
 | 
54
 | 
     my $self = shift;  | 
| 
55
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
48
 | 
     my $input = shift;  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
57
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
     my $addr = refaddr $self;  | 
| 
58
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
61
 | 
     my $cache = $InputCache{$addr};  | 
| 
59
 | 
37
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
80
 | 
     if (exists $cache->{$input}) {  | 
| 
60
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
         return $cache->{$input};  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
62
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
63
 | 
35
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
83
 | 
     croak "I don't know anything about '${input}'" if !exists $self->{$input};  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
65
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
49
 | 
     my $input_obj = $self->{$input};  | 
| 
66
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
138
 | 
     my $value = $input_obj->value($self, $Global{$addr}, $Local{$addr});  | 
| 
67
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2320
 | 
     $cache->{$input} = $value;  | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       | 
| 
69
 | 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
162
 | 
     return $value;  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |