Changeset 3501d2


Ignore:
Timestamp:
Dec 3, 2012, 9:49:06 AM (12 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:
bf42a0
Parents:
2a0eb0
git-author:
Frederik Heber <heber@…> (09/19/12 10:11:12)
git-committer:
Frederik Heber <heber@…> (12/03/12 09:49:06)
Message:

REFACTOR: CheckAgainstAdjacencyFile now gets File in cstor.

  • we cannot have multiple files, but we may have multiple fragmentations. Hence, CheckAgainstAdjacencyFile should get and parse the File in its cstor and get a set of atoms in its operator() to check against.
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Fragmentation.cpp

    r2a0eb0 r3501d2  
    136136    LOG(1, "Looking at bond structure stored in adjacency file and comparing to present one ... ");
    137137
    138     CheckAgainstAdjacencyFile FileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
    139     FragmentationToDo = FragmentationToDo && FileChecker(File);
     138    CheckAgainstAdjacencyFile FileChecker(File);
     139    FragmentationToDo = FragmentationToDo && FileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
    140140  }
    141141
  • src/Graph/CheckAgainstAdjacencyFile.cpp

    r2a0eb0 r3501d2  
    5151#include "World.hpp"
    5252
    53 CheckAgainstAdjacencyFile::CheckAgainstAdjacencyFile(World::AtomSet::const_iterator AtomMapBegin, World::AtomSet::const_iterator AtomMapEnd) :
     53/** Constructor of class CheckAgainstAdjacencyFile.
     54 *
     55 * \param File file to parser
     56 */
     57CheckAgainstAdjacencyFile::CheckAgainstAdjacencyFile(std::istream &File) :
    5458  status(true),
    5559  NonMatchNumber(0)
    5660{
    57   CreateInternalMap(AtomMapBegin, AtomMapEnd);
     61  ParseInExternalMap(File);
    5862}
    5963
     
    113117 * @param AtomMapEnd iterator pointing past end of map (think of World's SelectionIterator)
    114118 */
    115 void CheckAgainstAdjacencyFile::CreateInternalMap(World::AtomSet::const_iterator &AtomMapBegin, World::AtomSet::const_iterator &AtomMapEnd)
     119void CheckAgainstAdjacencyFile::CreateInternalMap(World::AtomSet::const_iterator AtomMapBegin, World::AtomSet::const_iterator AtomMapEnd)
    116120{
    117121  InternalAtomBondMap.clear();
     
    136140
    137141/** Checks contents of adjacency file against bond structure in structure molecule.
    138  * \param File file to parser
    139142 * \return true - structure is equal, false - not equivalence
    140143 */
    141 bool CheckAgainstAdjacencyFile::operator()(std::istream &File)
     144bool CheckAgainstAdjacencyFile::operator()(World::AtomSet::const_iterator AtomMapBegin, World::AtomSet::const_iterator AtomMapEnd)
    142145{
    143146  LOG(0, "STATUS: Looking at bond structure stored in adjacency file and comparing to present one ... ");
     
    145148  bool status = true;
    146149
    147   status = status && ParseInExternalMap(File);
     150  if (InternalAtomBondMap.empty())
     151    CreateInternalMap(AtomMapBegin, AtomMapEnd);
     152
    148153  status = status && CompareInternalExternalMap();
    149154
  • src/Graph/CheckAgainstAdjacencyFile.hpp

    r2a0eb0 r3501d2  
    2828  friend class CheckAgainstAdjacencyFileTest;
    2929public:
    30   CheckAgainstAdjacencyFile(World::AtomSet::const_iterator AtomMapBegin, World::AtomSet::const_iterator AtomMapEnd);
     30  CheckAgainstAdjacencyFile(std::istream &File);
    3131  ~CheckAgainstAdjacencyFile();
    3232
    33   bool operator()(std::istream &File);
     33  bool operator()(World::AtomSet::const_iterator AtomMapBegin, World::AtomSet::const_iterator AtomMapEnd);
    3434
    3535private:
     
    4747  ValuesSet getValues(const AtomBondRange&_range) const;
    4848
    49   void CreateInternalMap(World::AtomSet::const_iterator &AtomMapBegin, World::AtomSet::const_iterator &AtomMapEnd);
     49  void CreateInternalMap(World::AtomSet::const_iterator AtomMapBegin, World::AtomSet::const_iterator AtomMapEnd);
    5050  bool ParseInExternalMap(std::istream &File);
    5151  bool CompareInternalExternalMap();
  • src/Graph/unittests/CheckAgainstAdjacencyFileUnitTest.cpp

    r2a0eb0 r3501d2  
    101101void CheckAgainstAdjacencyFileTest::setUp()
    102102{
     103  // failing asserts should be thrown
     104  ASSERT_DO(Assert::Throw);
     105
    103106  const element *hydrogen = World::getInstance().getPeriode()->FindElement(1);
    104107  CPPUNIT_ASSERT(hydrogen != NULL);
    105 
    106   // failing asserts should be thrown
    107   ASSERT_DO(Assert::Throw);
    108108
    109109  TestMolecule = World::getInstance().createMolecule();
     
    148148void CheckAgainstAdjacencyFileTest::CreateInternalMapTest()
    149149{
     150  std::stringstream input;
     151  CheckAgainstAdjacencyFile fileChecker(input);
    150152  World::getInstance().selectAllAtoms(AllAtoms());
    151   CheckAgainstAdjacencyFile fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
     153  const World &world = World::getInstance();
     154  fileChecker.CreateInternalMap(world.beginAtomSelection(), world.endAtomSelection());
    152155
    153156  // check size (it's 8*2 + 2*1 = 18 keys)
     
    178181  std::stringstream input(adjacencyfile);
    179182  World::getInstance().selectAllAtoms(NoAtoms());
    180   CheckAgainstAdjacencyFile fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
    181   fileChecker.ParseInExternalMap(input);
     183  CheckAgainstAdjacencyFile fileChecker(input);
     184  fileChecker.CreateInternalMap(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
    182185
    183186  // check size (it's 8*2 + 2*1 = 18 keys)
     
    204207void CheckAgainstAdjacencyFileTest::CompareInternalExternalMapTest()
    205208{
    206   World::getInstance().selectAllAtoms(AllAtoms());
    207   CheckAgainstAdjacencyFile fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
     209  std::stringstream input(adjacencyfile);
     210  CheckAgainstAdjacencyFile fileChecker(input);
    208211
    209212  // assert non-equality before parsing
     
    213216
    214217  // parse
    215   std::stringstream input(adjacencyfile);
    216   fileChecker.ParseInExternalMap(input);
     218  World::getInstance().selectAllAtoms(AllAtoms());
     219  fileChecker.CreateInternalMap(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
    217220
    218221  // assert equality after parsing
     
    228231{
    229232  World::getInstance().selectAllAtoms(AllAtoms());
    230   CheckAgainstAdjacencyFile fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection());
    231233  {
    232234    // parse right
    233235    std::stringstream input(adjacencyfile);
    234     CPPUNIT_ASSERT( fileChecker(input) );
     236    CheckAgainstAdjacencyFile fileChecker(input);
     237    CPPUNIT_ASSERT( fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection()) );
    235238  }
    236239  {
    237240    // parse wrong1
    238241    std::stringstream input(wrongadjacencyfile1);
    239     CPPUNIT_ASSERT( !fileChecker(input) );
     242    CheckAgainstAdjacencyFile fileChecker(input);
     243    CPPUNIT_ASSERT( !fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection()) );
    240244  }
    241245  {
     
    244248#ifndef NDEBUG
    245249    std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
    246     CPPUNIT_ASSERT_THROW( fileChecker(input), Assert::AssertionFailure );
     250    CPPUNIT_ASSERT_THROW( CheckAgainstAdjacencyFile fileChecker(input), Assert::AssertionFailure );
    247251#else
    248     CPPUNIT_ASSERT( !fileChecker(input) );
     252    CheckAgainstAdjacencyFile fileChecker(input);
     253    CPPUNIT_ASSERT( !fileChecker(World::getInstance().beginAtomSelection(), World::getInstance().endAtomSelection()) );
    249254#endif
    250255  }
Note: See TracChangeset for help on using the changeset viewer.