line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GRID::Machine::MakeAccessors; |
2
|
21
|
|
|
21
|
|
6056
|
use strict; |
|
21
|
|
|
|
|
39
|
|
|
21
|
|
|
|
|
713
|
|
3
|
21
|
|
|
21
|
|
110
|
use warnings; |
|
21
|
|
|
|
|
43
|
|
|
21
|
|
|
|
|
979
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
GRID::Machine::MakeAccessors - Home Made "Make accessors" for a Class |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 METHODS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head2 sub make_accessors |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
GRID::Machine::MakeAccessors::make_accessors($package, @legalattributes) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Builds getter-setters for each attribute |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 sub make_constructor |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
GRID::Machine::MakeAccessors::make_constructor($package, %legalattributes) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub make_accessors { # Install getter-setters |
24
|
80
|
|
|
80
|
1
|
219
|
my $package = caller; |
25
|
|
|
|
|
|
|
|
26
|
21
|
|
|
21
|
|
114
|
no strict 'refs'; |
|
21
|
|
|
|
|
45
|
|
|
21
|
|
|
|
|
3269
|
|
27
|
80
|
|
|
|
|
227
|
for my $sub (@_) { |
28
|
1000
|
|
|
|
|
4815
|
*{$package."::$sub"} = sub { |
29
|
0
|
|
|
0
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
$self->{$sub} = shift() if @_; |
32
|
0
|
|
|
|
|
|
return $self->{$sub}; |
33
|
1000
|
|
|
|
|
3075
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub make_constructor { # Install constructor |
38
|
0
|
|
|
0
|
1
|
|
my $package = caller; |
39
|
0
|
|
|
|
|
|
my %legal = @_; |
40
|
|
|
|
|
|
|
|
41
|
21
|
|
|
21
|
|
116
|
no strict 'refs'; |
|
21
|
|
|
|
|
36
|
|
|
21
|
|
|
|
|
4513
|
|
42
|
0
|
|
|
|
|
|
*{$package."::new"} = sub { |
43
|
0
|
|
0
|
0
|
|
|
my $class = shift || die "Error: Provide a class\n"; |
44
|
0
|
|
|
|
|
|
my %args = (%legal, @_); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $a = ""; |
47
|
0
|
0
|
|
|
|
|
die "Illegal arg $a\n" if $a = first { !exists $legal{$_} } keys(%args); |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
bless \%args, $class; |
50
|
0
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |