line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# 2001/01/25 shizukesa@pobox.com |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package POE::Filter::RecordBlock; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1342
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
68
|
|
6
|
2
|
|
|
2
|
|
341
|
use POE::Filter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
7
|
use vars qw($VERSION @ISA); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
105
|
|
9
|
|
|
|
|
|
|
$VERSION = '1.366'; # NOTE - Should be #.### (three decimal places) |
10
|
|
|
|
|
|
|
@ISA = qw(POE::Filter); |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
7
|
use Carp qw(croak); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
178
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub BLOCKSIZE () { 0 }; |
15
|
|
|
|
|
|
|
sub GETBUFFER () { 1 }; |
16
|
|
|
|
|
|
|
sub PUTBUFFER () { 2 }; |
17
|
|
|
|
|
|
|
sub CHECKPUT () { 3 }; |
18
|
|
|
|
|
|
|
sub FIRST_UNUSED () { 4 } |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
9
|
use base 'Exporter'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
1026
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw( FIRST_UNUSED ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
8
|
|
|
8
|
1
|
3601
|
my $type = shift; |
28
|
|
|
|
|
|
|
|
29
|
8
|
100
|
|
|
|
118
|
croak "$type must be given an even number of parameters" if @_ & 1; |
30
|
7
|
|
|
|
|
14
|
my %params = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Block size |
33
|
7
|
100
|
100
|
|
|
400
|
croak "BlockSize must be greater than 0" unless ( |
34
|
|
|
|
|
|
|
defined($params{BlockSize}) && ($params{BlockSize} > 0) |
35
|
|
|
|
|
|
|
); |
36
|
4
|
|
|
|
|
4
|
my $block_size = $params{BlockSize}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# check put |
39
|
4
|
|
|
|
|
4
|
my $check_put = $params{CheckPut}; |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
6
|
delete @params{ qw( BlockSize CheckPut ) }; |
42
|
4
|
50
|
|
|
|
8
|
carp("$type ignores unknown parameters: ", join(', ', sort keys %params)) |
43
|
|
|
|
|
|
|
if scalar keys %params; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
24
|
my $self = bless [ |
46
|
|
|
|
|
|
|
$block_size, # BLOCKSIZE |
47
|
|
|
|
|
|
|
[], # GETBUFFER |
48
|
|
|
|
|
|
|
[], # PUTBUFFER |
49
|
|
|
|
|
|
|
$check_put # CHECKPUT |
50
|
|
|
|
|
|
|
], $type; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub clone { |
54
|
2
|
|
|
2
|
1
|
652
|
my $self = shift; |
55
|
2
|
|
|
|
|
9
|
my $clone = bless [ |
56
|
|
|
|
|
|
|
$self->[0], # BLOCKSIZE |
57
|
|
|
|
|
|
|
[], # GETBUFFER |
58
|
|
|
|
|
|
|
[], # PUTBUFFER |
59
|
|
|
|
|
|
|
$self->[3] # CHECKPUT |
60
|
|
|
|
|
|
|
], ref $self; |
61
|
2
|
|
|
|
|
4
|
$clone; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
65
|
|
|
|
|
|
|
# get() is inherited from POE::Filter. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
68
|
|
|
|
|
|
|
# 2001-07-27 RCC: Add get_one_start() and get_one() to correct filter |
69
|
|
|
|
|
|
|
# changing and make input flow control possible. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_one_start { |
72
|
4
|
|
|
4
|
1
|
317
|
my ($self, $data) = @_; |
73
|
4
|
|
|
|
|
4
|
push @{$self->[GETBUFFER]}, @$data; |
|
4
|
|
|
|
|
20
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get_one { |
77
|
12
|
|
|
12
|
1
|
299
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
12
|
100
|
|
|
|
7
|
return [ ] unless @{$self->[GETBUFFER]} >= $self->[BLOCKSIZE]; |
|
12
|
|
|
|
|
58
|
|
80
|
5
|
|
|
|
|
3
|
return [ [ splice @{$self->[GETBUFFER]}, 0, $self->[BLOCKSIZE] ] ]; |
|
5
|
|
|
|
|
17
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub put { |
86
|
8
|
|
|
8
|
1
|
853
|
my ($self, $data) = @_; |
87
|
8
|
|
|
|
|
4
|
my @result; |
88
|
|
|
|
|
|
|
|
89
|
8
|
100
|
|
|
|
17
|
if ($self->[CHECKPUT]) { |
90
|
3
|
|
|
|
|
3
|
foreach (@$data) { |
91
|
8
|
|
|
|
|
6
|
push @{$self->[PUTBUFFER]}, @$_; |
|
8
|
|
|
|
|
14
|
|
92
|
|
|
|
|
|
|
} |
93
|
3
|
|
|
|
|
3
|
while (@{$self->[PUTBUFFER]} >= $self->[BLOCKSIZE]) { |
|
11
|
|
|
|
|
18
|
|
94
|
8
|
|
|
|
|
7
|
push @result, splice @{$self->[PUTBUFFER]}, 0, $self->[BLOCKSIZE]; |
|
8
|
|
|
|
|
15
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else { |
98
|
5
|
|
|
|
|
6
|
push @result, splice(@{$self->[PUTBUFFER]}, 0); |
|
5
|
|
|
|
|
8
|
|
99
|
5
|
|
|
|
|
6
|
foreach (@$data) { |
100
|
12
|
|
|
|
|
20
|
push @result, @$_; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
8
|
|
|
|
|
30
|
\@result; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_pending { |
109
|
4
|
|
|
4
|
1
|
18
|
my $self = shift; |
110
|
4
|
100
|
|
|
|
3
|
return undef unless @{$self->[GETBUFFER]}; |
|
4
|
|
|
|
|
14
|
|
111
|
2
|
|
|
|
|
1
|
return [ @{$self->[GETBUFFER]} ]; |
|
2
|
|
|
|
|
6
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub put_pending { |
117
|
4
|
|
|
4
|
1
|
7
|
my ($self) = @_; |
118
|
4
|
100
|
|
|
|
11
|
return undef unless $self->[CHECKPUT]; |
119
|
3
|
100
|
|
|
|
2
|
return undef unless @{$self->[PUTBUFFER]}; |
|
3
|
|
|
|
|
8
|
|
120
|
2
|
|
|
|
|
2
|
return [ @{$self->[PUTBUFFER]} ]; |
|
2
|
|
|
|
|
6
|
|
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub blocksize { |
126
|
8
|
|
|
8
|
1
|
403
|
my ($self, $size) = @_; |
127
|
8
|
100
|
100
|
|
|
24
|
if (defined($size) && ($size > 0)) { |
128
|
1
|
|
|
|
|
2
|
$self->[BLOCKSIZE] = $size; |
129
|
|
|
|
|
|
|
} |
130
|
8
|
|
|
|
|
14
|
$self->[BLOCKSIZE]; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub checkput { |
136
|
4
|
|
|
4
|
1
|
7
|
my ($self, $val) = @_; |
137
|
4
|
100
|
|
|
|
7
|
if (defined($val)) { |
138
|
1
|
|
|
|
|
1
|
$self->[CHECKPUT] = $val; |
139
|
|
|
|
|
|
|
} |
140
|
4
|
|
|
|
|
9
|
$self->[CHECKPUT]; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |