- Timestamp:
- Feb 11, 2016, 8:06:49 AM (9 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:
- 5d8f4f
- Parents:
- 7f1865d
- git-author:
- Frederik Heber <heber@…> (12/28/15 15:09:49)
- git-committer:
- Frederik Heber <heber@…> (02/11/16 08:06:49)
- Location:
- src/Atom
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Atom/AtomObserver.cpp
r7f1865d r4a328f 53 53 Observable::insertNotificationChannel( std::make_pair(static_cast<Observable *>(this), OurChannel) ); 54 54 OurChannel->addChannel(AtomObservable::PositionChanged); 55 OurChannel->addChannel(AtomObservable::VelocityChanged); 56 OurChannel->addChannel(AtomObservable::ForceChanged); 57 OurChannel->addChannel(AtomObservable::MoleculeChanged); 58 OurChannel->addChannel(AtomObservable::NameChanged); 55 59 OurChannel->addChannel(AtomObservable::ElementChanged); 60 OurChannel->addChannel(AtomObservable::IndexChanged); 61 OurChannel->addChannel(AtomObservable::PropertyChanged); 62 OurChannel->addChannel(AtomObservable::BondsAdded); 63 OurChannel->addChannel(AtomObservable::BondsRemoved); 56 64 OurChannel->addChannel(AtomObservable::TrajectoryChanged); 65 OurChannel->addChannel(AtomObservable::SelectionChanged); 57 66 } 58 67 … … 70 79 { 71 80 res->signOn(this, AtomObservable::PositionChanged); 81 res->signOn(this, AtomObservable::VelocityChanged); 82 res->signOn(this, AtomObservable::ForceChanged); 83 res->signOn(this, AtomObservable::MoleculeChanged); 84 res->signOn(this, AtomObservable::NameChanged); 72 85 res->signOn(this, AtomObservable::ElementChanged); 86 res->signOn(this, AtomObservable::IndexChanged); 87 res->signOn(this, AtomObservable::PropertyChanged); 88 res->signOn(this, AtomObservable::BondsAdded); 89 res->signOn(this, AtomObservable::BondsRemoved); 73 90 res->signOn(this, AtomObservable::TrajectoryChanged); 91 res->signOn(this, AtomObservable::SelectionChanged); 74 92 } 75 93 … … 81 99 { 82 100 res->signOff(this, AtomObservable::PositionChanged); 101 res->signOff(this, AtomObservable::VelocityChanged); 102 res->signOff(this, AtomObservable::ForceChanged); 103 res->signOff(this, AtomObservable::MoleculeChanged); 104 res->signOff(this, AtomObservable::NameChanged); 83 105 res->signOff(this, AtomObservable::ElementChanged); 106 res->signOff(this, AtomObservable::IndexChanged); 107 res->signOff(this, AtomObservable::PropertyChanged); 108 res->signOff(this, AtomObservable::BondsAdded); 109 res->signOff(this, AtomObservable::BondsRemoved); 84 110 res->signOff(this, AtomObservable::TrajectoryChanged); 111 res->signOff(this, AtomObservable::SelectionChanged); 85 112 } 86 113 -
src/Atom/unittests/AtomObserverUnitTest.cpp
r7f1865d r4a328f 68 68 // observer checks that we don't receive general updates ... 69 69 observer = new UpdateCountObserver; 70 // but only specific notifications in observer1 and observer2 71 observer1 = new NotificationObserver( 72 AtomObserver::getInstance().getChannel(AtomObservable::PositionChanged) 73 ); 74 observer2 = new NotificationObserver( 75 AtomObserver::getInstance().getChannel(AtomObservable::ElementChanged) 76 ); 70 AtomObserver::getInstance().signOn(observer); 77 71 78 AtomObserver::getInstance().signOn(observer); 79 AtomObserver::getInstance().signOn(observer1, AtomObservable::PositionChanged); 80 AtomObserver::getInstance().signOn(observer2, AtomObservable::ElementChanged); 72 // but only specific notifications in others observers 73 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 74 specific_observers.push_back(new NotificationObserver( 75 AtomObserver::getInstance().getChannel((enum AtomObservable::NotificationType)i) 76 )); 77 AtomObserver::getInstance().signOn( 78 specific_observers.back(), (enum AtomObservable::NotificationType)i); 79 } 80 81 81 82 82 for(int i=0;i<ATOM_COUNT;++i){ … … 89 89 { 90 90 AtomObserver::getInstance().signOff(observer); 91 AtomObserver::getInstance().signOff(observer1, AtomObservable::PositionChanged); 92 AtomObserver::getInstance().signOff(observer2, AtomObservable::ElementChanged); 91 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 92 AtomObserver::getInstance().signOff(specific_observers[i], (enum AtomObservable::NotificationType)i); 93 delete specific_observers[i]; 94 } 95 specific_observers.clear(); 93 96 94 97 delete observer; 95 delete observer1;96 delete observer2;97 98 98 99 World::purgeInstance(); … … 107 108 // check for zero update 108 109 CPPUNIT_ASSERT_EQUAL( (int)0, observer->updates ); 109 CPPUNIT_ASSERT_EQUAL( false, observer1->wasNotified ); 110 CPPUNIT_ASSERT_EQUAL( false, observer2->wasNotified ); 110 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 111 112 CPPUNIT_ASSERT_EQUAL( false, specific_observers[i]->wasNotified ); 113 } 111 114 } 112 115 … … 120 123 121 124 // check for update 122 CPPUNIT_ASSERT_EQUAL( true, observer1->wasNotified ); 123 CPPUNIT_ASSERT_EQUAL( false, observer2->wasNotified ); 125 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 126 CPPUNIT_ASSERT_EQUAL( (enum AtomObservable::NotificationType)i == AtomObservable::PositionChanged, 127 specific_observers[i]->wasNotified ); 128 } 124 129 CPPUNIT_ASSERT_EQUAL( (int)0, observer->updates ); 125 130 } … … 134 139 135 140 // check for update 136 CPPUNIT_ASSERT_EQUAL( false, observer1->wasNotified ); 137 CPPUNIT_ASSERT_EQUAL( true, observer2->wasNotified ); 141 for (int i=0;i<AtomObservable::NotificationType_MAX; ++i) { 142 CPPUNIT_ASSERT_EQUAL( (enum AtomObservable::NotificationType)i == AtomObservable::ElementChanged, 143 specific_observers[i]->wasNotified ); 144 } 138 145 CPPUNIT_ASSERT_EQUAL( (int)0, observer->updates ); 139 146 } -
src/Atom/unittests/AtomObserverUnitTest.hpp
r7f1865d r4a328f 16 16 17 17 #include <cppunit/extensions/HelperMacros.h> 18 19 #include <vector> 18 20 19 21 #include "types.hpp" … … 48 50 49 51 UpdateCountObserver *observer; 50 NotificationObserver *observer1; 51 NotificationObserver *observer2; 52 std::vector<NotificationObserver *> specific_observers; 52 53 }; 53 54
Note:
See TracChangeset
for help on using the changeset viewer.