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.2 by williamc, Mon Apr 10 16:41:04 2000 UTC vs.
Revision 1.1.2.8.2.1 by williamc, Fri Aug 11 14:26:18 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
# Line 22 | Line 23
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 < # nonembeddeddependencies()   : return a list of dependency objects that
26 < #                               are not embedded into the parameters
27 < # save(location)   : Save object to given file
26 > # store(location)   : Save object to given file
27   # restore(location) : Restore object from specified file
28 + # reset()           : Clean out all the features
29 + # equals(toolobj)       : return 1 if the tools correspond in url version etc.
30  
31   package BuildSystem::Tool;
32 + use Utilities::Verbose;
33   require 5.004;
34 + @ISA=qw(Utilities::Verbose);
35  
36   sub new {
37          my $class=shift;
# Line 58 | Line 61 | sub url {
61            :$self->{url};
62   }
63  
64 + sub equals {
65 +        my $self=shift;
66 +        my $tool=shift;
67 +
68 +        my $rv=0;
69 +        if ( ($tool->url() eq $self->url() ) &&
70 +             ($tool->name() eq $self->name() ) &&
71 +             ($tool->version() eq $self->version()) ) {
72 +          $rv=1;
73 +        }
74 +        return $rv;
75 + }
76 +
77 + sub listtype {
78 +        my $self=shift;
79 +        my $type=shift;
80 +
81 +        my @list=();
82 +        foreach $v ( $self->features() ) {
83 +          if ( $self->type($v) eq $type ) {
84 +                push @list, $v;
85 +          }
86 +        }
87 +        return @list;
88 + }
89 +
90   sub type {
91          my $self=shift;
92          my $name=shift;
# Line 87 | Line 116 | sub setfeature {
116          @{$self->{features}{$name}}=@value;
117   }
118  
119 + sub reset {
120 +        my $self=shift;
121 +        undef $self->{features};
122 +        undef $self->{'features_ordered'};
123 +        undef $self->{reqobjs};
124 +        undef $self->{requireposition};
125 + }
126  
127   sub _newfeature {
128          my $self=shift;
# Line 153 | Line 189 | sub dependencies {
189          return @{$self->{recobjs}}
190   }
191  
192 < sub save {
192 > sub store {
193          my $self=shift;
194          my $location=shift;
195  
196          my $fh=FileHandle->new();
197 +        $self->verbose("opening $location for output");
198          $fh->open(">".$location) or die "Unable to open $location for output".
199                                  $!."\n";
200 <        print $fh "_sys:name:".$self->name()."\n";
201 <        print $fh "_sys:version:".$self->version()."\n";
200 >        print $fh "name:".$self->name().":_sys\n";
201 >        print $fh "version:".$self->version().":_sys\n";
202 >        print $fh "url:".$self->url().":_sys\n";
203          foreach $f ( $self->features()) {
204            foreach $val ( $self->getfeature($f) ) {
205 <           print $fh $self->type($f).":".$f.":".$val."\n";
205 >           print $fh $f.":".$val.":".$self->type($f)."\n";
206            }
207          }
208          undef $fh;
# Line 178 | Line 216 | sub restore {
216          $fh->open("<".$location) or die "Unable to open $location for output".
217                                  $!."\n";
218          my ($tool,$type,$variable,$value);
219 +        my @fields;
220          while ( <$fh> ) {
221            chomp;
222            next if /^#/;
223            next if /^\s*$/;
224 <          ($type, $variable, $value)=split /:/;
224 >          @fields=split /:/;
225 >          if ( $_!~/:$/ ) {
226 >            $type=pop @fields;
227 >          }
228 >          else { $type="" };
229 >          $variable=shift @fields;
230 >          $value=join ":",@fields;
231 >          #($variable, $value, $type)=split /:/;
232            next if ( $variable=~/\&/ );
233            $product=~tr[A-Z][a-z];
234            if ( $type eq "_sys" ) {
235 <             if ( can($variable)) {
235 >             if ( $self->can($variable)) {
236                 $self->$variable($value);
237               }
238            }
239            else {
240              $self->addfeature($variable,$value);
241 +            if ( $type ne "" ) {
242 +               $self->type($variable,$type);
243 +            }
244            }
245          }
246          undef $fh;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines