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 176 by mmeineke, Thu Nov 14 22:00:44 2002 UTC vs.
Revision 196 by chuckv, Thu Dec 5 21:37:51 2002 UTC

# Line 4 | Line 4
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 29 | 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 94 | Line 123 | void MakeStamps::addMolStamp( MoleculeStamp* the_stamp
123  
124    linked_mol = new LinkedMolStamp;
125    linked_mol->setStamp( the_stamp );
97  linked_mol->setNext( my_mols[key] );
126  
127 <  my_mols[key] = linked_mol;
127 >  my_mols[key]->add( linked_mol );
128 >
129   }
130  
131  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines