ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/Globals.cpp
(Generate patch)

Comparing trunk/OOPSE/libBASS/Globals.cpp (file contents):
Revision 655 by mmeineke, Tue Jul 29 16:32:06 2003 UTC vs.
Revision 675 by mmeineke, Mon Aug 11 19:38:44 2003 UTC

# Line 46 | Line 46
46   #define G_TARGETPRESSURE 25
47   #define G_TAUTHERMOSTAT  26
48   #define G_TAUBAROSTAT    27
49 + #define G_ZCONSTIME      28
50 + #define G_NZCONSTRAINTS  29
51  
52  
53   Globals::Globals(){
# Line 86 | Line 88 | Globals::Globals(){
88    addHash( "targetPressure",                       G_TARGETPRESSURE);
89    addHash( "tauThermostat",                        G_TAUTHERMOSTAT);
90    addHash( "tauBarostat",                          G_TAUBAROSTAT);
91 <  
91 >  addHash( "zconsTime",                            G_ZCONSTIME);
92 >  addHash( "nZconstraints",                        G_NZCONSTRAINTS);
93 >
94    // define some default values
95  
96    strcpy( mixingRule,"standard");  //default mixing rules to standard.
# Line 119 | Line 123 | Globals::Globals(){
123    have_target_pressure =0;
124    have_q_mass =         0;
125    have_tau_thermostat = 0;
126 <  have_tau_barostat =   0;
126 >  have_tau_barostat   = 0;
127 >  have_zcon_time     = 0;
128 >  have_n_zConstraints = 0;
129 >  have_zConstraints   = 0;
130   }
131  
132   Globals::~Globals(){
# Line 194 | Line 201 | int Globals::componentAssign( event* the_event ){
201    return 0;
202   }
203  
204 < int Globals::componentStartIndex( event* the_event ){
204 > int Globals::componentEnd( event* the_event ){
205  
206 <  current_component->startIndex( the_event->evt.si.array,
207 <                                 the_event->evt.si.n_elements );
206 >  the_event->err_msg = current_component->checkMe();
207 >  if( the_event->err_msg != NULL ) return 0;
208 >
209    return 1;
210   }
211  
212 < int Globals::componentEnd( event* the_event ){
212 > int Globals::newZconstraint( event* the_event ){
213 >  
214  
215 <  the_event->err_msg = current_component->checkMe();
215 >  int index = the_event->evt.blk_index;
216 >  char err[200];
217 >  current_zConstraint = new ZconStamp( index );
218 >  
219 >  have_zConstraints = 1;
220 >
221 >  if( have_n_zConstraints && index < n_zConstraints )
222 >    zConstraints[index] = current_zConstraint;
223 >  else{
224 >    if( have_n_zConstraints ){
225 >      sprintf( err, "Globals error, %d out of nZconstraints range",
226 >               index );
227 >      the_event->err_msg = strdup( err );
228 >      return 0;
229 >    }
230 >    else{
231 >      the_event->err_msg = strdup("Globals error, nZconstraints"
232 >                                  " not given before"
233 >                                  " first zConstraint declaration." );
234 >      return 0;
235 >    }
236 >  }  
237 >
238 >  return 1;
239 > }
240 >
241 >
242 >
243 > int Globals::zConstraintAssign( event* the_event ){
244 >
245 >  switch( the_event->evt.asmt.asmt_type ){
246 >    
247 >  case STRING:
248 >    return current_zConstraint->assignString( the_event->evt.asmt.lhs,
249 >                                            the_event->evt.asmt.rhs.sval,
250 >                                            &(the_event->err_msg));
251 >    break;
252 >    
253 >  case DOUBLE:
254 >    return current_zConstraint->assignDouble( the_event->evt.asmt.lhs,
255 >                                            the_event->evt.asmt.rhs.dval,
256 >                                            &(the_event->err_msg));
257 >    break;
258 >    
259 >  case INT:
260 >    return current_zConstraint->assignInt( the_event->evt.asmt.lhs,
261 >                                         the_event->evt.asmt.rhs.ival,
262 >                                         &(the_event->err_msg));
263 >    break;
264 >    
265 >  default:
266 >    the_event->err_msg = strdup( "Globals error. Invalid zConstraint"
267 >                                 " assignment type" );
268 >    return 0;
269 >    break;
270 >  }
271 >  return 0;
272 > }
273 >
274 > int Globals::zConstraintEnd( event* the_event ){
275 >
276 >  the_event->err_msg = current_zConstraint->checkMe();
277    if( the_event->err_msg != NULL ) return 0;
278  
279    return 1;
# Line 258 | Line 328 | int Globals::globalAssign( event* the_event ){
328          return 1;
329        }
330        break;
331 +
332 +    case G_NZCONSTRAINTS:
333 +      if( the_type == STRING ){
334 +        the_event->err_msg =
335 +          strdup("Global error. nZconstraints is not a double or an int.\n" );
336 +        return 0;
337 +      }
338        
339 +      else if( the_type == DOUBLE ){
340 +        n_zConstraints = (int)the_event->evt.asmt.rhs.dval;
341 +        zConstraints = new ZconStamp*[n_zConstraints];
342 +        have_n_zConstraints = 1;
343 +        return 1;
344 +      }
345 +      
346 +      else{
347 +        n_zConstraints = the_event->evt.asmt.rhs.ival;
348 +        zConstraints = new ZconStamp*[n_zConstraints];
349 +        have_n_zConstraints = 1;
350 +        return 1;
351 +      }
352 +      break;
353 +      
354      case G_TARGETTEMP:
355        switch( the_type ){
356          
# Line 882 | Line 974 | int Globals::globalAssign( event* the_event ){
974          break;
975        }
976        break;
977 <
977 >      
978 >   case G_ZCONSTIME:
979 >      switch( the_type ){
980 >        
981 >      case STRING:
982 >        the_event->err_msg =
983 >          strdup( "Global error. zcons_time is not a double or int.\n" );
984 >        return 0;
985 >        break;
986 >        
987 >      case DOUBLE:
988 >        zcons_time = the_event->evt.asmt.rhs.dval;
989 >        return 1;
990 >        break;
991 >        
992 >      case INT:
993 >        zcons_time = (double)the_event->evt.asmt.rhs.ival;
994 >        have_zcon_time = 1;
995 >        return 1;
996 >        break;
997 >        
998 >      default:
999 >        the_event->err_msg =
1000 >          strdup( "Global error. zcons_time unrecognized.\n" );
1001 >        return 0;
1002 >        break;
1003 >      }
1004 >      break;
1005 >  
1006  
1007        // add more token cases here.
1008  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines