--- trunk/mdtools/interface_implementation/MakeStamps.cpp 2002/12/05 18:53:40 195 +++ trunk/mdtools/interface_implementation/MakeStamps.cpp 2002/12/05 21:37:51 196 @@ -13,15 +13,42 @@ LinkedMolStamp::~LinkedMolStamp(){ 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; } @@ -31,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 ); + }