Changeset 6e97e5 for src/World.hpp


Ignore:
Timestamp:
Mar 17, 2010, 3:19:56 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
229e3c
Parents:
745a85
git-author:
Tillmann Crueger <crueger@…> (03/17/10 14:53:26)
git-committer:
Tillmann Crueger <crueger@…> (03/17/10 15:19:56)
Message:

Added a generic Iterator that can be used to iterate only over certain parts of an internal data structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/World.hpp

    r745a85 r6e97e5  
    1717
    1818#include "types.hpp"
     19#include "Descriptors/SelectiveIterator.hpp"
    1920#include "Patterns/Observer.hpp"
    2021#include "Patterns/Cacheable.hpp"
     
    160161
    161162  // Atoms
    162 
    163   class AtomIterator :
    164     public std::iterator<std::iterator_traits<AtomSet::iterator>::difference_type,
    165                          std::iterator_traits<AtomSet::iterator>::value_type,
    166                          std::iterator_traits<AtomSet::iterator>::pointer,
    167                          std::iterator_traits<AtomSet::iterator>::reference>
    168   {
    169   public:
    170 
    171     typedef AtomSet::iterator _Iter;
    172     typedef _Iter::value_type value_type;
    173     typedef _Iter::difference_type difference_type;
    174     typedef _Iter::pointer pointer;
    175     typedef _Iter::reference reference;
    176     typedef _Iter::iterator_category iterator_category;
    177 
    178 
    179     AtomIterator();
    180     AtomIterator(AtomDescriptor, World*);
    181     AtomIterator(const AtomIterator&);
    182     AtomIterator& operator=(const AtomIterator&);
    183     AtomIterator& operator++();     // prefix
    184     AtomIterator  operator++(int);  // postfix with dummy parameter
    185     bool operator==(const AtomIterator&);
    186     bool operator==(const AtomSet::iterator&);
    187     bool operator!=(const AtomIterator&);
    188     bool operator!=(const AtomSet::iterator&);
    189     atom* operator*();
    190 
    191     int getCount();
    192   protected:
    193     void advanceState();
    194     AtomSet::iterator state;
    195     boost::shared_ptr<AtomDescriptor_impl>  descr;
    196     int index;
    197 
    198     World* world;
    199   };
     163  typedef SelectiveIterator<atom*,AtomSet,AtomDescriptor> AtomIterator;
    200164
    201165  /**
     
    211175   * used for internal purposes, like AtomProcesses and AtomCalculations.
    212176   */
    213   AtomSet::iterator atomEnd();
     177  AtomIterator atomEnd();
    214178
    215179  // Molecules
    216180
    217   class MoleculeIterator :
    218     public std::iterator<std::iterator_traits<MoleculeSet::iterator>::difference_type,
    219                          std::iterator_traits<MoleculeSet::iterator>::value_type,
    220                          std::iterator_traits<MoleculeSet::iterator>::pointer,
    221                          std::iterator_traits<MoleculeSet::iterator>::reference>
    222   {
    223   public:
    224 
    225     typedef MoleculeSet::iterator _Iter;
    226     typedef _Iter::value_type value_type;
    227     typedef _Iter::difference_type difference_type;
    228     typedef _Iter::pointer pointer;
    229     typedef _Iter::reference reference;
    230     typedef _Iter::iterator_category iterator_category;
    231 
    232     MoleculeIterator();
    233     MoleculeIterator(MoleculeDescriptor, World*);
    234     MoleculeIterator(const MoleculeIterator&);
    235     MoleculeIterator& operator=(const MoleculeIterator&);
    236     MoleculeIterator& operator++();     // prefix
    237     MoleculeIterator  operator++(int);  // postfix with dummy parameter
    238     bool operator==(const MoleculeIterator&);
    239     bool operator==(const MoleculeSet::iterator&);
    240     bool operator!=(const MoleculeIterator&);
    241     bool operator!=(const MoleculeSet::iterator&);
    242     molecule* operator*();
    243 
    244     int getCount();
    245   protected:
    246     void advanceState();
    247     MoleculeSet::iterator state;
    248     boost::shared_ptr<MoleculeDescriptor_impl>  descr;
    249     int index;
    250 
    251     World* world;
    252   };
     181  typedef SelectiveIterator<molecule*,MoleculeSet,MoleculeDescriptor> MoleculeIterator;
    253182
    254183  /**
     
    264193   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
    265194   */
    266   MoleculeSet::iterator moleculeEnd();
     195  MoleculeIterator moleculeEnd();
    267196
    268197
     
    277206
    278207  periodentafel *periode;
     208public:
    279209  AtomSet atoms;
     210private:
    280211  std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
    281212  atomId_t currAtomId; //!< stores the next available Id for atoms
Note: See TracChangeset for help on using the changeset viewer.