Changeset d2dbac0 for src/World.cpp
- Timestamp:
- Feb 25, 2010, 10:50:54 AM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 244d26
- Parents:
- 0e2a47
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/World.cpp
r0e2a47 rd2dbac0 49 49 mol = new molecule(periode); 50 50 molecules_deprecated->insert(mol); 51 molecules.insert(mol); 51 assert(!molecules.count(currMoleculeId)); 52 molecules[currMoleculeId++] = mol; 52 53 mol->signOn(this); 53 54 return mol; … … 58 59 OBSERVE; 59 60 atom *res = NewAtom(); 61 assert(!atoms.count(currAtomId)); 60 62 res->setId(currAtomId++); 61 63 res->setWorld(this); … … 66 68 int World::registerAtom(atom *atom){ 67 69 OBSERVE; 70 assert(!atoms.count(currAtomId)); 68 71 atom->setId(currAtomId++); 69 72 atom->setWorld(this); … … 107 110 /******************************* Iterators ********************************/ 108 111 109 World::AtomIterator::AtomIterator(){ 110 state = World::get()->atomEnd(); 111 } 112 113 World::AtomIterator::AtomIterator(AtomDescriptor _descr, World* _world) : 114 descr(_descr.get_impl()), 115 world(_world), 116 index(0) 117 { 118 state = world->atoms.begin(); 119 advanceState(); 120 } 121 122 World::AtomIterator::AtomIterator(const AtomIterator& rhs) : 123 state(rhs.state), 124 descr(rhs.descr), 125 index(rhs.index), 126 world(rhs.world) 127 {} 128 129 World::AtomIterator& World::AtomIterator::operator=(const AtomIterator& rhs) 130 { 131 if(&rhs!=this){ 132 state=rhs.state; 133 descr=rhs.descr; 134 index=rhs.index; 135 world=rhs.world; 136 } 137 return *this; 138 } 139 140 World::AtomIterator& World::AtomIterator::operator++(){ 141 ++state; 142 ++index; 143 advanceState(); 144 return *this; 145 } 146 147 World::AtomIterator World::AtomIterator::operator++(int){ 148 AtomIterator res(*this); 149 ++(*this); 150 return res; 151 } 152 153 bool World::AtomIterator::operator==(const AtomIterator& rhs){ 154 return state==rhs.state; 155 } 156 157 bool World::AtomIterator::operator==(const World::AtomList::iterator& rhs){ 158 return state==rhs; 159 } 160 161 bool World::AtomIterator::operator!=(const AtomIterator& rhs){ 162 return state!=rhs.state; 163 } 164 165 bool World::AtomIterator::operator!=(const World::AtomList::iterator& rhs){ 166 return state!=rhs; 167 } 168 169 atom* World::AtomIterator::operator*(){ 170 return (*state).second; 171 } 172 173 void World::AtomIterator::advanceState(){ 174 while((state!=world->atoms.end()) && (!descr->predicate(*state))){ 175 ++state; 176 ++index; 177 } 178 } 179 180 int World::AtomIterator::getCount(){ 181 return index; 182 } 112 /* 113 * Actual Implementation of the iterators can be found in WorldIterators.cpp 114 */ 183 115 184 116 World::AtomIterator World::getAtomIter(AtomDescriptor descr){ … … 186 118 } 187 119 188 World::Atom List::iterator World::atomEnd(){120 World::AtomSet::iterator World::atomEnd(){ 189 121 return atoms.end(); 190 122 } … … 200 132 World::World() : 201 133 currAtomId(0), 134 currMoleculeId(0), 202 135 periode(new periodentafel), 203 136 molecules_deprecated(new MoleculeListClass), 204 atoms() 137 atoms(), 138 molecules() 205 139 { 206 140 molecules_deprecated->signOn(this); … … 211 145 delete molecules_deprecated; 212 146 delete periode; 213 Atom List::iterator iter;147 AtomSet::iterator iter; 214 148 for(iter=atoms.begin();iter!=atoms.end();++iter){ 215 149 DeleteAtom((*iter).second);
Note:
See TracChangeset
for help on using the changeset viewer.