--- trunk/mdtools/interface_implementation/MakeStamps.cpp 2002/12/05 21:37:51 196 +++ trunk/mdtools/interface_implementation/MakeStamps.cpp 2002/12/06 21:20:42 198 @@ -31,7 +31,8 @@ MoleculeStamp* LinkedMolStamp::match( char* id ){ if(next != NULL ){ if( next->match( id ) != NULL){ sprintf( painCave.errMsg, - "Molecule Stamp Error. Two separate of declarations of %s present.\n", + "Molecule Stamp Error. Two separate of declarations of " + "%s present.\n", id ); painCave.isFatal = 1; simError(); @@ -48,7 +49,40 @@ MoleculeStamp* LinkedMolStamp::match( char* id ){ } if( next != NULL ) return next->match( id ); + + return NULL; +} + +LinkedMolStamp* LinkedMolStamp::extract( char* id ){ + + if( mol_stamp != NULL ){ + 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 + } + } + + prev->setNext( next ); + if( next != NULL ) next->setPrev( prev ); + return this; + } + } + if( next != NULL ) return next->extract( id ); + return NULL; } @@ -103,12 +137,12 @@ int MakeStamps::hash( char* text ){ return key; } -MoleculeStamp* MakeStamps::getMolecule( char* the_id ){ +LinkedMolStamp* MakeStamps::extractMolStamp( char* the_id ){ int key; key = hash( the_id ); if( my_mols[key] != NULL ){ - return my_mols[key]->match( the_id ); + return my_mols[key]->extract( the_id ); } return NULL;