Changeset d5f216
- Timestamp:
- Feb 2, 2010, 12:00:19 PM (15 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:
- bfce50
- Parents:
- 63c1f6
- git-author:
- Tillmann Crueger <crueger@…> (01/21/10 14:01:16)
- git-committer:
- Tillmann Crueger <crueger@…> (02/02/10 12:00:19)
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r63c1f6 rd5f216 22 22 UISOURCE = ${ACTIONSSOURCE} ${VIEWSOURCE} ${MENUSOURCE} UIElements/UIFactory.cpp UIElements/TextUIFactory.cpp UIElements/MainWindow.cpp UIElements/TextWindow.cpp UIElements/Dialog.cpp UIElements/TextDialog.cpp 23 23 UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp 24 25 24 26 25 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp menu.cpp -
src/Patterns/Observer.hpp
r63c1f6 rd5f216 32 32 class Observer 33 33 { 34 friend class Observable; 34 35 public: 35 36 Observer(); 36 37 virtual ~Observer(); 37 38 39 protected: 38 40 virtual void update(Observable *publisher)=0; 39 41 virtual void subjectKilled(Observable *publisher)=0; … … 48 50 virtual void signOff(Observer *target); 49 51 52 protected: 50 53 virtual void update(Observable *publisher); 51 54 virtual void subjectKilled(Observable *publisher); 52 55 53 private:54 56 virtual void notifyAll(); 55 57 protected: 56 // Observer mechanism enis done from a static central place58 // Observer mechanism is done from a static central place 57 59 /** 58 60 * Internal method. -
src/molecule.hpp
r63c1f6 rd5f216 30 30 #include "stackclass.hpp" 31 31 #include "tesselation.hpp" 32 #include "Patterns/Observer.hpp" 32 33 33 34 /****************************************** forward declarations *****************************/ … … 310 311 /** A list of \a molecule classes. 311 312 */ 312 class MoleculeListClass {313 class MoleculeListClass : public Observable { 313 314 public: 314 315 MoleculeList ListOfMolecules; //!< List of the contained molecules -
src/moleculelist.cpp
r63c1f6 rd5f216 889 889 890 890 void MoleculeListClass::createNewMolecule(periodentafel *periode) { 891 START_OBSERVER; 891 892 molecule *mol = NULL; 892 893 mol = new molecule(periode); 893 894 insert(mol); 895 FINISH_OBSERVER; 894 896 }; 895 897 -
src/unittests/ObserverTest.cpp
r63c1f6 rd5f216 86 86 87 87 void ObserverTest::setUp() { 88 simpleObservable = new SimpleObservable(); 88 simpleObservable1 = new SimpleObservable(); 89 simpleObservable2 = new SimpleObservable(); 89 90 callObservable = new CallObservable(); 90 91 superObservable = new SuperObservable(); … … 93 94 observer2 = new UpdateCountObserver(); 94 95 observer3 = new UpdateCountObserver(); 96 observer4 = new UpdateCountObserver(); 95 97 } 96 98 97 99 void ObserverTest::tearDown() { 98 delete simpleObservable; 100 delete simpleObservable1; 101 delete simpleObservable2; 99 102 delete callObservable; 100 103 delete superObservable; … … 103 106 delete observer2; 104 107 delete observer3; 108 delete observer4; 105 109 } 106 110 107 111 void ObserverTest::doesUpdateTest() 108 112 { 109 simpleObservable->signOn(observer1); 110 simpleObservable->signOn(observer2); 111 simpleObservable->signOn(observer3); 112 113 simpleObservable->changeMethod(); 113 simpleObservable1->signOn(observer1); 114 simpleObservable1->signOn(observer2); 115 simpleObservable1->signOn(observer3); 116 simpleObservable2->signOn(observer2); 117 simpleObservable2->signOn(observer4); 118 119 simpleObservable1->changeMethod(); 114 120 CPPUNIT_ASSERT_EQUAL( 1, observer1->updates ); 115 121 CPPUNIT_ASSERT_EQUAL( 1, observer2->updates ); 116 122 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 117 118 simpleObservable->signOff(observer3); 119 120 simpleObservable->changeMethod(); 123 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 124 125 simpleObservable1->signOff(observer3); 126 127 simpleObservable1->changeMethod(); 121 128 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 122 129 CPPUNIT_ASSERT_EQUAL( 2, observer2->updates ); 123 130 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 131 CPPUNIT_ASSERT_EQUAL( 0, observer4->updates ); 132 133 simpleObservable2->changeMethod(); 134 CPPUNIT_ASSERT_EQUAL( 2, observer1->updates ); 135 CPPUNIT_ASSERT_EQUAL( 3, observer2->updates ); 136 CPPUNIT_ASSERT_EQUAL( 1, observer3->updates ); 137 CPPUNIT_ASSERT_EQUAL( 1, observer4->updates ); 124 138 } 125 139 … … 155 169 cout << "If this test does not complete in a few seconds, kill the test-suite and fix the Error in the circle detection mechanism" << endl; 156 170 157 cout << endl << endl << "The following error displayed by the observer framwork can be ignored" << endl;171 cout << endl << endl << "The following errors displayed by the observer framework can be ignored" << endl; 158 172 159 173 // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE 160 simpleObservable->signOn(simpleObservable); 161 simpleObservable->changeMethod(); 174 simpleObservable1->signOn(simpleObservable1); 175 simpleObservable1->changeMethod(); 176 177 // more complex test 178 simpleObservable1->signOff(simpleObservable1); 179 simpleObservable1->signOn(simpleObservable2); 180 simpleObservable2->signOn(simpleObservable1); 181 simpleObservable1->changeMethod(); 182 simpleObservable1->signOff(simpleObservable2); 183 simpleObservable2->signOff(simpleObservable1); 162 184 // when we reach this line, although we broke the DAG assumption the circle check works fine 163 185 CPPUNIT_ASSERT(true); -
src/unittests/ObserverTest.hpp
r63c1f6 rd5f216 40 40 UpdateCountObserver *observer2; 41 41 UpdateCountObserver *observer3; 42 UpdateCountObserver *observer4; 42 43 43 SimpleObservable *simpleObservable; 44 SimpleObservable *simpleObservable1; 45 SimpleObservable *simpleObservable2; 44 46 CallObservable *callObservable; 45 47 SuperObservable *superObservable;
Note:
See TracChangeset
for help on using the changeset viewer.