line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Relations::TradeRoute; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Relations::TradeRoute::VERSION = '0.400115'; |
3
|
13
|
|
|
13
|
|
168
|
use strict; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
358
|
|
4
|
13
|
|
|
13
|
|
119
|
use v5.10; |
|
13
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
58
|
use Moo; |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
73
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has factor1 => ( |
9
|
|
|
|
|
|
|
is => 'ro' |
10
|
|
|
|
|
|
|
); |
11
|
|
|
|
|
|
|
has factor2 => ( |
12
|
|
|
|
|
|
|
is => 'ro' |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'BalanceOfPower::Relations::Role::Relation'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub factor_for_node |
18
|
|
|
|
|
|
|
{ |
19
|
184
|
|
|
184
|
0
|
199
|
my $self = shift; |
20
|
184
|
|
|
|
|
162
|
my $node = shift; |
21
|
184
|
100
|
|
|
|
492
|
if ($self->node1 eq $node) |
|
|
50
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
95
|
|
|
|
|
368
|
return $self->factor1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif ($self->node2 eq $node) |
26
|
|
|
|
|
|
|
{ |
27
|
89
|
|
|
|
|
301
|
return $self->factor2; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
else |
30
|
|
|
|
|
|
|
{ |
31
|
0
|
|
|
|
|
|
return undef; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub print |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
37
|
0
|
|
|
|
|
|
my $from = shift; |
38
|
0
|
0
|
|
|
|
|
if($from eq $self->node1) |
|
|
0
|
|
|
|
|
|
39
|
|
|
|
|
|
|
{ |
40
|
0
|
|
|
|
|
|
return $from . " -[x" . $self->factor1 . "]-> " . $self->node2; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif($from eq $self->node2) |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
|
|
|
return $from . " -[x" . $self->factor2 . "]-> " . $self->node1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
sub dump |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
my $io = shift; |
51
|
0
|
|
0
|
|
|
|
my $indent = shift || ""; |
52
|
0
|
|
|
|
|
|
print {$io} $indent . join(";", $self->node1, $self->node2, $self->factor1, $self->factor2) . "\n"; |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
sub load |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
my $data = shift; |
58
|
0
|
|
|
|
|
|
$data =~ s/^\s+//; |
59
|
0
|
|
|
|
|
|
chomp $data; |
60
|
0
|
|
|
|
|
|
my ($node1, $node2, $factor1, $factor2) = split ";", $data; |
61
|
0
|
|
|
|
|
|
return $self->new(node1 => $node1, node2 => $node2, factor1 => $factor1, factor2 => $factor2); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|