line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Framework::Base::Object ; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Object - Basic object |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use App::Framework::Base::Object ; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 AUTHOR |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Steve Price C<< >> |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 BUGS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
None that I know of! |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 INTERFACE |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
42
|
|
|
42
|
|
16213
|
use strict ; |
|
42
|
|
|
|
|
62
|
|
|
30
|
|
|
|
|
633
|
|
34
|
30
|
|
|
30
|
|
89
|
use Carp ; |
|
30
|
|
|
|
|
27
|
|
|
30
|
|
|
|
|
1216
|
|
35
|
30
|
|
|
30
|
|
109
|
use Cwd ; |
|
30
|
|
|
|
|
36
|
|
|
30
|
|
|
|
|
2082
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = "2.002" ; |
38
|
|
|
|
|
|
|
our $AUTOLOAD ; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#============================================================================================ |
41
|
|
|
|
|
|
|
# USES |
42
|
|
|
|
|
|
|
#============================================================================================ |
43
|
|
|
|
|
|
|
|
44
|
30
|
|
|
30
|
|
11687
|
use App::Framework::Base::Object::DumpObj ; |
|
30
|
|
|
|
|
43
|
|
|
30
|
|
|
|
|
54796
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#============================================================================================ |
47
|
|
|
|
|
|
|
# GLOBALS |
48
|
|
|
|
|
|
|
#============================================================================================ |
49
|
|
|
|
|
|
|
my $global_debug = 0 ; |
50
|
|
|
|
|
|
|
my $global_verbose = 0 ; |
51
|
|
|
|
|
|
|
my $strict_fields = 0 ; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my @SPECIAL_FIELDS = qw/ |
54
|
|
|
|
|
|
|
global_debug |
55
|
|
|
|
|
|
|
global_verbose |
56
|
|
|
|
|
|
|
strict_fields |
57
|
|
|
|
|
|
|
/ ; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my %COMMON_FIELDS = ( |
60
|
|
|
|
|
|
|
'debug' => undef, # pseudo field |
61
|
|
|
|
|
|
|
'verbose' => undef, # pseudo field |
62
|
|
|
|
|
|
|
) ; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Constant |
65
|
|
|
|
|
|
|
#my @REQ_LIST ; |
66
|
|
|
|
|
|
|
my %FIELD_LIST ; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my %CLASS_INIT; |
69
|
|
|
|
|
|
|
my %CLASS_INSTANCE ; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my %DEBUG ; |
72
|
|
|
|
|
|
|
my %VERBOSE ; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#============================================================================================ |
75
|
|
|
|
|
|
|
# CONSTRUCTOR |
76
|
|
|
|
|
|
|
#============================================================================================ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Create a new object. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The %args are specified as they would be in the B method, for example: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
'mmap_handler' => $mmap_handler |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Special arguments are: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
'fields' => Either ARRAY list of valid field names, or HASH of field names with default values |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Example: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
new( |
93
|
|
|
|
|
|
|
'fields' => { |
94
|
|
|
|
|
|
|
'cmd' => undef, |
95
|
|
|
|
|
|
|
'status' => 0, |
96
|
|
|
|
|
|
|
'results' => [], |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
) |
99
|
|
|
|
|
|
|
) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
All defined fields have an accessor method created. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub new |
106
|
|
|
|
|
|
|
{ |
107
|
162
|
|
|
162
|
1
|
693
|
my ($obj, %args) = @_ ; |
108
|
|
|
|
|
|
|
|
109
|
162
|
|
33
|
|
|
702
|
my $class = ref($obj) || $obj ; |
110
|
|
|
|
|
|
|
#my $class = $obj->class() ; |
111
|
|
|
|
|
|
|
|
112
|
162
|
100
|
|
|
|
316
|
print "== Object: Creating new $class object ========\n" if $global_debug ; |
113
|
162
|
50
|
|
|
|
341
|
prt_data("ARGS=", \%args, "\n") if $global_debug>=2 ; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# Initialise class variables |
116
|
162
|
|
|
|
|
765
|
$class->init_class(%args); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Create object |
119
|
162
|
|
|
|
|
390
|
my $this = {} ; |
120
|
162
|
|
|
|
|
283
|
bless ($this, $class) ; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Initialise object |
123
|
162
|
|
|
|
|
986
|
$this->init(%args) ; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# # Check for required settings |
126
|
|
|
|
|
|
|
# foreach (@REQ_LIST) |
127
|
|
|
|
|
|
|
# { |
128
|
|
|
|
|
|
|
# do |
129
|
|
|
|
|
|
|
# { |
130
|
|
|
|
|
|
|
# croak "ERROR: $class : Must specify setting for $_" ; |
131
|
|
|
|
|
|
|
# } unless defined($this->{$_}) ; |
132
|
|
|
|
|
|
|
# } |
133
|
|
|
|
|
|
|
|
134
|
162
|
50
|
|
|
|
358
|
prt_data("== Created object=", $this, "================================================\n") if $global_debug ; |
135
|
|
|
|
|
|
|
|
136
|
162
|
|
|
|
|
458
|
return($this) ; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item B |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Initialises the newly created object instance. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub init |
149
|
|
|
|
|
|
|
{ |
150
|
162
|
|
|
162
|
1
|
204
|
my $this = shift ; |
151
|
162
|
|
|
|
|
515
|
my (%args) = @_ ; |
152
|
|
|
|
|
|
|
|
153
|
162
|
50
|
|
|
|
369
|
prt_data("init() ARGS=", \%args, "\n") if $global_debug>=3 ; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
#my $class = $this->class() ; |
156
|
|
|
|
|
|
|
##my $class = ref($this) || $this ; |
157
|
162
|
|
|
|
|
913
|
$this = $this->check_instance() ; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# Defaults |
160
|
|
|
|
|
|
|
## my %field_list = $this->field_list() ; |
161
|
162
|
|
33
|
|
|
400
|
my $class = ref($this) || $this ; |
162
|
162
|
|
|
|
|
312
|
my %field_list = (); |
163
|
162
|
50
|
|
|
|
602
|
%field_list = %{ $FIELD_LIST{$class} } if exists($FIELD_LIST{$class}) ; |
|
162
|
|
|
|
|
1186
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# May have default value for some or all fields |
167
|
162
|
|
|
|
|
281
|
my %field_copy ; |
168
|
162
|
|
|
|
|
633
|
foreach my $fld (keys %field_list) |
169
|
|
|
|
|
|
|
{ |
170
|
3319
|
|
|
|
|
2389
|
my $val = $field_list{$fld} ; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# If value is an ARRAY ref or a HASH ref then we want a new copy of this per instance (otherwise |
173
|
|
|
|
|
|
|
# all instances will have a ref to the same HASH/ARRAY and one instance will change all instance's values!) |
174
|
3319
|
100
|
|
|
|
5081
|
if (ref($val) eq 'ARRAY') |
|
|
100
|
|
|
|
|
|
175
|
|
|
|
|
|
|
{ |
176
|
987
|
|
|
|
|
1006
|
$val = [@$val] ; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
elsif (ref($val) eq 'HASH') |
179
|
|
|
|
|
|
|
{ |
180
|
441
|
|
|
|
|
665
|
$val = { (%$val) } ; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
3319
|
|
|
|
|
3621
|
$field_copy{$fld} = $val ; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
162
|
|
|
|
|
1432
|
$this->set(%field_copy) ; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
## Handle special fields |
189
|
162
|
|
|
|
|
585
|
foreach my $special (@SPECIAL_FIELDS) |
190
|
|
|
|
|
|
|
{ |
191
|
486
|
50
|
|
|
|
915
|
if (exists($args{$special})) |
192
|
|
|
|
|
|
|
{ |
193
|
|
|
|
|
|
|
# remove from args list |
194
|
0
|
|
|
|
|
0
|
my $special_val = delete $args{$special} ; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# call variable handler |
197
|
0
|
|
|
|
|
0
|
$this->$special($special_val) ; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
## Set fields from parameters |
202
|
162
|
|
|
|
|
528
|
$this->set(%args) ; |
203
|
|
|
|
|
|
|
|
204
|
162
|
50
|
|
|
|
905
|
print "init() - done\n" if $global_debug>=3 ; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item B |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Initialises the object class variables. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=cut |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub init_class |
218
|
|
|
|
|
|
|
{ |
219
|
162
|
|
|
162
|
1
|
281
|
my $this = shift ; |
220
|
162
|
|
|
|
|
453
|
my (%args) = @_ ; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
#my $class = $this->class() ; |
223
|
162
|
|
33
|
|
|
764
|
my $class = ref($this) || $this ; |
224
|
|
|
|
|
|
|
|
225
|
162
|
50
|
|
|
|
497
|
prt_data("init_class() ARGS=", \%args, "\n") if $global_debug>=3 ; |
226
|
|
|
|
|
|
|
#prt_data("init_class() ARGS (LIST)=", \@_, "\n") ; |
227
|
|
|
|
|
|
|
|
228
|
162
|
100
|
|
|
|
419
|
if (!$CLASS_INIT{$class}) |
229
|
|
|
|
|
|
|
{ |
230
|
|
|
|
|
|
|
# Field list |
231
|
148
|
|
|
|
|
374
|
$FIELD_LIST{$class} = {}; |
232
|
148
|
|
|
|
|
282
|
my $fields = delete($args{'fields'}) ; |
233
|
|
|
|
|
|
|
|
234
|
148
|
50
|
|
|
|
384
|
prt_data(" + fields=$fields", $fields, "ARGS=", \%args, "\n") if $global_debug>=4 ; |
235
|
|
|
|
|
|
|
#prt_data(" init_class($class) FIELDS=", $fields, "\n") ; |
236
|
|
|
|
|
|
|
|
237
|
148
|
50
|
|
|
|
306
|
if ($fields) |
238
|
|
|
|
|
|
|
{ |
239
|
148
|
50
|
|
|
|
311
|
print " + fields=$fields ref()=", ref($fields), "\n" if $global_debug>=4 ; |
240
|
|
|
|
|
|
|
|
241
|
148
|
|
|
|
|
195
|
my $class_fields_href = {} ; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
## Do the fields |
244
|
148
|
50
|
|
|
|
1179
|
if (ref($fields) eq 'ARRAY') |
|
|
50
|
|
|
|
|
|
245
|
|
|
|
|
|
|
{ |
246
|
|
|
|
|
|
|
$class_fields_href = { |
247
|
|
|
|
|
|
|
(%COMMON_FIELDS), |
248
|
0
|
|
|
|
|
0
|
map {$_ => undef} @$fields |
|
0
|
|
|
|
|
0
|
|
249
|
|
|
|
|
|
|
} ; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
elsif (ref($fields) eq 'HASH') |
252
|
|
|
|
|
|
|
{ |
253
|
148
|
|
|
|
|
1764
|
$class_fields_href = { |
254
|
|
|
|
|
|
|
(%COMMON_FIELDS), |
255
|
|
|
|
|
|
|
(%$fields) |
256
|
|
|
|
|
|
|
} ; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
else |
259
|
|
|
|
|
|
|
{ |
260
|
0
|
|
|
|
|
0
|
$class_fields_href = { |
261
|
|
|
|
|
|
|
(%COMMON_FIELDS), |
262
|
|
|
|
|
|
|
($fields => undef) |
263
|
|
|
|
|
|
|
} ; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
148
|
|
|
|
|
404
|
$FIELD_LIST{$class} = $class_fields_href ; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# create accessors |
270
|
148
|
|
|
|
|
535
|
my $code = "package $class;\n" ; |
271
|
148
|
|
|
|
|
175
|
foreach my $field (keys %{$FIELD_LIST{$class}}) |
|
148
|
|
|
|
|
742
|
|
272
|
|
|
|
|
|
|
{ |
273
|
3075
|
100
|
|
|
|
13655
|
if (!$class->can($field)) |
274
|
|
|
|
|
|
|
{ |
275
|
2760
|
|
|
|
|
4615
|
$code .= qq{ |
276
|
|
|
|
|
|
|
## get / set |
277
|
|
|
|
|
|
|
sub $field |
278
|
|
|
|
|
|
|
{ |
279
|
|
|
|
|
|
|
my \$this = shift ; |
280
|
|
|
|
|
|
|
\@_ ? \$this->{$field} = \$_[0] # set |
281
|
|
|
|
|
|
|
: \$this->{$field}; # get |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
}; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
3075
|
100
|
|
|
|
16850
|
if (!$class->can("undef_$field")) |
287
|
|
|
|
|
|
|
{ |
288
|
2779
|
|
|
|
|
4837
|
$code .= qq{ |
289
|
|
|
|
|
|
|
## undefine |
290
|
|
|
|
|
|
|
sub undef_$field |
291
|
|
|
|
|
|
|
{ |
292
|
|
|
|
|
|
|
my \$this = shift ; |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
\$this->{$field} = undef ; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
}; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
148
|
50
|
|
|
|
493
|
print "Created Accessors:\n$code\n" if $global_debug>=4 ; |
301
|
|
|
|
|
|
|
|
302
|
148
|
100
|
|
9
|
0
|
115543
|
eval $code; |
|
9
|
100
|
|
9
|
0
|
1463
|
|
|
9
|
100
|
|
6
|
0
|
23
|
|
|
9
|
100
|
|
9
|
0
|
1522
|
|
|
9
|
100
|
|
0
|
0
|
26
|
|
|
6
|
100
|
|
0
|
0
|
1581
|
|
|
6
|
100
|
|
3
|
0
|
20
|
|
|
9
|
50
|
|
0
|
0
|
1135
|
|
|
9
|
100
|
|
196
|
1
|
22
|
|
|
0
|
100
|
|
409
|
1
|
0
|
|
|
0
|
100
|
|
364
|
1
|
0
|
|
|
0
|
100
|
|
57
|
1
|
0
|
|
|
0
|
100
|
|
142
|
1
|
0
|
|
|
3
|
100
|
|
1264
|
0
|
3
|
|
|
3
|
100
|
|
1175
|
0
|
7
|
|
|
0
|
100
|
|
92
|
0
|
0
|
|
|
0
|
50
|
|
269
|
1
|
0
|
|
|
196
|
100
|
|
45
|
1
|
245
|
|
|
196
|
100
|
|
567
|
1
|
622
|
|
|
409
|
100
|
|
896
|
1
|
440
|
|
|
409
|
100
|
|
232
|
0
|
1019
|
|
|
364
|
100
|
|
246
|
0
|
427
|
|
|
364
|
100
|
|
75
|
0
|
987
|
|
|
57
|
100
|
|
186
|
0
|
108
|
|
|
57
|
100
|
|
180
|
1
|
233
|
|
|
142
|
100
|
|
300
|
1
|
261
|
|
|
142
|
100
|
|
165
|
1
|
469
|
|
|
1264
|
100
|
|
95
|
0
|
1272
|
|
|
1264
|
50
|
|
334
|
1
|
2943
|
|
|
1175
|
100
|
|
276
|
1
|
1191
|
|
|
1175
|
100
|
|
341
|
0
|
2802
|
|
|
92
|
100
|
|
231
|
0
|
166
|
|
|
92
|
100
|
|
15
|
0
|
343
|
|
|
269
|
100
|
|
172
|
0
|
359
|
|
|
269
|
100
|
|
376
|
0
|
759
|
|
|
45
|
100
|
|
89
|
0
|
47
|
|
|
45
|
100
|
|
54
|
0
|
125
|
|
|
567
|
100
|
|
58
|
0
|
599
|
|
|
567
|
100
|
|
67
|
0
|
1376
|
|
|
896
|
100
|
|
92
|
0
|
959
|
|
|
896
|
100
|
|
23
|
0
|
2238
|
|
|
232
|
100
|
|
49
|
0
|
321
|
|
|
232
|
100
|
|
260
|
0
|
803
|
|
|
246
|
100
|
|
42
|
0
|
297
|
|
|
246
|
100
|
|
63
|
0
|
1085
|
|
|
75
|
100
|
|
82
|
0
|
124
|
|
|
75
|
100
|
|
48
|
0
|
313
|
|
|
186
|
100
|
|
76
|
0
|
233
|
|
|
186
|
100
|
|
58
|
0
|
681
|
|
|
180
|
100
|
|
48
|
0
|
233
|
|
|
180
|
100
|
|
53
|
0
|
626
|
|
|
300
|
100
|
|
272
|
1
|
323
|
|
|
300
|
100
|
|
450
|
1
|
1373
|
|
|
165
|
100
|
|
246
|
1
|
247
|
|
|
165
|
100
|
|
77
|
1
|
669
|
|
|
95
|
100
|
|
64
|
1
|
134
|
|
|
95
|
100
|
|
63
|
1
|
318
|
|
|
334
|
100
|
|
82
|
1
|
380
|
|
|
334
|
100
|
|
54
|
1
|
1119
|
|
|
276
|
100
|
|
360
|
1
|
324
|
|
|
276
|
100
|
|
307
|
1
|
902
|
|
|
341
|
100
|
|
76
|
1
|
398
|
|
|
341
|
100
|
|
73
|
1
|
1312
|
|
|
231
|
100
|
|
84
|
1
|
294
|
|
|
231
|
100
|
|
76
|
1
|
767
|
|
|
15
|
100
|
|
54
|
1
|
16
|
|
|
15
|
100
|
|
231
|
1
|
43
|
|
|
172
|
100
|
|
234
|
1
|
220
|
|
|
172
|
100
|
|
408
|
1
|
578
|
|
|
376
|
100
|
|
86
|
1
|
347
|
|
|
376
|
100
|
|
88
|
1
|
5235
|
|
|
89
|
100
|
|
144
|
1
|
116
|
|
|
89
|
100
|
|
84
|
1
|
280
|
|
|
54
|
100
|
|
57
|
0
|
78
|
|
|
54
|
100
|
|
73
|
0
|
186
|
|
|
58
|
100
|
|
95
|
0
|
84
|
|
|
58
|
100
|
|
83
|
0
|
191
|
|
|
67
|
100
|
|
106
|
0
|
93
|
|
|
67
|
100
|
|
92
|
0
|
333
|
|
|
92
|
100
|
|
156
|
0
|
112
|
|
|
92
|
100
|
|
93
|
0
|
292
|
|
|
23
|
100
|
|
23
|
1
|
26
|
|
|
23
|
100
|
|
32
|
1
|
66
|
|
|
49
|
100
|
|
55
|
1
|
80
|
|
|
49
|
100
|
|
249
|
1
|
145
|
|
|
260
|
100
|
|
818
|
1
|
298
|
|
|
260
|
100
|
|
397
|
1
|
807
|
|
|
42
|
100
|
|
204
|
1
|
68
|
|
|
42
|
100
|
|
121
|
1
|
394
|
|
|
63
|
100
|
|
121
|
1
|
84
|
|
|
63
|
100
|
|
140
|
1
|
218
|
|
|
82
|
100
|
|
110
|
1
|
110
|
|
|
82
|
50
|
|
81
|
1
|
279
|
|
|
48
|
100
|
|
223
|
1
|
103
|
|
|
48
|
100
|
|
246
|
1
|
271
|
|
|
76
|
100
|
|
221
|
1
|
107
|
|
|
76
|
100
|
|
15
|
1
|
269
|
|
|
58
|
100
|
|
74
|
1
|
103
|
|
|
58
|
100
|
|
64
|
1
|
229
|
|
|
48
|
100
|
|
66
|
1
|
71
|
|
|
48
|
100
|
|
67
|
1
|
200
|
|
|
53
|
100
|
|
58
|
0
|
75
|
|
|
53
|
100
|
|
116
|
0
|
190
|
|
|
272
|
100
|
|
80
|
1
|
307
|
|
|
272
|
100
|
|
64
|
1
|
858
|
|
|
450
|
100
|
|
99
|
0
|
437
|
|
|
450
|
100
|
|
121
|
0
|
1117
|
|
|
246
|
100
|
|
52
|
0
|
274
|
|
|
246
|
100
|
|
102
|
0
|
695
|
|
|
77
|
100
|
|
101
|
0
|
125
|
|
|
77
|
100
|
|
150
|
0
|
269
|
|
|
64
|
100
|
|
101
|
0
|
99
|
|
|
64
|
100
|
|
134
|
0
|
235
|
|
|
63
|
100
|
|
137
|
0
|
93
|
|
|
63
|
100
|
|
91
|
0
|
212
|
|
|
82
|
100
|
|
62
|
0
|
126
|
|
|
82
|
100
|
|
248
|
0
|
317
|
|
|
54
|
100
|
|
233
|
0
|
87
|
|
|
54
|
100
|
|
87
|
0
|
193
|
|
|
360
|
|
|
49
|
0
|
513
|
|
|
360
|
|
|
0
|
0
|
1313
|
|
|
307
|
|
|
0
|
0
|
341
|
|
|
307
|
|
|
0
|
0
|
895
|
|
|
76
|
|
|
0
|
0
|
123
|
|
|
76
|
|
|
0
|
0
|
318
|
|
|
73
|
|
|
0
|
0
|
122
|
|
|
73
|
|
|
0
|
0
|
283
|
|
|
84
|
|
|
1
|
0
|
135
|
|
|
84
|
|
|
17
|
0
|
319
|
|
|
76
|
|
|
0
|
0
|
132
|
|
|
76
|
|
|
0
|
0
|
266
|
|
|
54
|
|
|
0
|
0
|
93
|
|
|
54
|
|
|
0
|
0
|
210
|
|
|
231
|
|
|
2
|
0
|
256
|
|
|
231
|
|
|
30
|
0
|
737
|
|
|
234
|
|
|
27
|
0
|
259
|
|
|
234
|
|
|
27
|
0
|
685
|
|
|
408
|
|
|
28
|
0
|
405
|
|
|
408
|
|
|
21
|
0
|
1443
|
|
|
86
|
|
|
27
|
0
|
120
|
|
|
86
|
|
|
26
|
0
|
286
|
|
|
88
|
|
|
26
|
0
|
112
|
|
|
88
|
|
|
0
|
0
|
340
|
|
|
144
|
|
|
17
|
0
|
168
|
|
|
144
|
|
|
0
|
0
|
418
|
|
|
84
|
|
|
28
|
0
|
102
|
|
|
84
|
|
|
26
|
0
|
277
|
|
|
57
|
|
|
27
|
0
|
88
|
|
|
57
|
|
|
28
|
0
|
216
|
|
|
73
|
|
|
26
|
0
|
211
|
|
|
73
|
|
|
21
|
0
|
238
|
|
|
95
|
|
|
21
|
0
|
137
|
|
|
95
|
|
|
17
|
0
|
393
|
|
|
83
|
|
|
0
|
0
|
105
|
|
|
83
|
|
|
0
|
0
|
365
|
|
|
106
|
|
|
0
|
0
|
141
|
|
|
106
|
|
|
0
|
0
|
440
|
|
|
92
|
|
|
0
|
0
|
105
|
|
|
92
|
|
|
0
|
0
|
425
|
|
|
156
|
|
|
0
|
0
|
219
|
|
|
156
|
|
|
0
|
0
|
643
|
|
|
93
|
|
|
0
|
0
|
109
|
|
|
93
|
|
|
0
|
0
|
378
|
|
|
23
|
|
|
0
|
0
|
23
|
|
|
23
|
|
|
0
|
0
|
72
|
|
|
32
|
|
|
0
|
0
|
56
|
|
|
32
|
|
|
0
|
0
|
142
|
|
|
55
|
|
|
0
|
0
|
563
|
|
|
55
|
|
|
0
|
0
|
243
|
|
|
249
|
|
|
0
|
0
|
341
|
|
|
249
|
|
|
0
|
0
|
657
|
|
|
818
|
|
|
0
|
0
|
803
|
|
|
818
|
|
|
0
|
0
|
2073
|
|
|
397
|
|
|
0
|
0
|
461
|
|
|
397
|
|
|
0
|
0
|
1204
|
|
|
204
|
|
|
0
|
0
|
242
|
|
|
204
|
|
|
0
|
0
|
627
|
|
|
121
|
|
|
29
|
0
|
146
|
|
|
121
|
|
|
1
|
0
|
365
|
|
|
121
|
|
|
0
|
0
|
160
|
|
|
121
|
|
|
0
|
0
|
396
|
|
|
140
|
|
|
0
|
0
|
160
|
|
|
140
|
|
|
0
|
0
|
426
|
|
|
110
|
|
|
0
|
0
|
148
|
|
|
110
|
|
|
0
|
0
|
365
|
|
|
81
|
|
|
2
|
0
|
104
|
|
|
81
|
|
|
0
|
0
|
298
|
|
|
223
|
|
|
0
|
0
|
276
|
|
|
223
|
|
|
0
|
0
|
793
|
|
|
246
|
|
|
0
|
0
|
308
|
|
|
246
|
|
|
0
|
0
|
776
|
|
|
221
|
|
|
0
|
0
|
254
|
|
|
221
|
|
|
17
|
0
|
748
|
|
|
15
|
|
|
0
|
0
|
17
|
|
|
15
|
|
|
0
|
0
|
42
|
|
|
74
|
|
|
0
|
0
|
105
|
|
|
74
|
|
|
45
|
0
|
300
|
|
|
64
|
|
|
36
|
0
|
108
|
|
|
64
|
|
|
1
|
0
|
257
|
|
|
66
|
|
|
0
|
0
|
100
|
|
|
66
|
|
|
0
|
0
|
214
|
|
|
67
|
|
|
0
|
0
|
93
|
|
|
67
|
|
|
0
|
0
|
235
|
|
|
58
|
|
|
0
|
0
|
86
|
|
|
58
|
|
|
26
|
0
|
229
|
|
|
116
|
|
|
26
|
0
|
160
|
|
|
116
|
|
|
26
|
0
|
454
|
|
|
80
|
|
|
17
|
0
|
112
|
|
|
80
|
|
|
0
|
0
|
343
|
|
|
64
|
|
|
0
|
0
|
109
|
|
|
64
|
|
|
0
|
0
|
297
|
|
|
99
|
|
|
0
|
0
|
132
|
|
|
99
|
|
|
0
|
0
|
398
|
|
|
121
|
|
|
0
|
0
|
141
|
|
|
121
|
|
|
0
|
0
|
495
|
|
|
52
|
|
|
0
|
0
|
67
|
|
|
52
|
|
|
0
|
0
|
250
|
|
|
102
|
|
|
0
|
0
|
135
|
|
|
102
|
|
|
0
|
0
|
373
|
|
|
101
|
|
|
0
|
0
|
138
|
|
|
101
|
|
|
0
|
0
|
342
|
|
|
150
|
|
|
0
|
1
|
170
|
|
|
150
|
|
|
0
|
1
|
484
|
|
|
101
|
|
|
0
|
0
|
124
|
|
|
101
|
|
|
0
|
|
355
|
|
|
134
|
|
|
0
|
|
174
|
|
|
134
|
|
|
0
|
|
462
|
|
|
137
|
|
|
0
|
|
153
|
|
|
137
|
|
|
0
|
|
452
|
|
|
91
|
|
|
0
|
|
266
|
|
|
91
|
|
|
17
|
|
343
|
|
|
62
|
|
|
26
|
|
114
|
|
|
62
|
|
|
0
|
|
234
|
|
|
248
|
|
|
0
|
|
287
|
|
|
248
|
|
|
26
|
|
774
|
|
|
233
|
|
|
283
|
|
239
|
|
|
233
|
|
|
66
|
|
674
|
|
|
87
|
|
|
570
|
|
95
|
|
|
87
|
|
|
249
|
|
298
|
|
|
49
|
|
|
|
|
42
|
|
|
49
|
|
|
|
|
126
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
67
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
4
|
|
|
30
|
|
|
|
|
66
|
|
|
30
|
|
|
|
|
93
|
|
|
27
|
|
|
|
|
56
|
|
|
27
|
|
|
|
|
87
|
|
|
27
|
|
|
|
|
61
|
|
|
27
|
|
|
|
|
85
|
|
|
28
|
|
|
|
|
65
|
|
|
28
|
|
|
|
|
85
|
|
|
21
|
|
|
|
|
57
|
|
|
21
|
|
|
|
|
61
|
|
|
27
|
|
|
|
|
41
|
|
|
27
|
|
|
|
|
80
|
|
|
26
|
|
|
|
|
40
|
|
|
26
|
|
|
|
|
64
|
|
|
26
|
|
|
|
|
39
|
|
|
26
|
|
|
|
|
71
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
17
|
|
|
|
|
38
|
|
|
17
|
|
|
|
|
47
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
28
|
|
|
|
|
55
|
|
|
28
|
|
|
|
|
94
|
|
|
26
|
|
|
|
|
55
|
|
|
26
|
|
|
|
|
84
|
|
|
27
|
|
|
|
|
67
|
|
|
27
|
|
|
|
|
101
|
|
|
28
|
|
|
|
|
58
|
|
|
28
|
|
|
|
|
78
|
|
|
26
|
|
|
|
|
45
|
|
|
26
|
|
|
|
|
89
|
|
|
21
|
|
|
|
|
40
|
|
|
21
|
|
|
|
|
79
|
|
|
21
|
|
|
|
|
48
|
|
|
21
|
|
|
|
|
63
|
|
|
17
|
|
|
|
|
45
|
|
|
17
|
|
|
|
|
61
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
29
|
|
|
|
|
40
|
|
|
29
|
|
|
|
|
76
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
54
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
45
|
|
|
|
|
65
|
|
|
45
|
|
|
|
|
105
|
|
|
36
|
|
|
|
|
57
|
|
|
36
|
|
|
|
|
100
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
26
|
|
|
|
|
39
|
|
|
26
|
|
|
|
|
73
|
|
|
26
|
|
|
|
|
40
|
|
|
26
|
|
|
|
|
65
|
|
|
26
|
|
|
|
|
40
|
|
|
26
|
|
|
|
|
57
|
|
|
17
|
|
|
|
|
36
|
|
|
17
|
|
|
|
|
51
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
17
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
72
|
|
|
26
|
|
|
|
|
35
|
|
|
26
|
|
|
|
|
67
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
26
|
|
|
|
|
35
|
|
|
26
|
|
|
|
|
64
|
|
|
283
|
|
|
|
|
364
|
|
|
283
|
|
|
|
|
1015
|
|
|
66
|
|
|
|
|
112
|
|
|
66
|
|
|
|
|
255
|
|
|
570
|
|
|
|
|
619
|
|
|
570
|
|
|
|
|
1782
|
|
|
249
|
|
|
|
|
302
|
|
|
249
|
|
|
|
|
877
|
|
303
|
148
|
50
|
|
|
|
487
|
if ($@) { |
304
|
0
|
|
|
|
|
0
|
die "ERROR defining accessors for '$class':" |
305
|
|
|
|
|
|
|
. "\n\t$@\n" |
306
|
|
|
|
|
|
|
. "-----------------------------------------------------\n" |
307
|
|
|
|
|
|
|
. $code; |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
## Create private fields |
311
|
|
|
|
|
|
|
|
312
|
148
|
50
|
|
|
|
416
|
prt_data(" init_class: class=$class FIELD_LIST=", \%FIELD_LIST) if $global_debug>=4 ; |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
# Finished |
315
|
148
|
|
|
|
|
462
|
$CLASS_INIT{$class}=1; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
162
|
50
|
|
|
|
812
|
print "init_class() - done\n" if $global_debug>=3 ; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=item B |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
Adds the contents of the HASH ref $fields_href to the args HASH ref ($args_href) under the key |
326
|
|
|
|
|
|
|
'fields'. Used by derived objects to add their fields to the parent object's fields. |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
=cut |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub add_fields |
332
|
|
|
|
|
|
|
{ |
333
|
475
|
|
|
475
|
1
|
478
|
my $this = shift ; |
334
|
475
|
|
|
|
|
462
|
my ($fields_href, $args_href) = @_ ; |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# Add extra fields |
337
|
475
|
|
|
|
|
2170
|
foreach (keys %$fields_href) |
338
|
|
|
|
|
|
|
{ |
339
|
2667
|
|
|
|
|
4344
|
$args_href->{'fields'}{$_} = $fields_href->{$_} ; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=item B |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
Initialises the object class variables. Creates a class instance so that these |
349
|
|
|
|
|
|
|
methods can also be called via the class (don't need a specific instance) |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=cut |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
sub init_class_instance |
354
|
|
|
|
|
|
|
{ |
355
|
0
|
|
|
0
|
1
|
0
|
my $class = shift ; |
356
|
0
|
|
|
|
|
0
|
my (%args) = @_ ; |
357
|
|
|
|
|
|
|
|
358
|
0
|
|
|
|
|
0
|
$class->init_class(%args) ; |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# Create a class instance object - allows these methods to be called via class |
361
|
0
|
|
|
|
|
0
|
$class->class_instance(%args) ; |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
# Set any global values |
364
|
0
|
|
|
|
|
0
|
$class->set(%args) ; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
368
|
|
|
|
|
|
|
# Return global fields hash |
369
|
|
|
|
|
|
|
sub _field_list |
370
|
|
|
|
|
|
|
{ |
371
|
0
|
|
|
0
|
|
0
|
my $class = shift ; |
372
|
|
|
|
|
|
|
|
373
|
0
|
|
|
|
|
0
|
return %FIELD_LIST ; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
#============================================================================================ |
377
|
|
|
|
|
|
|
# CLASS METHODS |
378
|
|
|
|
|
|
|
#============================================================================================ |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=item B |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
Set global debug print options to I. |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
0 = No debug |
387
|
|
|
|
|
|
|
1 = standard debug information |
388
|
|
|
|
|
|
|
2 = verbose debug information |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
=cut |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub global_debug |
393
|
|
|
|
|
|
|
{ |
394
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
395
|
0
|
|
|
|
|
0
|
my ($flag) = @_ ; |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
#my $class = $this->class() ; |
398
|
|
|
|
|
|
|
##my $class = ref($this) || $this ; |
399
|
|
|
|
|
|
|
|
400
|
0
|
|
|
|
|
0
|
my $old = $global_debug ; |
401
|
0
|
0
|
|
|
|
0
|
$global_debug = $flag if defined($flag) ; |
402
|
|
|
|
|
|
|
|
403
|
0
|
|
|
|
|
0
|
return $old ; |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
=item B |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
Set global verbose print level to I. |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
0 = None verbose |
414
|
|
|
|
|
|
|
1 = verbose information |
415
|
|
|
|
|
|
|
2 = print commands |
416
|
|
|
|
|
|
|
3 = print command results |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=cut |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
sub global_verbose |
421
|
|
|
|
|
|
|
{ |
422
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
423
|
0
|
|
|
|
|
0
|
my ($flag) = @_ ; |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
#my $class = $this->class() ; |
426
|
|
|
|
|
|
|
##my $class = ref($this) || $this ; |
427
|
|
|
|
|
|
|
|
428
|
0
|
|
|
|
|
0
|
my $old = $global_verbose ; |
429
|
0
|
0
|
|
|
|
0
|
$global_verbose = $flag if defined($flag) ; |
430
|
|
|
|
|
|
|
|
431
|
0
|
|
|
|
|
0
|
return $old ; |
432
|
|
|
|
|
|
|
} |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=item B |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
Enable/disable strict field checking |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=cut |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
sub strict_fields |
443
|
|
|
|
|
|
|
{ |
444
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
445
|
0
|
|
|
|
|
0
|
my ($flag) = @_ ; |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
#my $class = $this->class() ; |
448
|
|
|
|
|
|
|
##my $class = ref($this) || $this ; |
449
|
|
|
|
|
|
|
|
450
|
0
|
|
|
|
|
0
|
my $old = $strict_fields ; |
451
|
0
|
0
|
|
|
|
0
|
$strict_fields = $flag if defined($flag) ; |
452
|
|
|
|
|
|
|
|
453
|
0
|
|
|
|
|
0
|
return $old ; |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
=item B |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
Returns an object that can be used for class-based calls - object contains |
461
|
|
|
|
|
|
|
all the usual fields |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=cut |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
sub class_instance |
466
|
|
|
|
|
|
|
{ |
467
|
162
|
|
|
162
|
1
|
276
|
my $this = shift ; |
468
|
162
|
|
|
|
|
897
|
my (@args) = @_ ; |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
#my $class = $this->class() ; |
471
|
162
|
|
33
|
|
|
877
|
my $class = ref($this) || $this ; |
472
|
|
|
|
|
|
|
|
473
|
162
|
100
|
100
|
|
|
1246
|
if ($class->allowed_class_instance() && !$class->has_class_instance()) |
474
|
|
|
|
|
|
|
{ |
475
|
2
|
|
|
|
|
4
|
$CLASS_INSTANCE{$class} = 1 ; # ensure we don't get here again (breaks recursive loop) |
476
|
|
|
|
|
|
|
|
477
|
2
|
50
|
|
|
|
7
|
print "-- Create class instance --\n" if $global_debug>=3 ; |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
# Need to create one using the args |
480
|
2
|
|
|
|
|
8
|
$CLASS_INSTANCE{$class} = $class->new(@args) ; |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
|
484
|
162
|
|
|
|
|
1278
|
return $CLASS_INSTANCE{$class} ; |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=item B |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
Returns true if this class has a class instance object |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=cut |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
sub has_class_instance |
496
|
|
|
|
|
|
|
{ |
497
|
5
|
|
|
5
|
1
|
5
|
my $this = shift ; |
498
|
|
|
|
|
|
|
#my $class = $this->class() ; |
499
|
5
|
|
33
|
|
|
18
|
my $class = ref($this) || $this ; |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
#prt_data("has_class_instance($class) CLASS_INSTANCE=", \%CLASS_INSTANCE) if $global_debug>=5 ; |
502
|
|
|
|
|
|
|
|
503
|
5
|
|
|
|
|
19
|
return exists($CLASS_INSTANCE{$class}) ; |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=item B |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Returns true if this class can have a class instance object |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=cut |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
sub allowed_class_instance |
515
|
|
|
|
|
|
|
{ |
516
|
5
|
|
|
5
|
1
|
23
|
return 1 ; |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
=item B |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
Returns hash of object's field definitions. |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=cut |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
sub field_list |
528
|
|
|
|
|
|
|
{ |
529
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
#my $class = $this->class() ; |
532
|
0
|
|
0
|
|
|
0
|
my $class = ref($this) || $this ; |
533
|
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
0
|
my $href ; |
535
|
0
|
0
|
|
|
|
0
|
$href = $FIELD_LIST{$class} if exists($FIELD_LIST{$class}) ; |
536
|
|
|
|
|
|
|
|
537
|
0
|
0
|
|
|
|
0
|
return $href ? %$href : () ; |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
#============================================================================================ |
542
|
|
|
|
|
|
|
# OBJECT DATA METHODS |
543
|
|
|
|
|
|
|
#============================================================================================ |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=item B |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
Set debug print options to I. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
=cut |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
sub debug |
555
|
|
|
|
|
|
|
{ |
556
|
37899
|
|
|
37899
|
1
|
24091
|
my $this = shift ; |
557
|
37899
|
|
|
|
|
23819
|
my ($level) = @_ ; |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
#my $class = $this->class() ; |
560
|
37899
|
|
33
|
|
|
48852
|
my $class = ref($this) || $this ; |
561
|
|
|
|
|
|
|
#print "In debug() for $class\n" ; |
562
|
|
|
|
|
|
|
|
563
|
37899
|
|
100
|
|
|
78897
|
$DEBUG{$class} ||= 0 ; |
564
|
37899
|
|
|
|
|
25563
|
my $old = $DEBUG{$class} ; |
565
|
37899
|
100
|
|
|
|
43365
|
$DEBUG{$class} = $level if defined($level) ; |
566
|
|
|
|
|
|
|
|
567
|
37899
|
|
|
|
|
77302
|
return $old ; |
568
|
|
|
|
|
|
|
} |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
=item B |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
Set debug print options flag to undefined. |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=cut |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
sub undef_debug |
580
|
|
|
|
|
|
|
{ |
581
|
162
|
|
|
162
|
1
|
215
|
my $this = shift ; |
582
|
162
|
|
|
|
|
224
|
my ($level) = @_ ; |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
#my $class = $this->class() ; |
585
|
162
|
|
33
|
|
|
388
|
my $class = ref($this) || $this ; |
586
|
|
|
|
|
|
|
#print "In undef_debug() for $class\n" ; |
587
|
|
|
|
|
|
|
|
588
|
162
|
|
50
|
|
|
720
|
$DEBUG{$class} ||= 0 ; |
589
|
162
|
|
|
|
|
174
|
my $old = $DEBUG{$class} ; |
590
|
162
|
|
|
|
|
185
|
$DEBUG{$class} = undef ; |
591
|
|
|
|
|
|
|
|
592
|
162
|
|
|
|
|
276
|
return $old ; |
593
|
|
|
|
|
|
|
} |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
=item B |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
Set verbose print options to I. |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=cut |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
sub verbose |
606
|
|
|
|
|
|
|
{ |
607
|
211
|
|
|
211
|
1
|
202
|
my $this = shift ; |
608
|
211
|
|
|
|
|
208
|
my ($level) = @_ ; |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
#my $class = $this->class() ; |
611
|
211
|
|
33
|
|
|
436
|
my $class = ref($this) || $this ; |
612
|
|
|
|
|
|
|
#print "In verbose() for $class\n" ; |
613
|
|
|
|
|
|
|
|
614
|
211
|
|
50
|
|
|
733
|
$VERBOSE{$class} ||= 0 ; |
615
|
211
|
|
|
|
|
203
|
my $old = $VERBOSE{$class} ; |
616
|
211
|
50
|
|
|
|
349
|
$VERBOSE{$class} = $level if defined($level) ; |
617
|
|
|
|
|
|
|
|
618
|
211
|
|
|
|
|
318
|
return $old ; |
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=item B |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
Set verbose print options flag to undefined. |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=cut |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
sub undef_verbose |
631
|
|
|
|
|
|
|
{ |
632
|
162
|
|
|
162
|
1
|
225
|
my $this = shift ; |
633
|
162
|
|
|
|
|
192
|
my ($level) = @_ ; |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
#my $class = $this->class() ; |
636
|
162
|
|
33
|
|
|
384
|
my $class = ref($this) || $this ; |
637
|
|
|
|
|
|
|
#print "In undef_verbose() for $class\n" ; |
638
|
|
|
|
|
|
|
|
639
|
162
|
|
50
|
|
|
696
|
$DEBUG{$class} ||= 0 ; |
640
|
162
|
|
|
|
|
186
|
my $old = $DEBUG{$class} ; |
641
|
162
|
|
|
|
|
184
|
$DEBUG{$class} = undef ; |
642
|
|
|
|
|
|
|
|
643
|
162
|
|
|
|
|
262
|
return $old ; |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=item B |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
Get/set a field value. Used by derived objects to get/set the underlying object field |
651
|
|
|
|
|
|
|
variable when they have overridden that field's access method. |
652
|
|
|
|
|
|
|
|
653
|
|
|
|
|
|
|
=cut |
654
|
|
|
|
|
|
|
|
655
|
|
|
|
|
|
|
sub field_access |
656
|
|
|
|
|
|
|
{ |
657
|
34
|
|
|
34
|
1
|
53
|
my $this = shift ; |
658
|
34
|
|
|
|
|
76
|
my ($field, $value) = @_ ; |
659
|
|
|
|
|
|
|
|
660
|
34
|
|
33
|
|
|
96
|
my $class = ref($this) || $this ; |
661
|
34
|
|
|
|
|
66
|
my %field_list = (); |
662
|
34
|
50
|
|
|
|
103
|
%field_list = %{ $FIELD_LIST{$class} } if exists($FIELD_LIST{$class}) ; |
|
34
|
|
|
|
|
393
|
|
663
|
34
|
50
|
|
|
|
131
|
$this->throw_fatal("Attempting to access an invalid field \"$field\" for this object class \"$class\" ") unless (exists($field_list{$field})) ; |
664
|
|
|
|
|
|
|
|
665
|
34
|
100
|
|
|
|
104
|
$this->{$field} = $value if defined($value) ; |
666
|
34
|
|
|
|
|
145
|
return $this->{$field} ; |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
=item B |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
Set one or more settable parameter. |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
The %args are specified as a hash, for example |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
set('mmap_handler' => $mmap_handler) |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
Sets field values. Field values are expressed as part of the HASH (i.e. normal |
684
|
|
|
|
|
|
|
field => value pairs). |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=cut |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
sub set |
689
|
|
|
|
|
|
|
{ |
690
|
611
|
|
|
611
|
1
|
1374
|
my $this = shift ; |
691
|
611
|
|
|
|
|
1923
|
my (%args) = @_ ; |
692
|
|
|
|
|
|
|
|
693
|
611
|
50
|
|
|
|
1454
|
prt_data("set() ARGS=", \%args, "\n") if $global_debug>=3 ; |
694
|
|
|
|
|
|
|
|
695
|
611
|
|
|
|
|
1266
|
$this = $this->check_instance() ; |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
# Args |
698
|
|
|
|
|
|
|
## my %field_list = $this->field_list() ; |
699
|
611
|
|
33
|
|
|
1888
|
my $class = ref($this) || $this ; |
700
|
611
|
|
|
|
|
753
|
my %field_list = (); |
701
|
611
|
50
|
|
|
|
1181
|
%field_list = %{ $FIELD_LIST{$class} } if exists($FIELD_LIST{$class}) ; |
|
611
|
|
|
|
|
6306
|
|
702
|
|
|
|
|
|
|
|
703
|
611
|
|
|
|
|
2765
|
foreach my $field (keys %field_list) |
704
|
|
|
|
|
|
|
{ |
705
|
16023
|
100
|
|
|
|
20423
|
if (exists($args{$field})) |
706
|
|
|
|
|
|
|
{ |
707
|
4616
|
50
|
|
|
|
5821
|
print " + set $field = $args{$field}\n" if $global_debug>=3 ; |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
# Need to call actual method (rather than ___set) so that it can be overridden |
710
|
4616
|
100
|
|
|
|
5415
|
if (!defined($args{$field})) |
711
|
|
|
|
|
|
|
{ |
712
|
|
|
|
|
|
|
# Set to undef |
713
|
1068
|
|
|
|
|
1401
|
my $undef_method = "undef_$field" ; |
714
|
1068
|
|
|
|
|
15052
|
$this->$undef_method() ; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
else |
717
|
|
|
|
|
|
|
{ |
718
|
3548
|
|
|
|
|
69468
|
$this->$field($args{$field}) ; |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
## See if strict checks are enabled |
724
|
611
|
50
|
|
|
|
1620
|
if ($strict_fields) |
725
|
|
|
|
|
|
|
{ |
726
|
|
|
|
|
|
|
# Check to ensure that only the valid fields are being set |
727
|
0
|
|
|
|
|
0
|
foreach my $field (keys %args) |
728
|
|
|
|
|
|
|
{ |
729
|
0
|
0
|
|
|
|
0
|
if (!exists($field_list{$field})) |
730
|
|
|
|
|
|
|
{ |
731
|
0
|
|
|
|
|
0
|
print "WARNING::Attempt to set invalid field \"$field\" \n" ; |
732
|
0
|
|
|
|
|
0
|
$this->dump_callstack() ; |
733
|
|
|
|
|
|
|
} |
734
|
|
|
|
|
|
|
} |
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
|
737
|
611
|
50
|
|
|
|
3073
|
print "set() - done\n" if $global_debug>=3 ; |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
=item B |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
Returns hash of object's fields (i.e. field name => field value pairs). |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
If @names array is specified, then only returns the HASH containing the named fields. |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
=cut |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
sub vars |
752
|
|
|
|
|
|
|
{ |
753
|
211
|
|
|
211
|
1
|
233
|
my $this = shift ; |
754
|
211
|
|
|
|
|
273
|
my (@names) = @_ ; |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
## my %field_list = $this->field_list() ; |
757
|
211
|
|
33
|
|
|
446
|
my $class = ref($this) || $this ; |
758
|
211
|
|
|
|
|
301
|
my %field_list = (); |
759
|
211
|
50
|
|
|
|
441
|
%field_list = %{ $FIELD_LIST{$class} } if exists($FIELD_LIST{$class}) ; |
|
211
|
|
|
|
|
2665
|
|
760
|
|
|
|
|
|
|
|
761
|
211
|
|
|
|
|
409
|
my %fields ; |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
#prt_data("vars() names=", \@names) ; |
764
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
# If no names specified then get all of them |
766
|
211
|
50
|
|
|
|
385
|
unless (@names) |
767
|
|
|
|
|
|
|
{ |
768
|
211
|
|
|
|
|
1270
|
@names = keys %field_list ; |
769
|
|
|
|
|
|
|
} |
770
|
211
|
|
|
|
|
468
|
my %names = map {$_ => 1} @names ; |
|
7130
|
|
|
|
|
6352
|
|
771
|
|
|
|
|
|
|
#prt_data(" + names=", \%names) ; |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
# Get the value of each field |
774
|
211
|
|
|
|
|
1044
|
foreach my $field (keys %field_list) |
775
|
|
|
|
|
|
|
{ |
776
|
|
|
|
|
|
|
# Store field if we've asked for it |
777
|
7130
|
50
|
|
|
|
118894
|
$fields{$field} = $this->$field() if exists($names{$field}) ; |
778
|
|
|
|
|
|
|
#print " + + $field : " ; |
779
|
|
|
|
|
|
|
#if (exists($fields{$field})) |
780
|
|
|
|
|
|
|
#{ |
781
|
|
|
|
|
|
|
# print "ok ($fields{$field})\n" ; |
782
|
|
|
|
|
|
|
#} |
783
|
|
|
|
|
|
|
#else |
784
|
|
|
|
|
|
|
#{ |
785
|
|
|
|
|
|
|
# print "not wanted\n" ; |
786
|
|
|
|
|
|
|
#} |
787
|
|
|
|
|
|
|
} |
788
|
|
|
|
|
|
|
|
789
|
211
|
|
|
|
|
4869
|
return %fields ; |
790
|
|
|
|
|
|
|
} |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
=item B |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
Destroy object |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=cut |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
sub DESTROY |
804
|
|
|
|
|
|
|
{ |
805
|
6
|
|
|
6
|
|
885
|
my $this = shift ; |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
} |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
#============================================================================================ |
811
|
|
|
|
|
|
|
# OBJECT METHODS |
812
|
|
|
|
|
|
|
#============================================================================================ |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
=item B |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
If this is not an instance (i.e. a class call), then if there is a class_instance |
819
|
|
|
|
|
|
|
defined use it, otherwise error. |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
=cut |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
sub check_instance |
824
|
|
|
|
|
|
|
{ |
825
|
795
|
|
|
795
|
1
|
765
|
my $this = shift ; |
826
|
795
|
|
|
|
|
912
|
my (%args) = @_ ; |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
#my $class = $this->class() ; |
829
|
|
|
|
|
|
|
|
830
|
795
|
50
|
|
|
|
1427
|
if (!ref($this)) |
831
|
|
|
|
|
|
|
{ |
832
|
0
|
|
0
|
|
|
0
|
my $class = ref($this) || $this ; |
833
|
0
|
0
|
|
|
|
0
|
if ($class->has_class_instance()) |
834
|
|
|
|
|
|
|
{ |
835
|
0
|
|
|
|
|
0
|
$this = $class->class_instance() ; |
836
|
|
|
|
|
|
|
} |
837
|
|
|
|
|
|
|
else |
838
|
|
|
|
|
|
|
{ |
839
|
0
|
|
|
|
|
0
|
croak "$this is not a usable object" ; |
840
|
|
|
|
|
|
|
} |
841
|
|
|
|
|
|
|
} |
842
|
|
|
|
|
|
|
|
843
|
795
|
|
|
|
|
1178
|
return $this ; |
844
|
|
|
|
|
|
|
} |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
=item B |
850
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
Transfers all the supported attributes from $this object to $target object. |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=cut |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
sub copy_attributes |
856
|
|
|
|
|
|
|
{ |
857
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
858
|
0
|
|
|
|
|
0
|
my ($target) = @_ ; |
859
|
|
|
|
|
|
|
|
860
|
0
|
|
|
|
|
0
|
$this = $this->check_instance() ; |
861
|
0
|
|
|
|
|
0
|
$target = $target->check_instance() ; |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
# Get list of fields in the target |
864
|
0
|
|
|
|
|
0
|
my %target_field_list = $target->field_list() ; |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
# Copy values from this object |
867
|
0
|
|
|
|
|
0
|
my %field_list = $this->field_list() ; |
868
|
0
|
|
|
|
|
0
|
foreach my $field (keys %target_field_list) |
869
|
|
|
|
|
|
|
{ |
870
|
|
|
|
|
|
|
# see if can copy |
871
|
0
|
0
|
|
|
|
0
|
if (exists($field_list{$field})) |
872
|
|
|
|
|
|
|
{ |
873
|
0
|
|
|
|
|
0
|
$target->set($field => $this->$field()) ; |
874
|
|
|
|
|
|
|
} |
875
|
|
|
|
|
|
|
} |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
} |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
=item B |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
Returns name of object class. |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
=cut |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
sub class |
888
|
|
|
|
|
|
|
{ |
889
|
76
|
|
|
76
|
1
|
96
|
my $this = shift ; |
890
|
|
|
|
|
|
|
|
891
|
76
|
|
33
|
|
|
209
|
my $class = ref($this) || $this ; |
892
|
|
|
|
|
|
|
|
893
|
76
|
|
|
|
|
329
|
return $class ; |
894
|
|
|
|
|
|
|
} |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
=item B |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
Create a copy of this object and return the copy. |
901
|
|
|
|
|
|
|
|
902
|
|
|
|
|
|
|
=cut |
903
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
sub clone |
905
|
|
|
|
|
|
|
{ |
906
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
907
|
|
|
|
|
|
|
|
908
|
0
|
|
|
|
|
0
|
my $clone ; |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
# TODO: WRITE IT! |
911
|
|
|
|
|
|
|
|
912
|
0
|
|
|
|
|
0
|
return $clone ; |
913
|
|
|
|
|
|
|
} |
914
|
|
|
|
|
|
|
|
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
|
917
|
|
|
|
|
|
|
# ============================================================================================ |
918
|
|
|
|
|
|
|
# UTILITY METHODS |
919
|
|
|
|
|
|
|
# ============================================================================================ |
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
924
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
=item B |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
Returns a quoted version of the string. |
928
|
|
|
|
|
|
|
|
929
|
|
|
|
|
|
|
=cut |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
sub quote_str |
932
|
|
|
|
|
|
|
{ |
933
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
934
|
0
|
|
|
|
|
0
|
my ($str) = @_ ; |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
##my $class = $this->class() ; |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
# skip on Windows machines |
939
|
0
|
0
|
|
|
|
0
|
unless ($^O eq 'MSWin32') |
940
|
|
|
|
|
|
|
{ |
941
|
|
|
|
|
|
|
# first escape any existing quotes |
942
|
0
|
|
|
|
|
0
|
$str =~ s%\\'%'%g ; |
943
|
0
|
|
|
|
|
0
|
$str =~ s%'%'\\''%g ; |
944
|
|
|
|
|
|
|
|
945
|
0
|
|
|
|
|
0
|
$str = "'".$str."'" ; |
946
|
|
|
|
|
|
|
} |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
|
949
|
0
|
|
|
|
|
0
|
return $str ; |
950
|
|
|
|
|
|
|
} |
951
|
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
=item B |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
Work through string expanding any variables, replacing them with the value stored in the %vars hash. |
957
|
|
|
|
|
|
|
If variable is not stored in %vars, then that variable is left. |
958
|
|
|
|
|
|
|
|
959
|
|
|
|
|
|
|
Returns expanded string. |
960
|
|
|
|
|
|
|
|
961
|
|
|
|
|
|
|
=cut |
962
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
sub expand_vars |
964
|
|
|
|
|
|
|
{ |
965
|
0
|
|
|
0
|
1
|
0
|
my $this = shift ; |
966
|
0
|
|
|
|
|
0
|
my ($string, $vars_href) = @_ ; |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
# Do replacement |
970
|
0
|
|
|
|
|
0
|
$string =~ s{ |
971
|
|
|
|
|
|
|
\$ # find a literal dollar sign |
972
|
|
|
|
|
|
|
\{{0,1} # optional brace |
973
|
|
|
|
|
|
|
(\w+) # find a "word" and store it in $1 |
974
|
|
|
|
|
|
|
\}{0,1} # optional brace |
975
|
|
|
|
|
|
|
}{ |
976
|
30
|
|
|
30
|
|
147
|
no strict 'refs'; # for $$1 below |
|
30
|
|
|
|
|
38
|
|
|
30
|
|
|
|
|
25277
|
|
977
|
0
|
0
|
|
|
|
0
|
if (defined $vars_href->{$1}) { |
978
|
0
|
|
|
|
|
0
|
$vars_href->{$1}; # expand variable |
979
|
|
|
|
|
|
|
} else { |
980
|
0
|
|
|
|
|
0
|
"\${$1}"; # leave it |
981
|
|
|
|
|
|
|
} |
982
|
|
|
|
|
|
|
}egx; |
983
|
|
|
|
|
|
|
|
984
|
0
|
|
|
|
|
0
|
return $string ; |
985
|
|
|
|
|
|
|
} |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
|
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
=item B |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
Use App::Framework::Base::Object::DumpObj to print out variable information. Automatically enables |
994
|
|
|
|
|
|
|
object print out |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
=cut |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
sub prt_data |
999
|
|
|
|
|
|
|
{ |
1000
|
1270
|
|
|
1270
|
1
|
27500
|
my $this = shift ; |
1001
|
1270
|
|
|
|
|
1574
|
my (@args) = @_ ; |
1002
|
|
|
|
|
|
|
|
1003
|
1270
|
|
|
|
|
1978
|
App::Framework::Base::Object::DumpObj::print_objects_flag(1) ; |
1004
|
1270
|
|
|
|
|
2096
|
App::Framework::Base::Object::DumpObj::prt_data(@args) ; |
1005
|
|
|
|
|
|
|
} |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
1008
|
|
|
|
|
|
|
# |
1009
|
|
|
|
|
|
|
#=item B<_dbg_prt($items_aref [, $min_debug])> |
1010
|
|
|
|
|
|
|
# |
1011
|
|
|
|
|
|
|
#Print out the items in the $items_aref ARRAY ref iff the calling object's debug level is >0. |
1012
|
|
|
|
|
|
|
#If $min_debug is specified, will only print out items if the calling object's debug level is >= $min_debug. |
1013
|
|
|
|
|
|
|
# |
1014
|
|
|
|
|
|
|
#=cut |
1015
|
|
|
|
|
|
|
# |
1016
|
|
|
|
|
|
|
sub _dbg_prt |
1017
|
|
|
|
|
|
|
{ |
1018
|
37378
|
|
|
37378
|
|
26508
|
my $obj = shift ; |
1019
|
37378
|
|
|
|
|
27045
|
my ($items_aref, $min_debug) = @_ ; |
1020
|
|
|
|
|
|
|
|
1021
|
37378
|
|
100
|
|
|
50333
|
$min_debug ||= 1 ; |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
## check debug level setting |
1024
|
37378
|
100
|
|
|
|
38763
|
if ($obj->debug >= $min_debug) |
1025
|
|
|
|
|
|
|
{ |
1026
|
1170
|
|
|
|
|
1100
|
my $pkg = ref($obj) ; |
1027
|
1170
|
|
|
|
|
2627
|
$pkg =~ s/App::Framework/ApFw/ ; |
1028
|
|
|
|
|
|
|
|
1029
|
1170
|
|
|
|
|
2408
|
my $prefix = App::Framework::Base::Object::DumpObj::prefix("$pkg :: ") ; |
1030
|
1170
|
|
|
|
|
1784
|
$obj->prt_data(@$items_aref) ; |
1031
|
1170
|
|
|
|
|
2650
|
App::Framework::Base::Object::DumpObj::prefix($prefix) ; |
1032
|
|
|
|
|
|
|
} |
1033
|
|
|
|
|
|
|
} |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
|
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
=item B |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
Print out the call stack. Useful for debug output at a crash site. |
1042
|
|
|
|
|
|
|
=cut |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
sub dump_callstack |
1045
|
|
|
|
|
|
|
{ |
1046
|
12
|
|
|
12
|
1
|
18
|
my $this = shift ; |
1047
|
12
|
|
|
|
|
15
|
my ($package, $filename, $line, $subr, $has_args, $wantarray) ; |
1048
|
12
|
|
|
|
|
11
|
my $i=0 ; |
1049
|
12
|
|
|
|
|
948
|
print "\n-----------------------------------------\n"; |
1050
|
|
|
|
|
|
|
do |
1051
|
12
|
|
|
|
|
25
|
{ |
1052
|
86
|
|
|
|
|
505
|
($package, $filename, $line, $subr, $has_args, $wantarray) = caller($i++) ; |
1053
|
86
|
100
|
|
|
|
187
|
if ($subr) |
1054
|
|
|
|
|
|
|
{ |
1055
|
74
|
|
|
|
|
4334
|
print "$filename :: $subr :: $line\n" ; |
1056
|
|
|
|
|
|
|
} |
1057
|
|
|
|
|
|
|
} |
1058
|
|
|
|
|
|
|
while($subr) ; |
1059
|
12
|
|
|
|
|
678
|
print "-----------------------------------------\n\n"; |
1060
|
|
|
|
|
|
|
} |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
# ============================================================================================ |
1065
|
|
|
|
|
|
|
# PRIVATE METHODS |
1066
|
|
|
|
|
|
|
# ============================================================================================ |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
1069
|
|
|
|
|
|
|
# Set field value |
1070
|
|
|
|
|
|
|
sub ___set |
1071
|
|
|
|
|
|
|
{ |
1072
|
0
|
|
|
0
|
|
0
|
my $this = shift ; |
1073
|
0
|
|
|
|
|
0
|
my ($field, $new_value) = @_ ; |
1074
|
|
|
|
|
|
|
|
1075
|
|
|
|
|
|
|
## NEW |
1076
|
0
|
0
|
|
|
|
0
|
if ($global_debug>=10) |
1077
|
|
|
|
|
|
|
{ |
1078
|
0
|
|
|
|
|
0
|
print "Unexpected ___set($field, $new_value)\n" ; |
1079
|
0
|
|
|
|
|
0
|
$this->dump_callstack() ; |
1080
|
|
|
|
|
|
|
} |
1081
|
|
|
|
|
|
|
## NEW |
1082
|
|
|
|
|
|
|
|
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
#my $class = $this->class() ; |
1085
|
0
|
|
|
|
|
0
|
my $value ; |
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
# Check that field name is valid |
1088
|
|
|
|
|
|
|
## my %field_list = $this->field_list() ; |
1089
|
0
|
|
0
|
|
|
0
|
my $class = ref($this) || $this ; |
1090
|
0
|
|
|
|
|
0
|
my %field_list = (); |
1091
|
0
|
0
|
|
|
|
0
|
%field_list = %{ $FIELD_LIST{$class} } if exists($FIELD_LIST{$class}) ; |
|
0
|
|
|
|
|
0
|
|
1092
|
|
|
|
|
|
|
|
1093
|
0
|
0
|
|
|
|
0
|
if (!exists($field_list{$field})) |
1094
|
|
|
|
|
|
|
{ |
1095
|
|
|
|
|
|
|
## my $class = ref($this) || $this ; |
1096
|
|
|
|
|
|
|
|
1097
|
0
|
0
|
|
|
|
0
|
prt_data("$class : ___set($field) invalid field. Valid fields=", \%field_list) if $global_debug>=5 ; |
1098
|
0
|
0
|
|
|
|
0
|
$this->dump_callstack() if $global_debug>=10 ; |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
# TODO: Do something more useful! |
1101
|
0
|
|
|
|
|
0
|
croak "$class: Attempting to write invalid field $field" ; |
1102
|
|
|
|
|
|
|
} |
1103
|
|
|
|
|
|
|
else |
1104
|
|
|
|
|
|
|
{ |
1105
|
|
|
|
|
|
|
# get existing value |
1106
|
0
|
|
|
|
|
0
|
$value = $this->{$field} ; |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
# write |
1109
|
0
|
|
|
|
|
0
|
$this->{$field} = $new_value ; |
1110
|
|
|
|
|
|
|
} |
1111
|
0
|
0
|
|
|
|
0
|
print " + ___set($field) <= $new_value (was $value)\n" if $global_debug>=5 ; |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
# Return previous value |
1114
|
0
|
|
|
|
|
0
|
return $value ; |
1115
|
|
|
|
|
|
|
} |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
1118
|
|
|
|
|
|
|
# get field value |
1119
|
|
|
|
|
|
|
sub ___get |
1120
|
|
|
|
|
|
|
{ |
1121
|
0
|
|
|
0
|
|
0
|
my $this = shift ; |
1122
|
0
|
|
|
|
|
0
|
my ($field) = @_ ; |
1123
|
|
|
|
|
|
|
|
1124
|
0
|
|
|
|
|
0
|
my $value ; |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
#my $class = $this->class() ; |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
## NEW |
1129
|
0
|
0
|
|
|
|
0
|
if ($global_debug>=10) |
1130
|
|
|
|
|
|
|
{ |
1131
|
0
|
|
|
|
|
0
|
print "Unexpected ___get($field)\n" ; |
1132
|
0
|
|
|
|
|
0
|
$this->dump_callstack() ; |
1133
|
|
|
|
|
|
|
} |
1134
|
|
|
|
|
|
|
## NEW |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
|
1137
|
|
|
|
|
|
|
# Check that field name is valid |
1138
|
|
|
|
|
|
|
## my %field_list = $this->field_list() ; |
1139
|
0
|
|
0
|
|
|
0
|
my $class = ref($this) || $this ; |
1140
|
0
|
|
|
|
|
0
|
my %field_list = (); |
1141
|
0
|
0
|
|
|
|
0
|
%field_list = %{ $FIELD_LIST{$class} } if exists($FIELD_LIST{$class}) ; |
|
0
|
|
|
|
|
0
|
|
1142
|
|
|
|
|
|
|
|
1143
|
0
|
0
|
|
|
|
0
|
if (!exists($field_list{$field})) |
1144
|
|
|
|
|
|
|
{ |
1145
|
|
|
|
|
|
|
## my $class = ref($this) || $this ; |
1146
|
|
|
|
|
|
|
|
1147
|
0
|
0
|
|
|
|
0
|
prt_data("$class : ___get($field) invalid field. Valid fields=", \%field_list) if $global_debug>=5 ; |
1148
|
0
|
|
|
|
|
0
|
prt_data("$class : ___get($field) invalid field. Valid fields=", \%field_list) ; |
1149
|
0
|
0
|
|
|
|
0
|
$this->dump_callstack() if $global_debug>=10 ; |
1150
|
0
|
|
|
|
|
0
|
$this->dump_callstack() ; |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
# TODO: Do something more useful! |
1153
|
0
|
|
|
|
|
0
|
croak "$class: Attempting to access invalid method $field (or read using invalid data accessor)" ; |
1154
|
|
|
|
|
|
|
} |
1155
|
|
|
|
|
|
|
else |
1156
|
|
|
|
|
|
|
{ |
1157
|
|
|
|
|
|
|
# get existing value |
1158
|
0
|
|
|
|
|
0
|
$value = $this->{$field} ; |
1159
|
|
|
|
|
|
|
} |
1160
|
|
|
|
|
|
|
|
1161
|
0
|
0
|
|
|
|
0
|
print " + ___get($field) = $value\n" if $global_debug>=5 ; |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
# Return previous value |
1164
|
0
|
|
|
|
|
0
|
return $value ; |
1165
|
|
|
|
|
|
|
} |
1166
|
|
|
|
|
|
|
|
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
# ============================================================================================ |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
# Autoload handle only field value set/undefine |
1171
|
|
|
|
|
|
|
# Set method = |
1172
|
|
|
|
|
|
|
# Undefine method = undef_ |
1173
|
|
|
|
|
|
|
# |
1174
|
|
|
|
|
|
|
sub AUTOLOAD |
1175
|
|
|
|
|
|
|
{ |
1176
|
0
|
0
|
|
0
|
|
0
|
print "AUTOLOAD ($AUTOLOAD)\n" if $global_debug>=5 ; |
1177
|
|
|
|
|
|
|
|
1178
|
|
|
|
|
|
|
## NEW |
1179
|
0
|
0
|
|
|
|
0
|
if ($global_debug>=10) |
1180
|
|
|
|
|
|
|
{ |
1181
|
0
|
|
|
|
|
0
|
my $caller = (caller())[0] ; |
1182
|
0
|
|
|
|
|
0
|
print "Unexpected AUTOLOAD ($AUTOLOAD) from $caller\n" ; |
1183
|
|
|
|
|
|
|
} |
1184
|
|
|
|
|
|
|
## NEW |
1185
|
|
|
|
|
|
|
|
1186
|
0
|
|
|
|
|
0
|
my $this = shift; |
1187
|
|
|
|
|
|
|
# prt_data("AUTOLOAD ($AUTOLOAD) this=", $this) if $global_debug>=5 ; |
1188
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
#print "$this=",ref($this),"\n"; |
1190
|
0
|
0
|
0
|
|
|
0
|
if (!ref($this)||ref($this)eq'ARRAY') |
1191
|
|
|
|
|
|
|
{ |
1192
|
0
|
|
|
|
|
0
|
croak "AUTOLOAD ($AUTOLOAD) (@_): $this is not a valid object" ; |
1193
|
|
|
|
|
|
|
} |
1194
|
|
|
|
|
|
|
|
1195
|
0
|
|
|
|
|
0
|
$this = $this->check_instance() ; |
1196
|
|
|
|
|
|
|
# prt_data(" + this=", $this) if $global_debug>=5 ; |
1197
|
|
|
|
|
|
|
|
1198
|
0
|
|
|
|
|
0
|
my $name = $AUTOLOAD; |
1199
|
0
|
|
|
|
|
0
|
$name =~ s/.*://; # strip fully-qualified portion |
1200
|
0
|
|
|
|
|
0
|
my $class = $AUTOLOAD; |
1201
|
0
|
|
|
|
|
0
|
$class =~ s/::[^:]+$//; # get class |
1202
|
|
|
|
|
|
|
|
1203
|
0
|
|
|
|
|
0
|
my $type = ref($this) ; |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
# if (!$type) |
1206
|
|
|
|
|
|
|
# { |
1207
|
|
|
|
|
|
|
# # see if there is a class instance object defined |
1208
|
|
|
|
|
|
|
# if ($class->has_class_instance()) |
1209
|
|
|
|
|
|
|
# { |
1210
|
|
|
|
|
|
|
# $this = $class->class_instance() ; |
1211
|
|
|
|
|
|
|
# $type = ref($this) ; |
1212
|
|
|
|
|
|
|
# } |
1213
|
|
|
|
|
|
|
# else |
1214
|
|
|
|
|
|
|
# { |
1215
|
|
|
|
|
|
|
# croak "$this is not an object"; |
1216
|
|
|
|
|
|
|
# } |
1217
|
|
|
|
|
|
|
# } |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
# possibly going to set a new value |
1220
|
0
|
|
|
|
|
0
|
my $set=0; |
1221
|
0
|
|
|
|
|
0
|
my $new_value = shift; |
1222
|
0
|
0
|
|
|
|
0
|
$set = 1 if defined($new_value) ; |
1223
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
# 1st see if this is of the form undef_ |
1225
|
0
|
0
|
|
|
|
0
|
if ($name =~ m/^undef_(\w+)$/) |
1226
|
|
|
|
|
|
|
{ |
1227
|
0
|
|
|
|
|
0
|
$set = 1 ; |
1228
|
0
|
|
|
|
|
0
|
$name = $1 ; |
1229
|
0
|
|
|
|
|
0
|
$new_value = undef ; |
1230
|
|
|
|
|
|
|
} |
1231
|
|
|
|
|
|
|
|
1232
|
0
|
|
|
|
|
0
|
my $value = $this->___get($name); |
1233
|
|
|
|
|
|
|
|
1234
|
0
|
0
|
|
|
|
0
|
if ($set) |
1235
|
|
|
|
|
|
|
{ |
1236
|
0
|
|
|
|
|
0
|
$this->___set($name, $new_value) ; |
1237
|
|
|
|
|
|
|
} |
1238
|
|
|
|
|
|
|
|
1239
|
|
|
|
|
|
|
# Return previous value |
1240
|
0
|
|
|
|
|
0
|
return $value ; |
1241
|
|
|
|
|
|
|
} |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
|
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
# ============================================================================================ |
1246
|
|
|
|
|
|
|
# END OF PACKAGE |
1247
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
=back |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
=cut |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
1; |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
__END__ |