line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ProgressMonitor::Stringify::Fields::AbstractField;
|
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
8521
|
use warnings;
|
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
297
|
|
4
|
10
|
|
|
10
|
|
51
|
use strict;
|
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
515
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Attributes:
|
7
|
|
|
|
|
|
|
# width
|
8
|
|
|
|
|
|
|
# The width the field will use at this point. Note that dynamic fields will
|
9
|
|
|
|
|
|
|
# adjust this value as they get more width
|
10
|
|
|
|
|
|
|
# cfg
|
11
|
|
|
|
|
|
|
# The configuration object
|
12
|
|
|
|
|
|
|
#
|
13
|
|
|
|
|
|
|
use classes
|
14
|
10
|
|
|
|
|
151
|
new => 'ABSTRACT',
|
15
|
|
|
|
|
|
|
class_methods => ['_new'],
|
16
|
|
|
|
|
|
|
methods => {
|
17
|
|
|
|
|
|
|
isDynamic => 'isDynamic',
|
18
|
|
|
|
|
|
|
render => 'ABSTRACT',
|
19
|
|
|
|
|
|
|
},
|
20
|
|
|
|
|
|
|
attrs_ro => ['width',],
|
21
|
|
|
|
|
|
|
attrs_pr => ['cfg'],
|
22
|
10
|
|
|
10
|
|
49
|
;
|
|
10
|
|
|
|
|
18
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub isDynamic
|
25
|
|
|
|
|
|
|
{
|
26
|
|
|
|
|
|
|
# by default, fields are fixed
|
27
|
|
|
|
|
|
|
#
|
28
|
10
|
|
|
10
|
|
61
|
return 0;
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
### PROTECTED
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _set_width
|
34
|
|
|
|
|
|
|
{
|
35
|
11
|
|
|
11
|
|
101
|
my $self = shift;
|
36
|
11
|
|
|
|
|
71
|
my $w = shift;
|
37
|
|
|
|
|
|
|
|
38
|
11
|
|
|
|
|
25
|
$self->{$ATTR_width} = $w;
|
39
|
|
|
|
|
|
|
|
40
|
11
|
|
|
|
|
31
|
return;
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# protected ctor
|
44
|
|
|
|
|
|
|
#
|
45
|
|
|
|
|
|
|
sub _new
|
46
|
|
|
|
|
|
|
{
|
47
|
11
|
|
|
11
|
|
69
|
my $self = classes::new_only(shift);
|
48
|
11
|
|
|
|
|
73
|
my $cfg = shift;
|
49
|
11
|
|
|
|
|
25
|
my $cfgPkg = shift;
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# make sure we have a cfg object
|
52
|
|
|
|
|
|
|
#
|
53
|
11
|
|
|
|
|
74
|
$self->{$ATTR_cfg} = ProgressMonitor::AbstractConfiguration::ensureCfgObject($cfg, $cfgPkg);
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# initialize the rest
|
56
|
|
|
|
|
|
|
#
|
57
|
11
|
|
|
|
|
46
|
$self->{$ATTR_width} = 0;
|
58
|
|
|
|
|
|
|
|
59
|
11
|
|
|
|
|
37
|
return $self;
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _get_cfg
|
63
|
|
|
|
|
|
|
{
|
64
|
413
|
|
|
413
|
|
499
|
my $self = shift;
|
65
|
|
|
|
|
|
|
|
66
|
413
|
|
|
|
|
1436
|
return $self->{$ATTR_cfg};
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
###
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
package ProgressMonitor::Stringify::Fields::AbstractFieldConfiguration;
|
72
|
|
|
|
|
|
|
|
73
|
10
|
|
|
10
|
|
6921
|
use strict;
|
|
10
|
|
|
|
|
30
|
|
|
10
|
|
|
|
|
319
|
|
74
|
10
|
|
|
10
|
|
53
|
use warnings;
|
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
467
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
require ProgressMonitor::AbstractConfiguration if 0;
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# declare the configuration class for the above class, this is just a starting
|
79
|
|
|
|
|
|
|
# point to derive from as needed
|
80
|
|
|
|
|
|
|
#
|
81
|
|
|
|
|
|
|
use classes
|
82
|
10
|
|
|
|
|
58
|
extends => 'ProgressMonitor::AbstractConfiguration',
|
83
|
10
|
|
|
10
|
|
52
|
;
|
|
10
|
|
|
|
|
31
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub defaultAttributeValues
|
86
|
|
|
|
|
|
|
{
|
87
|
11
|
|
|
11
|
|
24
|
my $self = shift;
|
88
|
|
|
|
|
|
|
|
89
|
11
|
|
|
|
|
30
|
return {%{$self->SUPER::defaultAttributeValues()},};
|
|
11
|
|
|
|
|
92
|
|
90
|
|
|
|
|
|
|
}
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub checkAttributeValues
|
93
|
|
|
|
|
|
|
{
|
94
|
11
|
|
|
11
|
|
27
|
my $self = shift;
|
95
|
|
|
|
|
|
|
|
96
|
11
|
|
|
|
|
95
|
$self->SUPER::checkAttributeValues;
|
97
|
|
|
|
|
|
|
|
98
|
11
|
|
|
|
|
27
|
return;
|
99
|
|
|
|
|
|
|
}
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
############################
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
ProgressMonitor::Stringify::Fields::AbstractField - A reusable/abstract field
|
106
|
|
|
|
|
|
|
implementation for stringify progress.
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
...
|
111
|
|
|
|
|
|
|
use classes
|
112
|
|
|
|
|
|
|
extends => 'ProgressMonitor::Stringify::Fields::AbstractField',
|
113
|
|
|
|
|
|
|
new => 'new',
|
114
|
|
|
|
|
|
|
...
|
115
|
|
|
|
|
|
|
;
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub new
|
118
|
|
|
|
|
|
|
{
|
119
|
|
|
|
|
|
|
my $class = shift;
|
120
|
|
|
|
|
|
|
my $cfg = shift;
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $self = $class->SUPER::_new($cfg, $CLASS);
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
...
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub render
|
128
|
|
|
|
|
|
|
{
|
129
|
|
|
|
|
|
|
my $self = shift;
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
...
|
132
|
|
|
|
|
|
|
}
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This class is a base class for fields for stringified feedback.
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
When extended it provides some accessors for 'protected' data, i.e. only for
|
139
|
|
|
|
|
|
|
the use of subclasses. These accessors are prefixed with '_'.
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Subclassing this normally entails only defining the render method.
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 METHODS
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=over 2
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item render( $ticks, $totalTicks )
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Called with the current tick count, and the total tick count. Should return
|
150
|
|
|
|
|
|
|
with an appropriate string corresponding to the tick vs totalTick values.
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This implementation is abstract, must be reimplemented.
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item isDynamic
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Should return true if the field is dynamic. Automatically handled by inheriting
|
157
|
|
|
|
|
|
|
from the AbstractDynamicField.
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=back
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 PROTECTED METHODS
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 2
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item _new( $hashRef, $package )
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
The constructor, needs to be called by subclasses.
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Configuration data:
|
170
|
|
|
|
|
|
|
(none)
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item _get_cfg
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Returns the configuration object.
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item _set_width
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Set the width of the field.
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=back
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 AUTHOR
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Kenneth Olwing, C<< >>
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 BUGS
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
I wouldn't be surprised! If you can come up with a minimal test that shows the
|
189
|
|
|
|
|
|
|
problem I might be able to take a look. Even better, send me a patch.
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Please report any bugs or feature requests to
|
192
|
|
|
|
|
|
|
C, or through the web interface at
|
193
|
|
|
|
|
|
|
L.
|
194
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on
|
195
|
|
|
|
|
|
|
your bug as I make changes.
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 SUPPORT
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
You can find general documentation for this module with the perldoc command:
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
perldoc ProgressMonitor
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Thanks to my family. I'm deeply grateful for you!
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Copyright 2006,2007 Kenneth Olwing, all rights reserved.
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
212
|
|
|
|
|
|
|
under the same terms as Perl itself.
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; # End of ProgressMonitor::Stringify::Fields::AbstractField
|