ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/Tool.pm
(Generate patch)

Comparing COMP/SCRAM/src/BuildSystem/Tool.pm (file contents):
Revision 1.1.2.1 by williamc, Fri Apr 7 08:12:48 2000 UTC vs.
Revision 1.1.2.5 by williamc, Thu Apr 20 11:32:26 2000 UTC

# Line 15 | Line 15
15   # url()         : get set the tool url
16   # features()    : return a list of features defined (ordered in relation to
17   #                       their first definition)
18 + # listtype(type) : return a list of all features of the specified type
19   # addfeature(name,@value) : add value(s) to the named feature
20   # setfeature(name,@value) : set value(s) for the named feature
21   # getfeature(name) : return a list of elements belonging to the named feature
22 + #                       (with embedded dependencies)
23 + # type(name[,type]) : get/set the type associated with a feature
24   # addrequirement() : add a requirement at the current parse position
25   # dependencies()   : return a list of dependency objects
26 + # store(location)   : Save object to given file
27 + # restore(location) : Restore object from specified file
28 + # reset()           : Clean out all the features
29  
30   package BuildSystem::Tool;
31   require 5.004;
# Line 52 | Line 58 | sub url {
58            :$self->{url};
59   }
60  
61 + sub listtype {
62 +        my $self=shift;
63 +        my $type=shift;
64 +
65 +        my @list=();
66 +        foreach $v ( $self->features() ) {
67 +          if ( $self->type($v) eq $type ) {
68 +                push @list, $v;
69 +          }
70 +        }
71 +        return @list;
72 + }
73 +
74 + sub type {
75 +        my $self=shift;
76 +        my $name=shift;
77 +
78 +        if ( @_ ) {
79 +          $self->{featuretypes}{$name}=shift;
80 +        }
81 +        return ((defined $self->{featuretypes}{$name})?
82 +                $self->{featuretypes}{$name}:"");
83 + }
84  
85   sub addfeature {
86          my $self=shift;
# Line 71 | Line 100 | sub setfeature {
100          @{$self->{features}{$name}}=@value;
101   }
102  
103 + sub reset {
104 +        my $self=shift;
105 +        undef $self->{features};
106 +        undef $self->{'features_ordered'};
107 +        undef $self->{reqobjs};
108 +        undef $self->{requireposition};
109 + }
110  
111   sub _newfeature {
112          my $self=shift;
# Line 137 | Line 173 | sub dependencies {
173          return @{$self->{recobjs}}
174   }
175  
176 + sub store {
177 +        my $self=shift;
178 +        my $location=shift;
179 +
180 +        my $fh=FileHandle->new();
181 +        $fh->open(">".$location) or die "Unable to open $location for output".
182 +                                $!."\n";
183 +        print $fh "name:".$self->name().":_sys\n";
184 +        print $fh "version:".$self->version().":_sys\n";
185 +        print $fh "url:".$self->url().":_sys\n";
186 +        foreach $f ( $self->features()) {
187 +          foreach $val ( $self->getfeature($f) ) {
188 +           print $fh $f.":".$val.":".$self->type($f)."\n";
189 +          }
190 +        }
191 +        undef $fh;
192 + }
193 +
194 + sub restore {
195 +        my $self=shift;
196 +        my $location=shift;
197 +
198 +        my $fh=FileHandle->new();
199 +        $fh->open("<".$location) or die "Unable to open $location for output".
200 +                                $!."\n";
201 +        my ($tool,$type,$variable,$value);
202 +        while ( <$fh> ) {
203 +          chomp;
204 +          next if /^#/;
205 +          next if /^\s*$/;
206 +          ($variable, $value, $type)=split /:/;
207 +          next if ( $variable=~/\&/ );
208 +          $product=~tr[A-Z][a-z];
209 +          if ( $type eq "_sys" ) {
210 +             if ( $self->can($variable)) {
211 +               $self->$variable($value);
212 +             }
213 +          }
214 +          else {
215 +            $self->addfeature($variable,$value);
216 +          }
217 +        }
218 +        undef $fh;
219 + }
220 +
221   sub _recordpos {
222          my $self=shift;
223          my $name=shift;
# Line 160 | Line 241 | sub _testpos {
241          }
242          return @rv;
243   }
244 +
245 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines