ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/interface_implementation/MakeStamps.cpp
(Generate patch)

Comparing trunk/mdtools/interface_implementation/MakeStamps.cpp (file contents):
Revision 11 by mmeineke, Tue Jul 9 18:40:59 2002 UTC vs.
Revision 196 by chuckv, Thu Dec 5 21:37:51 2002 UTC

# Line 3 | Line 3
3  
4   #include "MakeStamps.hpp"
5   #include "MoleculeStamp.hpp"
6 + #include "simError.h"
7 + #ifdef IS_MPI
8 + #include "mpiBASS.h"
9 + #endif // is_mpi
10  
11   LinkedMolStamp::~LinkedMolStamp(){
12    if( mol_stamp != NULL ) delete mol_stamp;
13    if( next != NULL ) delete next;
14   }
15  
16 + void LinkedMolStamp::add( LinkedMolStamp* newbie ){
17 +  
18 +  if( next != NULL ) next->add( newbie );
19 +  else{
20 +    next = newbie;
21 +    next->setPrev( this );
22 +  }
23 + }
24 +
25   MoleculeStamp* LinkedMolStamp::match( char* id ){
26  
27    if( mol_stamp != NULL ){
28 <    
29 <    if(!strcmp( mol_stamp->getID(), id )) return mol_stamp;
30 <    
31 <    if( next != NULL ) return next->match( id );
28 >    if(!strcmp( mol_stamp->getID(), id )){
29 >      
30 >      // make sure we aren't hiding somebody else with the same name
31 >      if(next != NULL ){
32 >        if( next->match( id ) != NULL){
33 >          sprintf( painCave.errMsg,
34 >                   "Molecule Stamp Error. Two separate of declarations of %s present.\n",
35 >                   id );
36 >          painCave.isFatal = 1;
37 >          simError();
38 > #ifdef IS_MPI
39 >          if( painCave.isEventLoop ){
40 >            if( worldRank == 0 ) mpiInterfaceExit();
41 >          }
42 > #endif //is_mpi
43 >        }
44 >        else return mol_stamp;
45 >      }
46 >      else  return mol_stamp;
47 >    }
48    }
49    
50 +  if( next != NULL ) return next->match( id );
51 +  
52    return NULL;
53   }
54  
# Line 27 | Line 58 | MakeStamps::MakeStamps(){
58    
59    my_mols = new LinkedMolStamp*[hash_size];
60    for( i=0; i<hash_size; i++ ){
61 <    my_mols[i] = NULL;
61 >    my_mols[i] = new LinkedMolStamp();
62    }
63  
64   }
# Line 58 | Line 89 | int MakeStamps::hash( char* text ){
89  
90      // if the key is less than zero, we've had an overflow error
91  
92 <    fprintf( stderr,
93 <             "There has been an overflow error in the hash key.");
94 <    exit(0);
92 >    sprintf( painCave.errMsg,
93 >             "There has been an overflow error in the MakeStamps hash key.");
94 >    painCave.isFatal = 1;
95 >    simError();
96 > #ifdef IS_MPI
97 >    if( painCave.isEventLoop ){
98 >      if( worldRank == 0 ) mpiInterfaceExit();
99 >    }
100 > #endif //is_mpi
101    }
102    
103    return key;
# Line 86 | Line 123 | void MakeStamps::addMolStamp( MoleculeStamp* the_stamp
123  
124    linked_mol = new LinkedMolStamp;
125    linked_mol->setStamp( the_stamp );
89  linked_mol->setNext( my_mols[key] );
126  
127 <  my_mols[key] = linked_mol;
127 >  my_mols[key]->add( linked_mol );
128 >
129   }
130  
131  
# Line 103 | Line 140 | int MakeStamps::moleculeAssign( event* the_event ){
140    switch( the_event->evt.asmt.asmt_type ){
141      
142    case STRING:
143 <    current_mol->assignString( the_event->evt.asmt.lhs,
144 <                               the_event->evt.asmt.rhs.sval );
108 <    return 1;
143 >    the_event->err_msg = current_mol->assignString( the_event->evt.asmt.lhs,
144 >                                      the_event->evt.asmt.rhs.sval );
145      break;
146  
147    case DOUBLE:
148 <    current_mol->assignDouble( the_event->evt.asmt.lhs,
149 <                               the_event->evt.asmt.rhs.dval );
114 <    return 1;
148 >    the_event->err_msg = current_mol->assignDouble( the_event->evt.asmt.lhs,
149 >                                      the_event->evt.asmt.rhs.dval );
150      break;
151 <
151 >    
152    case INT:
153 <    current_mol->assignInt( the_event->evt.asmt.lhs,
154 <                            the_event->evt.asmt.rhs.ival );
120 <    return 1;
153 >    the_event->err_msg = current_mol->assignInt( the_event->evt.asmt.lhs,
154 >                                   the_event->evt.asmt.rhs.ival );
155      break;
156  
157    default:
# Line 126 | Line 160 | int MakeStamps::moleculeAssign( event* the_event ){
160      return 0;
161      break;
162    }
163 <  return 0;
163 >  if( the_event->err_msg != NULL ) return 0;
164 >  return 1;
165   }
166  
167   int MakeStamps::moleculeEnd( event* the_event ){
# Line 146 | Line 181 | int MakeStamps::newAtom( event* the_event ){
181    the_event->err_msg = current_mol->addAtom( current_atom,
182                                               the_event->evt.blk_index );
183    if( the_event->err_msg != NULL ) return 0;
149
184    return 1;
185   }
186  
# Line 172 | Line 206 | int MakeStamps::atomAssign( event* the_event ){
206    switch( the_event->evt.asmt.asmt_type ){
207      
208    case STRING:
209 <    current_atom->assignString( the_event->evt.asmt.lhs,
210 <                               the_event->evt.asmt.rhs.sval );
209 >    the_event->err_msg =
210 >      current_atom->assignString( the_event->evt.asmt.lhs,
211 >                                  the_event->evt.asmt.rhs.sval );
212 >    if( the_event->err_msg != NULL ) return 0;
213      return 1;
214      break;
215  
216    case DOUBLE:
217 <    current_atom->assignDouble( the_event->evt.asmt.lhs,
218 <                               the_event->evt.asmt.rhs.dval );
219 <    return 1;
217 >    the_event->err_msg =
218 >      current_atom->assignDouble( the_event->evt.asmt.lhs,
219 >                                  the_event->evt.asmt.rhs.dval );
220 >    if( the_event->err_msg != NULL ) return 0;
221 >    return 1;    
222      break;
223  
224    case INT:
225 <    current_atom->assignInt( the_event->evt.asmt.lhs,
226 <                            the_event->evt.asmt.rhs.ival );
225 >    the_event->err_msg =
226 >      current_atom->assignInt( the_event->evt.asmt.lhs,
227 >                               the_event->evt.asmt.rhs.ival );
228 >    if( the_event->err_msg != NULL ) return 0;
229      return 1;
230      break;
231  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines