line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::NamedParms; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
21069
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
97
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
BEGIN { |
6
|
2
|
|
|
2
|
|
6802
|
$Class::NamedParms::VERSION = '1.06'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
27
|
|
|
27
|
1
|
4238
|
my $proto = shift; |
13
|
27
|
|
|
|
|
62
|
my $package = __PACKAGE__; |
14
|
27
|
|
|
|
|
33
|
my $class; |
15
|
27
|
100
|
|
|
|
75
|
if (ref($proto)) { |
|
|
100
|
|
|
|
|
|
16
|
1
|
|
|
|
|
3
|
$class = ref($proto); |
17
|
|
|
|
|
|
|
} elsif ($proto) { |
18
|
25
|
|
|
|
|
32
|
$class = $proto; |
19
|
|
|
|
|
|
|
} else { |
20
|
1
|
|
|
|
|
2
|
$class = $package; |
21
|
|
|
|
|
|
|
} |
22
|
27
|
|
|
|
|
68
|
my $self = bless {},$class; |
23
|
|
|
|
|
|
|
|
24
|
27
|
|
|
|
|
41
|
my $vars = {}; |
25
|
27
|
|
|
|
|
66
|
$self->{$package} = $vars; |
26
|
27
|
|
|
|
|
65
|
$vars->{-legal_parms} = {}; |
27
|
27
|
|
|
|
|
66
|
$vars->{-parm_values} = {}; |
28
|
|
|
|
|
|
|
|
29
|
27
|
100
|
|
|
|
75
|
if ($#_ != -1) { |
30
|
22
|
|
|
|
|
50
|
$self->declare(@_); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
27
|
|
|
|
|
97
|
$self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
###################################################################### |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub list_declared_parms { |
39
|
2
|
|
|
2
|
1
|
13
|
my $self = shift; |
40
|
2
|
|
|
|
|
5
|
my $package = __PACKAGE__; |
41
|
2
|
100
|
|
|
|
9
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
42
|
|
|
|
|
|
|
|
43
|
2
|
|
|
|
|
4
|
my @parmnames = keys %{$vars->{-legal_parms}}; |
|
2
|
|
|
|
|
8
|
|
44
|
2
|
|
|
|
|
9
|
return @parmnames; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
###################################################################### |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub list_initialized_parms { |
50
|
4
|
|
|
4
|
1
|
11
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
7
|
my $package = __PACKAGE__; |
53
|
4
|
100
|
|
|
|
14
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
5
|
my @parmnames = keys %{$vars->{-parm_values}}; |
|
4
|
|
|
|
|
15
|
|
56
|
4
|
|
|
|
|
14
|
return @parmnames; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
###################################################################### |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub declare { |
62
|
23
|
|
|
23
|
1
|
35
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
23
|
|
|
|
|
42
|
my @parmnames = @_; |
65
|
|
|
|
|
|
|
|
66
|
23
|
|
|
|
|
24
|
my $package = __PACKAGE__; |
67
|
23
|
100
|
|
|
|
56
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
68
|
|
|
|
|
|
|
|
69
|
23
|
|
|
|
|
38
|
foreach my $parmname (@parmnames) { |
70
|
38
|
|
|
|
|
64
|
$parmname = lc ($parmname); |
71
|
38
|
|
|
|
|
109
|
$vars->{-legal_parms}->{$parmname} = 1; |
72
|
|
|
|
|
|
|
} |
73
|
23
|
|
|
|
|
58
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
###################################################################### |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub undeclare { |
79
|
4
|
|
|
4
|
1
|
471
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
4
|
|
|
|
|
8
|
my $package = __PACKAGE__; |
82
|
4
|
100
|
|
|
|
17
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
9
|
my @parmnames = @_; |
85
|
|
|
|
|
|
|
|
86
|
4
|
|
|
|
|
7
|
foreach my $parmname (@parmnames) { |
87
|
4
|
|
|
|
|
9
|
$parmname = lc ($parmname); |
88
|
4
|
100
|
|
|
|
17
|
unless (CORE::exists $vars->{-legal_parms}->{$parmname}) { |
89
|
2
|
|
|
|
|
11
|
require Carp; |
90
|
2
|
|
|
|
|
259
|
Carp::confess (__PACKAGE__ . "::undeclare() - Attempted to undeclare a parameter name ($parmname) that was never declared\n"); |
91
|
|
|
|
|
|
|
} |
92
|
2
|
|
|
|
|
9
|
delete $vars->{-legal_parms}->{$parmname}; |
93
|
2
|
|
|
|
|
12
|
delete $vars->{-parm_values}->{$parmname}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
###################################################################### |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub exists { |
100
|
6
|
|
|
6
|
1
|
26
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
6
|
|
|
|
|
8
|
my $package = __PACKAGE__; |
103
|
6
|
100
|
|
|
|
16
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
104
|
|
|
|
|
|
|
|
105
|
6
|
|
|
|
|
8
|
my ($parmname) = @_; |
106
|
6
|
|
|
|
|
11
|
$parmname = lc $parmname; |
107
|
6
|
|
|
|
|
19
|
return CORE::exists $vars->{-parm_values}->{$parmname}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
###################################################################### |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub set { |
113
|
20
|
|
|
20
|
1
|
137
|
my $self = shift; |
114
|
|
|
|
|
|
|
|
115
|
20
|
|
|
|
|
12117
|
my $parm_ref; |
116
|
20
|
100
|
|
|
|
74
|
if ($#_ == 0) { |
|
|
100
|
|
|
|
|
|
117
|
16
|
|
|
|
|
27
|
$parm_ref = shift; |
118
|
|
|
|
|
|
|
} elsif ($#_ > 0) { |
119
|
2
|
|
|
|
|
8
|
$parm_ref = { @_ }; |
120
|
|
|
|
|
|
|
} else { |
121
|
2
|
|
|
|
|
5
|
$parm_ref = {}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
20
|
|
|
|
|
27
|
my $package = __PACKAGE__; |
125
|
20
|
100
|
|
|
|
53
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
126
|
|
|
|
|
|
|
|
127
|
20
|
|
|
|
|
89
|
my @parmnames = keys %$parm_ref; |
128
|
20
|
|
|
|
|
37
|
foreach my $parmname (@parmnames) { |
129
|
28
|
|
|
|
|
46
|
my $keyname = lc ($parmname); |
130
|
28
|
|
|
|
|
42
|
my $value = $parm_ref->{$parmname}; |
131
|
28
|
100
|
|
|
|
86
|
unless (CORE::exists $vars->{-legal_parms}->{$keyname}) { |
132
|
2
|
|
|
|
|
24
|
require Carp; |
133
|
2
|
|
|
|
|
732
|
Carp::confess (__PACKAGE__ . "::set() - Attempted to set an undeclared named parameter: '$keyname'\n"); |
134
|
|
|
|
|
|
|
} |
135
|
26
|
|
|
|
|
88
|
$vars->{-parm_values}->{$keyname} = $value; |
136
|
|
|
|
|
|
|
} |
137
|
18
|
|
|
|
|
73
|
return; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
###################################################################### |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub clear { |
143
|
4
|
|
|
4
|
1
|
26
|
my $self = shift; |
144
|
|
|
|
|
|
|
|
145
|
4
|
|
|
|
|
33
|
my @parmnames = @_; |
146
|
|
|
|
|
|
|
|
147
|
4
|
|
|
|
|
7
|
my $package = __PACKAGE__; |
148
|
4
|
100
|
|
|
|
15
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
149
|
|
|
|
|
|
|
|
150
|
4
|
|
|
|
|
8
|
foreach my $parmname (@parmnames) { |
151
|
4
|
|
|
|
|
11
|
my $keyname = lc ($parmname); |
152
|
4
|
100
|
|
|
|
17
|
unless (CORE::exists $vars->{-legal_parms}->{$keyname}) { |
153
|
2
|
|
|
|
|
23
|
require Carp; |
154
|
2
|
|
|
|
|
299
|
Carp::confess (__PACKAGE__ . "::clear() - Attempted to clear an undeclared named parameter: '$keyname'\n"); |
155
|
|
|
|
|
|
|
} |
156
|
2
|
|
|
|
|
8
|
$vars->{-parm_values}->{$keyname} = undef; |
157
|
|
|
|
|
|
|
} |
158
|
2
|
|
|
|
|
7
|
return; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
###################################################################### |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub get { |
164
|
24
|
|
|
24
|
1
|
548
|
my $self = shift; |
165
|
|
|
|
|
|
|
|
166
|
24
|
100
|
|
|
|
67
|
if ($#_ == -1) { |
167
|
2
|
|
|
|
|
14
|
require Carp; |
168
|
2
|
|
|
|
|
309
|
Carp::confess(__PACKAGE__ . "::get() - Called without any parameters\n"); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
22
|
|
|
|
|
30
|
my $package = __PACKAGE__; |
172
|
22
|
100
|
|
|
|
53
|
my $vars = $self->{$package} ? $self->{$package} : $self; |
173
|
|
|
|
|
|
|
|
174
|
22
|
|
|
|
|
36
|
my @results = (); |
175
|
22
|
|
|
|
|
39
|
foreach (@_) { |
176
|
30
|
|
|
|
|
47
|
my $keyname = lc ($_); |
177
|
30
|
100
|
|
|
|
93
|
unless (CORE::exists $vars->{-parm_values}->{$keyname}) { |
178
|
6
|
|
|
|
|
46
|
require Carp; |
179
|
6
|
|
|
|
|
949
|
Carp::confess (__PACKAGE__ . "::get() - Attempted to retrieve an undeclared or unitialized named parameter: '$keyname'\n"); |
180
|
|
|
|
|
|
|
} |
181
|
24
|
|
|
|
|
68
|
push (@results,$vars->{-parm_values}->{$keyname}); |
182
|
|
|
|
|
|
|
} |
183
|
16
|
100
|
|
|
|
41
|
if (wantarray) { |
184
|
2
|
|
|
|
|
10
|
return @results; |
185
|
|
|
|
|
|
|
} |
186
|
14
|
|
|
|
|
46
|
return $results[$#results]; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
################################################################ |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub all_parms { |
192
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
193
|
|
|
|
|
|
|
|
194
|
2
|
|
|
|
|
9
|
my @parm_list = $self->list_initialized_parms; |
195
|
2
|
|
|
|
|
5
|
my $all_p = {}; |
196
|
2
|
|
|
|
|
5
|
foreach my $parm (@parm_list) { |
197
|
4
|
|
|
|
|
11
|
$all_p->{$parm} = $self->get($parm); |
198
|
|
|
|
|
|
|
} |
199
|
2
|
|
|
|
|
7
|
return $all_p; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
################################################################# |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |