Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.cpp

    r244d26 r24a5e0  
    4747  OBSERVE;
    4848  molecule *mol = NULL;
    49   mol = new molecule(periode);
    50   molecules_deprecated->insert(mol);
     49  mol = NewMolecule();
    5150  assert(!molecules.count(currMoleculeId));
     51  mol->setId(currMoleculeId++);
    5252  // store the molecule by ID
    53   molecules[currMoleculeId++] = mol;
     53  molecules[mol->getId()] = mol;
    5454  mol->signOn(this);
    5555  return mol;
     56}
     57
     58void World::destroyMolecule(molecule* mol){
     59  OBSERVE;
     60  destroyMolecule(mol->getId());
     61}
     62
     63void World::destroyMolecule(moleculeId_t id){
     64  OBSERVE;
     65  molecule *mol = molecules[id];
     66  assert(mol);
     67  DeleteMolecule(mol);
     68  molecules.erase(id);
    5669}
    5770
     
    8396}
    8497
    85 void World::destroyAtom(int id) {
     98void World::destroyAtom(atomId_t id) {
    8699  OBSERVE;
    87100  atom *atom = atoms[id];
     
    131144
    132145World::World() :
     146    periode(new periodentafel),
     147    atoms(),
    133148    currAtomId(0),
     149    molecules(),
    134150    currMoleculeId(0),
    135     periode(new periodentafel),
    136     molecules_deprecated(new MoleculeListClass),
    137     atoms(),
    138     molecules()
     151    molecules_deprecated(new MoleculeListClass(this))
    139152{
    140153  molecules_deprecated->signOn(this);
     
    145158  delete molecules_deprecated;
    146159  delete periode;
    147   AtomSet::iterator iter;
    148   for(iter=atoms.begin();iter!=atoms.end();++iter){
    149     DeleteAtom((*iter).second);
     160  MoleculeSet::iterator molIter;
     161  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
     162    DeleteMolecule((*molIter).second);
     163  }
     164  molecules.clear();
     165  AtomSet::iterator atIter;
     166  for(atIter=atoms.begin();atIter!=atoms.end();++atIter){
     167    DeleteAtom((*atIter).second);
    150168  }
    151169  atoms.clear();
     
    188206  // should see that it gets the updated new world
    189207  delete oldWorld;
     208  return theWorld;
    190209}
    191210
Note: See TracChangeset for help on using the changeset viewer.