Changeset 97445f for src/Descriptors/MoleculeDescriptor.cpp
- Timestamp:
- Jul 24, 2015, 4:44:34 PM (10 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, Candidate_v1.7.0, 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:
- 795c0f
- Parents:
- 270bdf
- git-author:
- Frederik Heber <heber@…> (06/01/15 07:42:00)
- git-committer:
- Frederik Heber <heber@…> (07/24/15 16:44:34)
- File:
-
- 1 edited
-
src/Descriptors/MoleculeDescriptor.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Descriptors/MoleculeDescriptor.cpp
r270bdf r97445f 49 49 50 50 typedef World::MoleculeSet::internal_iterator molecules_iter_t; 51 typedef World::MoleculeSet::const_iterator const_molecules_iter_t; 51 52 52 53 /************************ Forwarding object **************************************/ … … 75 76 } 76 77 78 const molecule* MoleculeDescriptor::find() const { 79 return const_cast<const impl_t &>(*impl).find(); 80 } 81 77 82 std::vector<molecule*> MoleculeDescriptor::findAll(){ 78 83 return impl->findAll(); 79 84 } 80 85 86 std::vector<const molecule*> MoleculeDescriptor::findAll() const{ 87 return const_cast<const impl_t &>(*impl).findAll(); 88 } 89 81 90 MoleculeDescriptor::impl_ptr MoleculeDescriptor::get_impl() const{ 82 91 return impl; … … 100 109 } 101 110 111 const World::MoleculeSet& MoleculeDescriptor_impl::getMolecules() const{ 112 return World::getInstance().molecules; 113 } 114 102 115 molecule* MoleculeDescriptor_impl::find() { 103 116 World::MoleculeSet &molecules = getMolecules(); 104 molecules_iter_t res = find_if(molecules.begin_internal(),molecules.end_internal(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1)); 117 molecules_iter_t res = find_if( 118 molecules.begin_internal(),molecules.end_internal(), 119 boost::bind(&MoleculeDescriptor_impl::predicate, 120 this,_1)); 105 121 return (res!=molecules.end_internal())?((*res).second):0; 122 } 123 124 const molecule* MoleculeDescriptor_impl::find() const { 125 const World::MoleculeSet &molecules = getMolecules(); 126 const_molecules_iter_t res = find_if( 127 molecules.begin(),molecules.end(), 128 boost::bind(&MoleculeDescriptor_impl::predicate, 129 this,_1)); 130 return (res!=molecules.end())?((*res).second):0; 106 131 } 107 132 … … 111 136 for_each(molecules.begin_internal(), 112 137 molecules.end_internal(), 113 boost::bind(&MoleculeDescriptor_impl::checkAndAdd, 114 this,&res,_1)); 138 boost::bind(static_cast<void (MoleculeDescriptor_impl::*)( 139 std::vector<molecule*> *, 140 std::pair<moleculeId_t,molecule*>)>(&MoleculeDescriptor_impl::checkAndAdd), 141 this,boost::cref(&res),_1)); 115 142 return res; 116 143 } 117 144 118 void MoleculeDescriptor_impl::checkAndAdd(std::vector<molecule*> *v,std::pair<moleculeId_t,molecule*> p){ 145 vector<const molecule*> MoleculeDescriptor_impl::findAll() const { 146 vector<const molecule*> res; 147 const World::MoleculeSet &molecules = getMolecules(); 148 for_each(molecules.begin(), 149 molecules.end(), 150 boost::bind(static_cast<void (MoleculeDescriptor_impl::*)( 151 std::vector<const molecule*> *, 152 std::pair<moleculeId_t,const molecule*>) const>(&MoleculeDescriptor_impl::checkAndAdd), 153 boost::cref(this),&res,_1)); 154 return res; 155 } 156 157 void MoleculeDescriptor_impl::checkAndAdd( 158 std::vector<molecule*> *v, 159 std::pair<moleculeId_t,molecule*> p){ 119 160 if(predicate(p)){ 120 161 v->push_back(p.second); … … 122 163 } 123 164 165 void MoleculeDescriptor_impl::checkAndAdd( 166 std::vector<const molecule*> *v, 167 std::pair<moleculeId_t,const molecule*> p) const{ 168 if(predicate(p)){ 169 v->push_back(p.second); 170 } 171 } 172 124 173 /************************** Universe and Emptyset *****************/ 125 174 … … 130 179 {} 131 180 132 bool MoleculeAllDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*>){181 bool MoleculeAllDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*>) const{ 133 182 return true; 134 183 } … … 144 193 {} 145 194 146 bool MoleculeNoneDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*>){195 bool MoleculeNoneDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*>) const{ 147 196 return false; 148 197 } … … 162 211 {} 163 212 164 bool MoleculeAndDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){213 bool MoleculeAndDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 165 214 return lhs->predicate(molecule) && rhs->predicate(molecule); 166 215 } … … 178 227 } 179 228 180 bool MoleculeOrDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){229 bool MoleculeOrDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 181 230 return lhs->predicate(molecule) || rhs->predicate(molecule); 182 231 } … … 198 247 } 199 248 200 bool MoleculeNotDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){249 bool MoleculeNotDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 201 250 return !(arg->predicate(molecule)); 202 251 }
Note:
See TracChangeset
for help on using the changeset viewer.
