line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Coder::Many::Scheduler::OrderedList; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
41
|
|
4
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
5
|
use base 'Geo::Coder::Many::Scheduler'; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
420
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Geo::Coder::Many::Scheduler::OrderedList - Ordered list scheduler |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This is a scheduler representing a strict preferential order - it will always |
17
|
|
|
|
|
|
|
use the first geocoder in the list, unless it fails, in which case it'll fall |
18
|
|
|
|
|
|
|
back to the second in the list, and then the third, and so on. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 new |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
140
|
|
|
140
|
1
|
121
|
my $class = shift; |
28
|
140
|
|
|
|
|
106
|
my $ra_items = shift; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my @names = |
31
|
210
|
|
|
|
|
371
|
map { $_->{name} } |
32
|
140
|
|
|
|
|
253
|
sort { $b->{weight} <=> $a->{weight}; } @$ra_items; |
|
70
|
|
|
|
|
145
|
|
33
|
|
|
|
|
|
|
|
34
|
140
|
|
|
|
|
231
|
my $self = { items => \@names }; |
35
|
140
|
|
|
|
|
156
|
bless $self, $class; |
36
|
|
|
|
|
|
|
|
37
|
140
|
|
|
|
|
187
|
$self->reset_available(); |
38
|
|
|
|
|
|
|
|
39
|
140
|
|
|
|
|
289
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 reset_available |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Resets the list back to how it was initially set. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub reset_available { |
49
|
840
|
|
|
840
|
1
|
594
|
my $self = shift; |
50
|
840
|
|
|
|
|
520
|
@{$self->{ available_items }} = @{$self->{items}}; |
|
840
|
|
|
|
|
1295
|
|
|
840
|
|
|
|
|
791
|
|
51
|
840
|
|
|
|
|
972
|
return; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 get_next_unique |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns the next item in the list. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_next_unique { |
61
|
2010
|
|
|
2010
|
1
|
1320
|
my $self = shift; |
62
|
2010
|
|
|
|
|
1133
|
return shift @{$self->{ available_items }}; |
|
2010
|
|
|
|
|
2921
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 next_available |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns zero if there are items available, and |
68
|
|
|
|
|
|
|
-1 if there aren't. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub next_available { |
73
|
1710
|
|
|
1710
|
1
|
1281
|
my $self = shift; |
74
|
|
|
|
|
|
|
|
75
|
1710
|
100
|
|
|
|
1081
|
if ( 0 < @{$self->{ available_items }} ) { |
|
1710
|
|
|
|
|
2680
|
|
76
|
1226
|
|
|
|
|
1838
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
484
|
|
|
|
|
666
|
return 1; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |