Ignore:
Timestamp:
Jul 3, 2017, 3:00:00 PM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_Verbose_Codepatterns, ForceAnnealing_oldresults, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps
Children:
4dfe724
Parents:
8e9217
git-author:
Frederik Heber <heber@…> (04/07/17 17:47:46)
git-committer:
Frederik Heber <frederik.heber@…> (07/03/17 15:00:00)
Message:

ObservedValue has forceUpdate() public function to externally force an update.

  • TESTS: unit test function extended to include that function.
Location:
ThirdParty/CodePatterns/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ThirdParty/CodePatterns/src/CodePatterns/ObservedValue.hpp

    r8e9217 r70fee0  
    8686  virtual void subjectKilled(Observable *publisher);
    8787
     88  void forceUpdate();
     89
    8890  const T& get() const;
    8991
     
    178180
    179181template <typename T>
     182void ObservedValue<T>::forceUpdate()
     183{
     184  boost::lock_guard<boost::recursive_mutex> guard(valueLock);
     185  value = recalcMethod();
     186}
     187
     188template <typename T>
    180189void ObservedValue<T>::update(Observable *publisher)
    181190{
  • ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.cpp

    r8e9217 r70fee0  
    7070  CPPUNIT_ASSERT_EQUAL( true, YChange_numbers->hasRecalced);
    7171  CPPUNIT_ASSERT_EQUAL( 11, (YChange_numbers->sum).get());
     72
     73  numbers->hasRecalced=false;
     74  numbers->sum.forceUpdate();
     75  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
    7276}
Note: See TracChangeset for help on using the changeset viewer.