Changeset 1259df for src/Descriptors


Ignore:
Timestamp:
Jul 24, 2015, 4:44:34 PM (9 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:
f01769
Parents:
63fb7a
git-author:
Frederik Heber <heber@…> (06/01/15 08:56:36)
git-committer:
Frederik Heber <heber@…> (07/24/15 16:44:34)
Message:

Replaced World::getAllMolecules() wherever possible by const version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Descriptors/unittests/MoleculeDescriptorUnitTest.cpp

    r63fb7a r1259df  
    7070
    7171// some helper functions
    72 static bool hasAllMolecules(std::vector<molecule*> molecules,moleculeId_t ids[MOLECULE_COUNT], std::set<moleculeId_t> excluded = std::set<moleculeId_t>()){
     72static bool hasAllMolecules(
     73    std::vector<const molecule*> &molecules,
     74    moleculeId_t ids[MOLECULE_COUNT],
     75    std::set<moleculeId_t> excluded = std::set<moleculeId_t>())
     76{
    7377  for(int i=0;i<MOLECULE_COUNT;++i){
    7478    moleculeId_t id = ids[i];
    7579    if(!excluded.count(id)){
    76       std::vector<molecule*>::iterator iter;
     80      std::vector<const molecule*>::const_iterator iter;
    7781      bool res=false;
    7882      for(iter=molecules.begin();iter!=molecules.end();++iter){
     
    8892}
    8993
    90 static bool hasNoDuplicateMolecules(std::vector<molecule*> molecules){
     94static bool hasNoDuplicateMolecules(std::vector<const molecule*> &molecules){
    9195  std::set<moleculeId_t> found;
    92   std::vector<molecule*>::iterator iter;
     96  std::vector<const molecule*>::const_iterator iter;
    9397  for(iter=molecules.begin();iter!=molecules.end();++iter){
    9498    int id = (*iter)->getId();
     
    102106
    103107void MoleculeDescriptorTest::MoleculeBaseSetsTest(){
    104   std::vector<molecule*> allMolecules = World::getInstance().getAllMolecules(AllMolecules());
     108  std::vector<const molecule*> allMolecules =
     109      const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules());
    105110  CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(allMolecules,moleculeIds));
    106111  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(allMolecules));
    107112
    108   std::vector<molecule*> noMolecules = World::getInstance().getAllMolecules(NoMolecules());
     113  std::vector<const molecule*> noMolecules =
     114      const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules());
    109115  CPPUNIT_ASSERT_EQUAL( true , noMolecules.empty());
    110116}
     
    142148  // test some elementary set operations
    143149  {
    144     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()||NoMolecules());
     150    std::vector<const molecule*> testMolecules =
     151        const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()||NoMolecules());
    145152    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
    146153    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
     
    148155
    149156  {
    150     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||AllMolecules());
     157    std::vector<const molecule*> testMolecules =
     158        const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()||AllMolecules());
    151159    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
    152160    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
     
    154162
    155163  {
    156     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()&&AllMolecules());
     164    std::vector<const molecule*> testMolecules =
     165        const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()&&AllMolecules());
    157166    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
    158167  }
    159168
    160169  {
    161     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&NoMolecules());
     170    std::vector<const molecule*> testMolecules =
     171        const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()&&NoMolecules());
    162172    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
    163173  }
    164174
    165175  {
    166     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!AllMolecules());
     176    std::vector<const molecule*> testMolecules =
     177        const_cast<const World &>(World::getInstance()).getAllMolecules(!AllMolecules());
    167178    CPPUNIT_ASSERT_EQUAL( true , testMolecules.empty());
    168179  }
    169180
    170181  {
    171     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(!NoMolecules());
     182    std::vector<const molecule*> testMolecules =
     183        const_cast<const World &>(World::getInstance()).getAllMolecules(!NoMolecules());
    172184    CPPUNIT_ASSERT_EQUAL( true , hasAllMolecules(testMolecules,moleculeIds));
    173185    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateMolecules(testMolecules));
     
    176188  // exclude and include some molecules
    177189  {
    178     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
     190    std::vector<const molecule*> testMolecules =
     191        const_cast<const World &>(World::getInstance()).getAllMolecules(AllMolecules()&&(!MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
    179192    std::set<moleculeId_t> excluded;
    180193    excluded.insert(moleculeIds[MOLECULE_COUNT/2]);
     
    185198
    186199  {
    187     std::vector<molecule*> testMolecules = World::getInstance().getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
     200    std::vector<const molecule*> testMolecules =
     201        const_cast<const World &>(World::getInstance()).getAllMolecules(NoMolecules()||(MoleculeById(moleculeIds[MOLECULE_COUNT/2])));
    188202    CPPUNIT_ASSERT_EQUAL( (size_t)1, testMolecules.size());
    189203    CPPUNIT_ASSERT_EQUAL( moleculeIds[MOLECULE_COUNT/2], testMolecules[0]->getId());
Note: See TracChangeset for help on using the changeset viewer.