ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildEnvironment.pm
Revision: 1.1
Committed: Fri Dec 17 11:02:27 1999 UTC (25 years, 4 months ago) by williamc
Content type: text/plain
Branch: MAIN
CVS Tags: V0_19_7, V0_19_6, V0_19_6p1, V0_19_5, SFATEST, V0_19_4, V0_19_4_pre3, V0_19_4_pre2, V0_19_4_pre1, V0_19_3, V0_19_2, V0_19_1, V0_19_0, V0_18_5, V0_18_4, V_18_3_TEST, VO_18_3, V0_18_2, V0_18_1, ProtoEnd
Branch point for: SCRAM_V1_BRANCH, V0_19_4_B
Log Message:
Not tested

File Contents

# User Rev Content
1 williamc 1.1 #
2     # BuildEnvironment.pm
3     #
4     # Originally Written by Christopher Williams
5     #
6     # Description
7     #
8     # Interface
9     # ---------
10     # new() : A new BuildEnvironment object
11     # newenv() :Set the current environment to a copy of the previous one
12     # restoreenv() : Restore the previous environment, deleting the current one
13     # addparam(name, value) : add the value to the variable name
14     # setparam(name, value) : Replace the current value of name with value
15     # getparam(name) : return the value of the parameter as a list
16    
17     package BuildSystem::BuildEnvironment;
18    
19     sub new {
20     my $class=shift;
21     $self={};
22     bless $self, $class;
23     $self->{env}[0]={}; # set up the base environment hash
24     return $self;
25     }
26    
27     sub newenv {
28     my $self=shift;
29     my $oldenv=$#{$self->{env}};
30     my $newenv=$oldenv+1;
31    
32     # create new hash
33     push @{$self->{env}}, {};
34     # copy old hash into new
35     foreach $key ( %{$self->{env}[$oldenv]} ){
36     $self->{env}[$newenv]{$key}=$self->{env}[$oldenv]{$key};
37     }
38     }
39    
40     sub restoreenv {
41     my $self=shift;
42    
43     undef $self->{env}[$#{$self->{env}}];
44     pop @{$self->{env}};
45     }
46    
47     sub addparam {
48     my $self=shift;
49     my $name=shift;
50     my $value=shift;
51    
52     push @{$self->{env}[$#{$self->{env}}]{$name}}, $value;
53    
54     }
55    
56     sub setparam {
57     my $self=shift;
58     my $name=shift;
59     my $value=shift;
60    
61     undef @{$self->{env}[$#{$self->{env}}]{$name}}}
62     $self->addparam($name,$value);
63    
64     }
65    
66     sub getparam {
67     my $self=shift;
68     my $name=shift;
69    
70     return @{$self->{env}[$#{$self->{env}}]{$name}};
71     }