1 |
williamc |
1.1 |
#
|
2 |
|
|
# BuildClass.pm
|
3 |
|
|
#
|
4 |
|
|
# Originally Written by Christopher Williams
|
5 |
|
|
#
|
6 |
|
|
# Description
|
7 |
|
|
#
|
8 |
|
|
# Interface
|
9 |
|
|
# ---------
|
10 |
|
|
# new() : A new BuildClass object
|
11 |
|
|
# child() : return a new object that is a copy of the object
|
12 |
|
|
# paramupdate($hashref) : update variable hash according to provided hashref
|
13 |
|
|
# paramlist() : return a list of all params that have been set
|
14 |
|
|
# param(name) : return value of given param - undef if undefined
|
15 |
|
|
|
16 |
|
|
package BuildSystem::BuildClass;
|
17 |
|
|
require 5.004;
|
18 |
|
|
|
19 |
|
|
sub new {
|
20 |
|
|
my $class=shift;
|
21 |
|
|
my $type=ref($class) || $class;
|
22 |
|
|
my $self={};
|
23 |
|
|
bless $self, $type;
|
24 |
|
|
return $self;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
sub child {
|
28 |
|
|
my $self=shift;
|
29 |
|
|
my $child=$self->new();
|
30 |
|
|
$child->paramupdate($self->{vars});
|
31 |
|
|
return $child;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
sub paramlist {
|
35 |
|
|
my $self=shift;
|
36 |
|
|
return (keys %{$self->{vars}});
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
sub param {
|
40 |
|
|
my $self=shift;
|
41 |
|
|
my $name=shift;
|
42 |
|
|
|
43 |
|
|
my $rv=undef;
|
44 |
|
|
if ( exists $self->{vars}{$name} ) {
|
45 |
|
|
$rv=$self->{vars}{$name};
|
46 |
|
|
}
|
47 |
|
|
return $rv;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
sub paramupdate {
|
51 |
|
|
my $self=shift;
|
52 |
|
|
my $hashref=shift;
|
53 |
|
|
|
54 |
|
|
foreach $key ( %$hashref ) {
|
55 |
|
|
$self->{vars}{$key}=$$hashref{$key};
|
56 |
|
|
}
|
57 |
|
|
}
|