Changeset 97445f for src/Descriptors
- 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, 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)
- Location:
- src/Descriptors
- Files:
-
- 18 edited
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 } -
src/Descriptors/MoleculeDescriptor.hpp
r270bdf r97445f 41 41 // close coupling to the world to allow access 42 42 friend molecule* World::getMolecule(MoleculeDescriptor descriptor); 43 friend const molecule* World::getMolecule(MoleculeDescriptor descriptor) const; 43 44 friend std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor); 45 friend std::vector<const molecule*> World::getAllMolecules(MoleculeDescriptor descriptor) const; 44 46 template <class,class,class> friend class SelectiveIterator; 45 47 template <class,class,class> friend class SelectiveConstIterator; … … 79 81 * forward Method to implementation 80 82 */ 83 const molecule* find() const; 84 85 /** 86 * forward Method to implementation 87 */ 81 88 std::vector<molecule*> findAll(); 89 90 /** 91 * forward Method to implementation 92 */ 93 std::vector<const molecule*> findAll() const; 82 94 83 95 /** -
src/Descriptors/MoleculeDescriptor_impl.hpp
r270bdf r97445f 30 30 * Implement this abstract Method to make a concrete MoleculeDescriptor pick certain Molecules 31 31 */ 32 virtual bool predicate( std::pair<moleculeId_t,molecule*>)=0;32 virtual bool predicate(const std::pair<moleculeId_t,const molecule*>) const=0; 33 33 34 34 protected: … … 43 43 44 44 /** 45 * This method is called when the Descriptor is used to find the first matching 46 * Molecule. Walks through all Molecules and stops on the first match. Can be implemented 47 * when the searched Molecule can be found in a more efficient way. Calculated 48 * Moleculedescriptors will always use this method, so no improvement there. 49 */ 50 virtual const molecule* find() const; 51 52 /** 45 53 * This method is called when the Descriptor is used to find all matching Molecules. 46 54 * Walks through all Molecules and tests the predicate on each one. A vector of all … … 48 56 */ 49 57 virtual std::vector<molecule*> findAll(); 58 59 /** 60 * This method is called when the Descriptor is used to find all matching Molecules. 61 * Walks through all Molecules and tests the predicate on each one. A vector of all 62 * matching Molecules is returned. 63 */ 64 virtual std::vector<const molecule*> findAll() const; 50 65 51 66 /** … … 57 72 World::MoleculeSet& getMolecules(); 58 73 74 /** 75 * This method is used internally to query the Set of Molecules from the world. 76 * By using this method derived classes can also access the Internal World Datastructre. 77 * Implemented in full in the Base Descriptor Implementation, so only this one method 78 * needs to be friend with the World class. 79 */ 80 const World::MoleculeSet& getMolecules() const; 81 59 82 void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>); 83 84 void checkAndAdd(std::vector<const molecule*>*,std::pair<moleculeId_t,const molecule*>) const; 60 85 }; 61 86 … … 73 98 * Always returns true for any Molecule 74 99 */ 75 virtual bool predicate( std::pair<moleculeId_t,molecule*>);100 virtual bool predicate(const std::pair<moleculeId_t,const molecule*>) const; 76 101 }; 77 102 … … 88 113 * Always returns false for any Molecule 89 114 */ 90 virtual bool predicate( std::pair<moleculeId_t,molecule*>);115 virtual bool predicate(const std::pair<moleculeId_t,const molecule*>) const; 91 116 }; 92 117 … … 106 131 * second Descriptor to decide if an Molecule should be selected. 107 132 */ 108 virtual bool predicate( std::pair<moleculeId_t,molecule*>);133 virtual bool predicate(const std::pair<moleculeId_t,const molecule*>) const; 109 134 110 135 private: … … 126 151 * second Descriptor to decide if an Molecule should be selected. 127 152 */ 128 virtual bool predicate( std::pair<moleculeId_t,molecule*>);153 virtual bool predicate(const std::pair<moleculeId_t,const molecule*>) const; 129 154 130 155 private: … … 145 170 * Opposite of the given descriptor predicate. 146 171 */ 147 virtual bool predicate( std::pair<moleculeId_t,molecule*>);172 virtual bool predicate(const std::pair<moleculeId_t,const molecule*>) const; 148 173 149 174 private: -
src/Descriptors/MoleculeFormulaDescriptor.cpp
r270bdf r97445f 48 48 MoleculeFormulaDescriptor_impl::~MoleculeFormulaDescriptor_impl(){} 49 49 50 bool MoleculeFormulaDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){50 bool MoleculeFormulaDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 51 51 return molecule.second->getFormula() == formula; 52 52 } -
src/Descriptors/MoleculeFormulaDescriptor_impl.hpp
r270bdf r97445f 23 23 MoleculeFormulaDescriptor_impl(const Formula &); 24 24 virtual ~MoleculeFormulaDescriptor_impl(); 25 bool predicate( std::pair<moleculeId_t,molecule*> molecule);25 bool predicate(const std::pair<moleculeId_t,const molecule*> molecule) const; 26 26 private: 27 27 Formula formula; -
src/Descriptors/MoleculeIdDescriptor.cpp
r270bdf r97445f 52 52 {} 53 53 54 bool MoleculeIdDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){54 bool MoleculeIdDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 55 55 return molecule.first==id; 56 56 } … … 66 66 } 67 67 68 const molecule *MoleculeIdDescriptor_impl::find() const { 69 const World::MoleculeSet &molecules = getMolecules(); 70 const World::MoleculeSet::const_iterator res = molecules.find(id); 71 return (res!=molecules.end())?((*res).second):0; 72 } 73 68 74 vector<molecule*> MoleculeIdDescriptor_impl::findAll(){ 69 75 molecule *res = find(); 70 76 return (res)?(vector<molecule*>(1,res)):(vector<molecule*>()); 71 77 } 78 79 vector<const molecule*> MoleculeIdDescriptor_impl::findAll() const { 80 const molecule *res = find(); 81 return (res)?(vector<const molecule*>(1,res)):(vector<const molecule*>()); 82 } 83 -
src/Descriptors/MoleculeIdDescriptor_impl.hpp
r270bdf r97445f 16 16 virtual ~MoleculeIdDescriptor_impl(); 17 17 18 bool predicate( std::pair<moleculeId_t,molecule*> molecule);18 bool predicate(const std::pair<moleculeId_t,const molecule*> molecule) const; 19 19 20 20 protected: 21 21 virtual molecule *find(); 22 virtual const molecule *find() const; 22 23 virtual std::vector<molecule*> findAll(); 24 virtual std::vector<const molecule*> findAll() const; 23 25 private: 24 26 moleculeId_t id; -
src/Descriptors/MoleculeNameDescriptor.cpp
r270bdf r97445f 50 50 {} 51 51 52 bool MoleculeNameDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){52 bool MoleculeNameDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 53 53 return molecule.second->name==name; 54 54 } -
src/Descriptors/MoleculeNameDescriptor_impl.hpp
r270bdf r97445f 16 16 virtual ~MoleculeNameDescriptor_impl(); 17 17 18 bool predicate( std::pair<moleculeId_t,molecule*> molecule);18 bool predicate(const std::pair<moleculeId_t,const molecule*> molecule) const; 19 19 20 20 private: -
src/Descriptors/MoleculeOfAtomSelectionDescriptor.cpp
r270bdf r97445f 48 48 MoleculeOfAtomSelectionDescriptor_impl::~MoleculeOfAtomSelectionDescriptor_impl(){} 49 49 50 bool MoleculeOfAtomSelectionDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){50 bool MoleculeOfAtomSelectionDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 51 51 for (molecule::const_iterator iter = molecule.second->begin(); 52 52 iter != molecule.second->end(); … … 70 70 } 71 71 72 const molecule* MoleculeOfAtomSelectionDescriptor_impl::find() const { 73 const World::AtomSet &set = getSelectedAtoms(); 74 for (World::AtomSet::const_iterator iter = set.begin(); 75 iter != set.end(); 76 ++iter) { 77 if (iter->second->getMolecule()) 78 return iter->second->getMolecule(); 79 } 80 return 0; 81 } 82 72 83 std::vector<molecule*> MoleculeOfAtomSelectionDescriptor_impl::findAll(){ 73 84 std::vector<molecule*> res; … … 78 89 iter != set.end_internal(); 79 90 ++iter) { 80 if (iter->second->getMolecule()) { 91 if (iter->second->getMolecule() != NULL) { 92 // get as non-const version 81 93 molecule * const _mol = 82 94 World::getInstance().getMolecule( 83 95 MoleculeById(iter->second->getMolecule()->getId())); 96 inserter = temp.insert( _mol ); 97 if (inserter.second) 98 res.push_back(_mol); 99 } 100 } 101 return res; 102 } 103 104 std::vector<const molecule*> MoleculeOfAtomSelectionDescriptor_impl::findAll() const { 105 std::vector<const molecule*> res; 106 std::set<const molecule*> temp; 107 std::pair< std::set<const molecule*>::iterator, bool> inserter; 108 const World::AtomSet &set = getSelectedAtoms(); 109 for (World::AtomSet::const_iterator iter = set.begin(); 110 iter != set.end(); 111 ++iter) { 112 const molecule * const _mol = iter->second->getMolecule(); 113 if ( _mol != NULL ) { 84 114 inserter = temp.insert( _mol ); 85 115 if (inserter.second) … … 94 124 } 95 125 126 const World::AtomSet& MoleculeOfAtomSelectionDescriptor_impl::getSelectedAtoms() const{ 127 return World::getInstance().selectedAtoms; 128 } 129 96 130 MoleculeDescriptor MoleculesByAtomSelection(){ 97 131 return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeOfAtomSelectionDescriptor_impl())); -
src/Descriptors/MoleculeOfAtomSelectionDescriptor_impl.hpp
r270bdf r97445f 21 21 MoleculeOfAtomSelectionDescriptor_impl(); 22 22 virtual ~MoleculeOfAtomSelectionDescriptor_impl(); 23 bool predicate( std::pair<moleculeId_t,molecule*> molecule);23 bool predicate(const std::pair<moleculeId_t,const molecule*> molecule) const; 24 24 protected: 25 25 // need to overide more than the standard methods to make this fast 26 virtual molecule* find(); 26 virtual molecule *find(); 27 virtual const molecule *find() const; 27 28 virtual std::vector<molecule*> findAll(); 29 virtual std::vector<const molecule*> findAll() const; 28 30 29 31 World::AtomSet& getSelectedAtoms(); 32 const World::AtomSet& getSelectedAtoms() const; 30 33 }; 31 34 -
src/Descriptors/MoleculeOrderDescriptor.cpp
r270bdf r97445f 50 50 {} 51 51 52 bool MoleculeOrderDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> _molecule)52 bool MoleculeOrderDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> _molecule) const 53 53 { 54 molecule *mol = find();54 const molecule *mol = find(); 55 55 return (mol == _molecule.second); 56 56 } … … 61 61 62 62 World::MoleculeSet& MoleculeOrderDescriptor_impl::getMolecules() 63 { 64 return World::getInstance().molecules; 65 } 66 67 const World::MoleculeSet& MoleculeOrderDescriptor_impl::getMolecules() const 63 68 { 64 69 return World::getInstance().molecules; … … 95 100 } 96 101 102 const molecule* MoleculeOrderDescriptor_impl::find() const { 103 const World::MoleculeSet &molecules = getMolecules(); 104 105 int i=0; 106 const molecule *mol = NULL; 107 if (id == 0) { 108 return NULL; 109 } else if (id > 0) { 110 World::MoleculeSet::const_iterator res = molecules.begin(); 111 for (; res != molecules.end(); ++res) { // when iterator is normal, ++ goes forward! 112 ++i; 113 if (id == i) { 114 mol = res->second; 115 break; 116 } 117 } 118 } else { 119 World::MoleculeSet::const_reverse_iterator res = molecules.rbegin(); 120 for (; res != molecules.rend(); ++res) { // when iterator is reverse, ++ goes backward! 121 --i; 122 if (id == i) { 123 mol = res->second; 124 break; 125 } 126 } 127 } 128 129 return mol; 130 } 131 132 97 133 vector<molecule*> MoleculeOrderDescriptor_impl::findAll(){ 98 134 molecule *res = find(); 99 135 return (res)?(vector<molecule*>(1,res)):(vector<molecule*>()); 100 136 } 137 138 vector<const molecule*> MoleculeOrderDescriptor_impl::findAll() const { 139 const molecule *res = find(); 140 return (res)?(vector<const molecule*>(1,res)):(vector<const molecule*>()); 141 } -
src/Descriptors/MoleculeOrderDescriptor_impl.hpp
r270bdf r97445f 16 16 virtual ~MoleculeOrderDescriptor_impl(); 17 17 18 bool predicate( std::pair<moleculeId_t,molecule*> _molecule);18 bool predicate(const std::pair<moleculeId_t,const molecule*> _molecule) const; 19 19 20 20 protected: 21 21 virtual molecule *find(); 22 virtual const molecule *find() const; 22 23 virtual std::vector<molecule*> findAll(); 24 virtual std::vector<const molecule*> findAll() const; 23 25 24 26 World::MoleculeSet& getMolecules(); 27 const World::MoleculeSet& getMolecules() const; 25 28 26 29 private: -
src/Descriptors/MoleculePtrDescriptor.cpp
r270bdf r97445f 45 45 46 46 47 MoleculePtrDescriptor_impl::MoleculePtrDescriptor_impl( molecule * _ptr) :47 MoleculePtrDescriptor_impl::MoleculePtrDescriptor_impl(const molecule * _ptr) : 48 48 ptr(_ptr) 49 49 {} … … 52 52 {} 53 53 54 bool MoleculePtrDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){54 bool MoleculePtrDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 55 55 return molecule.second==ptr; 56 56 } 57 57 58 MoleculeDescriptor MoleculeByPtr( molecule * ptr){58 MoleculeDescriptor MoleculeByPtr(const molecule * ptr){ 59 59 return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculePtrDescriptor_impl(ptr))); 60 60 } -
src/Descriptors/MoleculePtrDescriptor.hpp
r270bdf r97445f 18 18 #include "Descriptors/MoleculeDescriptor.hpp" 19 19 20 MoleculeDescriptor MoleculeByPtr( molecule * ptr);20 MoleculeDescriptor MoleculeByPtr(const molecule * ptr); 21 21 22 22 #endif /* MOLECULEPTRDESCRIPTOR_HPP_ */ -
src/Descriptors/MoleculePtrDescriptor_impl.hpp
r270bdf r97445f 15 15 { 16 16 public: 17 MoleculePtrDescriptor_impl( molecule * ptr);17 MoleculePtrDescriptor_impl(const molecule * ptr); 18 18 virtual ~MoleculePtrDescriptor_impl(); 19 19 20 bool predicate( std::pair<moleculeId_t,molecule*> molecule);20 bool predicate(const std::pair<moleculeId_t,const molecule*> molecule) const; 21 21 22 22 private: 23 molecule * ptr;23 const molecule * ptr; 24 24 }; 25 25 -
src/Descriptors/MoleculeSelectionDescriptor.cpp
r270bdf r97445f 44 44 MoleculeSelectionDescriptor_impl::~MoleculeSelectionDescriptor_impl(){} 45 45 46 bool MoleculeSelectionDescriptor_impl::predicate( std::pair<moleculeId_t,molecule*> molecule){46 bool MoleculeSelectionDescriptor_impl::predicate(const std::pair<moleculeId_t,const molecule*> molecule) const{ 47 47 return getSelectedMolecules().count(molecule.first); 48 48 } … … 52 52 World::MoleculeSet::internal_iterator begin = set.begin_internal(); 53 53 return (begin!=set.end_internal())?(begin->second):0; 54 } 55 56 const molecule* MoleculeSelectionDescriptor_impl::find() const { 57 const World::MoleculeSet &set = getSelectedMolecules(); 58 World::MoleculeSet::const_iterator begin = set.begin(); 59 return (begin!=set.end())?(begin->second):0; 54 60 } 55 61 … … 64 70 } 65 71 72 std::vector<const molecule*> MoleculeSelectionDescriptor_impl::findAll() const { 73 std::vector<const molecule*> res; 74 const World::MoleculeSet &set = getSelectedMolecules(); 75 transform(set.begin(), 76 set.end(), 77 back_inserter(res), 78 _take<molecule*,World::MoleculeSet::value_type>::get); 79 return res; 80 } 81 66 82 World::MoleculeSet& MoleculeSelectionDescriptor_impl::getSelectedMolecules(){ 83 return World::getInstance().selectedMolecules; 84 } 85 86 const World::MoleculeSet& MoleculeSelectionDescriptor_impl::getSelectedMolecules() const{ 67 87 return World::getInstance().selectedMolecules; 68 88 } -
src/Descriptors/MoleculeSelectionDescriptor_impl.hpp
r270bdf r97445f 21 21 MoleculeSelectionDescriptor_impl(); 22 22 virtual ~MoleculeSelectionDescriptor_impl(); 23 bool predicate( std::pair<moleculeId_t,molecule*> molecule);23 bool predicate(const std::pair<moleculeId_t,const molecule*> molecule) const; 24 24 protected: 25 25 // need to overide more than the standard methods to make this fast 26 virtual molecule* find(); 26 virtual molecule *find(); 27 virtual const molecule *find() const; 27 28 virtual std::vector<molecule*> findAll(); 29 virtual std::vector<const molecule*> findAll() const; 28 30 29 31 World::MoleculeSet& getSelectedMolecules(); 32 const World::MoleculeSet& getSelectedMolecules() const; 30 33 }; 31 34
Note:
See TracChangeset
for help on using the changeset viewer.