--- trunk/mdtools/interface_implementation/MakeStamps.cpp 2002/11/14 22:00:44 176 +++ trunk/mdtools/interface_implementation/MakeStamps.cpp 2002/12/05 21:37:51 196 @@ -4,22 +4,51 @@ #include "MakeStamps.hpp" #include "MoleculeStamp.hpp" #include "simError.h" +#ifdef IS_MPI #include "mpiBASS.h" +#endif // is_mpi LinkedMolStamp::~LinkedMolStamp(){ if( mol_stamp != NULL ) delete mol_stamp; if( next != NULL ) delete next; } +void LinkedMolStamp::add( LinkedMolStamp* newbie ){ + + if( next != NULL ) next->add( newbie ); + else{ + next = newbie; + next->setPrev( this ); + } +} + MoleculeStamp* LinkedMolStamp::match( char* id ){ if( mol_stamp != NULL ){ - - if(!strcmp( mol_stamp->getID(), id )) return mol_stamp; - - if( next != NULL ) return next->match( id ); + if(!strcmp( mol_stamp->getID(), id )){ + + // make sure we aren't hiding somebody else with the same name + if(next != NULL ){ + if( next->match( id ) != NULL){ + sprintf( painCave.errMsg, + "Molecule Stamp Error. Two separate of declarations of %s present.\n", + id ); + painCave.isFatal = 1; + simError(); +#ifdef IS_MPI + if( painCave.isEventLoop ){ + if( worldRank == 0 ) mpiInterfaceExit(); + } +#endif //is_mpi + } + else return mol_stamp; + } + else return mol_stamp; + } } + if( next != NULL ) return next->match( id ); + return NULL; } @@ -29,7 +58,7 @@ MakeStamps::MakeStamps(){ my_mols = new LinkedMolStamp*[hash_size]; for( i=0; isetStamp( the_stamp ); - linked_mol->setNext( my_mols[key] ); - my_mols[key] = linked_mol; + my_mols[key]->add( linked_mol ); + }