Changeset 8e1f901


Ignore:
Timestamp:
Mar 30, 2012, 9:16:31 AM (13 years ago)
Author:
Frederik Heber <heber@…>
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:
c67ff9
Parents:
5e6534
git-author:
Frederik Heber <heber@…> (03/21/12 11:41:02)
git-committer:
Frederik Heber <heber@…> (03/30/12 09:16:31)
Message:

molecule uses AtomIdSet now, rename getAtoms -> getAtomIds().

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Fragmentation.cpp

    r5e6534 r8e1f901  
    2727#include "Atom/atom.hpp"
    2828#include "Bond/bond.hpp"
     29#include "Descriptors/MoleculeDescriptor.hpp"
    2930#include "Element/element.hpp"
    3031#include "Element/periodentafel.hpp"
  • src/Graph/DepthFirstSearchAnalysis.cpp

    r5e6534 r8e1f901  
    3232#include "CodePatterns/Verbose.hpp"
    3333#include "Descriptors/AtomDescriptor.hpp"
     34#include "Descriptors/MoleculeDescriptor.hpp"
    3435#include "molecule.hpp"
    3536#include "MoleculeLeafClass.hpp"
  • src/molecule.cpp

    r5e6534 r8e1f901  
    165165/************************** Access to the List of Atoms ****************/
    166166
    167 
    168 molecule::iterator molecule::begin(){
    169   return iterator(atomIds.begin(), FromIdToAtom());
    170 }
    171 
    172 molecule::const_iterator molecule::begin() const{
    173   return const_iterator(atomIds.begin(), FromIdToAtom());
    174 }
    175 
    176 molecule::iterator molecule::end(){
    177   return iterator(atomIds.end(), FromIdToAtom());
    178 }
    179 
    180 molecule::const_iterator molecule::end() const{
    181   return const_iterator(atomIds.end(), FromIdToAtom());
    182 }
    183 
    184 bool molecule::empty() const
    185 {
    186   return (atomIds.empty());
    187 }
    188 
    189 size_t molecule::size() const
    190 {
    191   size_t counter = 0;
    192   for (const_iterator iter = begin(); iter != end (); ++iter)
    193     counter++;
    194   return counter;
    195 }
    196 
    197167molecule::const_iterator molecule::erase( const_iterator loc )
    198168{
     
    222192}
    223193
    224 molecule::const_iterator molecule::find ( atom * key ) const
    225 {
    226   return const_iterator(atomIds.find(key->getId()), FromIdToAtom());
    227 }
    228 
    229194pair<molecule::iterator,bool> molecule::insert ( atom * const key )
    230195{
    231196  OBSERVE;
    232   pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
     197  std::pair<iterator,bool> res = atomIds.insert(key->getId());
    233198  if (res.second) { // push atom if went well
    234199    key->setNr(atomIdPool.getNextId());
    235200    setAtomName(key);
    236201    formula+=key->getType();
    237     return pair<iterator,bool>(iterator(res.first, FromIdToAtom()),res.second);
     202    return res;
    238203  } else {
    239204    return pair<iterator,bool>(end(),res.second);
     
    256221{
    257222  World::AtomComposite vector_of_atoms;
    258 //  std::copy(MyIter(atomIds.begin(), FromIdToAtom()),
    259 //      MyIter(atomIds.end(), FromIdToAtom()),
    260 //      vector_of_atoms.begin());
    261 //  for (MyIter iter = MyIter(atomIds.begin(), FromIdToAtom());
    262 //      iter != MyIter(atomIds.end(), FromIdToAtom());
    263 //      ++iter)
    264223  for (molecule::iterator iter = begin(); iter != end(); ++iter)
    265224    vector_of_atoms.push_back(*iter);
     
    851810      "molecule::isInMolecule() - atom is not designated to be in molecule '"
    852811      +toString(this->getName())+"'.");
    853   molecule::atomIdSet::const_iterator iter = atomIds.find(_atom->getId());
     812  molecule::const_iterator iter = atomIds.find(_atom->getId());
    854813  return (iter != atomIds.end());
    855814}
  • src/molecule.hpp

    r5e6534 r8e1f901  
    2121#include <vector>
    2222
    23 #include <boost/iterator/transform_iterator.hpp>
    24 
    2523#include <string>
    2624
     25#include "AtomIdSet.hpp"
    2726#include "Atom/AtomSet.hpp"
    2827#include "CodePatterns/Cacheable.hpp"
    2928#include "CodePatterns/Observer/Observable.hpp"
    30 #include "CodePatterns/Observer/ObservedIterator.hpp"
    3129#include "Descriptors/AtomIdDescriptor.hpp"
    3230#include "Fragmentation/HydrogenSaturation_enum.hpp"
     
    3634#include "IdPool.hpp"
    3735#include "types.hpp"
    38 
    39 // TODO: Was is the include of MoleculeDescriptor_impl.hpp doing in molecule.hpp
    40 #include "Descriptors/MoleculeDescriptor_impl.hpp"
    4136
    4237/****************************************** forward declarations *****************************/
     
    5954class Shape;
    6055
    61 /******************************** Some definitions for easier reading **********************************/
    62 
    63 struct FromIdToAtom :
    64   public std::unary_function<atom *, atomId_t>
    65 {
    66     atom * operator()(atomId_t id) const {
    67      return World::getInstance().getAtom(AtomById(id));
    68     }
    69 };
    70 
    7156/************************************* Class definitions ****************************************/
    7257
     
    8065
    8166public:
    82   typedef std::set<atomId_t> atomIdSet;
    83   typedef boost::transform_iterator<FromIdToAtom, atomIdSet::iterator, atom *, atomId_t> iterator;
    84   typedef boost::transform_iterator<FromIdToAtom, atomIdSet::const_iterator, const atom *, atomId_t const &> const_iterator;
     67  typedef AtomIdSet::atomIdSet atomIdSet;
     68  typedef AtomIdSet::iterator iterator;
     69  typedef AtomIdSet::const_iterator const_iterator;
    8570
    8671  int MDSteps; //!< The number of MD steps in Trajectories
     
    9782  Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
    9883  moleculeId_t id;
    99   atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
     84  AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
    10085  IdPool<atomId_t, uniqueId> atomIdPool;  //!< pool of internal ids such that way may guarantee uniqueness
    10186
     
    125110  World::AtomComposite getAtomSet() const;
    126111
    127   iterator begin();
    128   const_iterator begin() const;
    129   iterator end();
    130   const_iterator end() const;
    131   bool empty() const;
    132   size_t size() const;
    133   const_iterator find(atom * key) const;
    134   pair<iterator, bool> insert(atom * const key);
     112  // simply pass on all functions to AtomIdSet
     113  iterator begin() {
     114    return atomIds.begin();
     115  }
     116  const_iterator begin() const
     117  {
     118    return atomIds.begin();
     119  }
     120  iterator end()
     121  {
     122    return atomIds.end();
     123  }
     124  const_iterator end() const
     125  {
     126    return atomIds.end();
     127  }
     128  bool empty() const
     129  {
     130    return atomIds.empty();
     131  }
     132  size_t size() const
     133  {
     134    return atomIds.size();
     135  }
     136  const_iterator find(atom * key) const
     137  {
     138    return atomIds.find(key);
     139  }
     140  const atomIdSet & getAtomIds() const {
     141    return atomIds.getAtomIds();
     142  }
     143
     144  std::pair<iterator, bool> insert(atom * const key);
     145
    135146  bool containsAtom(atom* key);
    136147
     
    145156   */
    146157  const_iterator erase(const_iterator loc);
     158
    147159  /** Erase an atom from the list.
    148160   * \note This should only be called by atom::removeFromMolecule(),
Note: See TracChangeset for help on using the changeset viewer.