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

Comparing COMP/SCRAM/src/ActiveDoc/Query.pm (file contents):
Revision 1.2 by williamc, Fri Dec 17 08:36:23 1999 UTC vs.
Revision 1.4 by williamc, Thu Jan 6 13:21:55 2000 UTC

# Line 18 | Line 18
18   #                       query
19   # queryprompt(name)  : return/set the prompt string for the query
20   # queryoptions(name) : return/set the query option list for the named query
21 + # querycheck(name)   : return/set the query checker object
22   # currentvalue(name) : return the current value of the query list exapnded
23   #                       in the context of the other query values - affected
24   #                        by lodgevalue.
# Line 25 | Line 26
26   #                  affected by lodgevalue until OK called.
27   # setparam(name,value) : set the value of a given query to list
28   # setifundef(name,value) : set the value of a given query to list
29 < # expand(@string)        : expand given strings
29 > # expand(string)         : expand given string
30   # lodgevalue(name,val)   : set a value of a given query variable to the list
31   #                          current value will be expanded in terms of these
32 + #                          return (pass/fail,messageobject,new_vals_in_options)
33   # OK()                   : set all query values to the values of the lodged
34   #                          variables
35   # cancel()               : clear the values of any lodged variables
36   # setparam(name,value)   : hard set
37   # params                 : return list of all parameters
38 + # runchecker(name,value) : run a query checker to analyse a value, any
39 + #                          return values are added to the option list
40  
41   package ActiveDoc::Query;
42   require 5.004;
# Line 59 | Line 63 | sub intro {
63   sub querytype {
64          my $self=shift;
65          my $name=shift;
66 +        my $rv;
67  
68 <        @_?$self->{querytype}{$name}=shift
69 <          :$self->{querytype}{$name};
68 >        if ( @_) {
69 >             $rv=shift;
70 >             if ( ! exists $self->{querytype}{$name} ) {
71 >                # store the order in which definitions are made
72 >                push @{$self->{queryorder}}, $name;
73 >             }
74 >             $self->{querytype}{$name}=$rv;
75 >        }
76 >        else {
77 >          $rv=$self->{querytype}{$name};
78 >        }
79 >        return $rv;
80 >        
81 > }
82 >
83 > sub querycheck {
84 >        my $self=shift;
85 >        my $name=shift;
86 >
87 >        @_?$self->{querycheck}{$name}=shift
88 >          :$self->{querycheck}{$name};
89   }
90  
91   sub querymessage {
# Line 79 | Line 103 | sub queryprompt {
103          my $rv=undef;
104          if ( @_ ) {
105            $self->{queryprompt}{$name}=shift;
106 <          $rv=$self->{queryprompt}{$name};
107 <        } elsif ( defined $self->{queryprompt}{$name} ) {
84 <          $rv=$self->expand($self->{queryprompt}{$name});
106 >        } elsif ( ! defined $self->{queryprompt}{$name} ) {
107 >          $self->{queryprompt}{$name}="";
108          }
109 +        $rv=$self->expand($self->{queryprompt}{$name});
110          return $rv;            
111   }
112  
# Line 143 | Line 167 | sub getparam {
167   sub lodgevalue {
168          my $self=shift;
169          my $name=shift;
170 +        my $value=shift;
171  
172 <        $self->{lodgehash}{$name}=shift;
172 >        # pass this parameter to the checker
173 >        my ($ret,$message,@vals)=$self->runchecker($name,$value);
174 >        # only lodge the value if its valid
175 >        if ( $ret eq 0 ) {
176 >          $self->{lodgehash}{$name}=$value;
177 >        }
178 >        return ($ret,$message,@vals);
179 > }
180 >
181 > sub runchecker {
182 >        my $self=shift;
183 >        my $name=shift;
184 >        my $value=shift;
185 >        my $ret=0;
186 >        my $message;
187 >        my @vals=();
188 >
189 >        if (defined $self->querycheck($name)) {
190 >          ($ret,$message,@vals)=$self->querycheck($name)->consider($value);
191 >          # add any analysis options to the option list
192 >          if ( $#vals >= 0 ) {
193 >           $self->queryoptions($name,@vals);
194 >          }
195 >        }
196 >        return ($ret,$message,@vals);
197   }
198  
199   sub OK {
# Line 157 | Line 206 | sub OK {
206  
207   sub querylist {
208          my $self=shift;
209 <        return ( keys %{$self->{querytype}});
209 >        return @{$self->{queryorder}};
210   }
211  
212   sub cancel {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines