Changeset 4fb5a3 for src/Patterns


Ignore:
Timestamp:
Mar 19, 2010, 4:44:08 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
adc42b
Parents:
052b8d0
git-author:
Tillmann Crueger <crueger@…> (03/19/10 16:13:28)
git-committer:
Tillmann Crueger <crueger@…> (03/19/10 16:44:08)
Message:

Improved Observer Framework to include methods to report the state

  • bool Observable::isBlocked() will tell if the Observer is currently updating itself
  • The Circle detection test now uses ASSERT to report when a circle was detected (can be caught by CPPUNIT)
Location:
src/Patterns
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/Observer.cpp

    r052b8d0 r4fb5a3  
    1010
    1111#include <iostream>
    12 #include <cassert>
     12
     13#include "Helpers/Assert.hpp"
    1314
    1415using namespace std;
     
    127128    // observers, but still we are called by one of our sub-Observables
    128129    // we cannot be sure observation will still work at this point
    129     cerr << "Circle detected in observation-graph." << endl;
    130     cerr << "Observation-graph always needs to be a DAG to work correctly!" << endl;
    131     cerr << "Please check your observation code and fix this!" << endl;
     130    ASSERT(0,"Circle detected in observation-graph.\n"
     131             "Observation-graph always needs to be a DAG to work correctly!\n"
     132             "Please check your observation code and fix this!\n");
    132133    return;
    133134  }
     
    148149 */
    149150void Observable::signOn(Observer *target,int priority) {
    150   assert(priority>=-20 && priority<=+20 && "Priority out of range [-20:+20]");
     151  ASSERT(priority>=-20 && priority<=+20, "Priority out of range [-20:+20] when signing on Observer");
    151152  bool res = false;
    152153  callees_t *callees = 0;
     
    172173 */
    173174void Observable::signOff(Observer *target) {
    174   assert(callTable.count(this) && "SignOff called for an Observable without Observers.");
     175  ASSERT(callTable.count(this),"SignOff called for an Observable without Observers.");
    175176  callees_t *callees = callTable[this];
    176177  callees_t::iterator iter;
     
    188189    delete callees;
    189190  }
     191}
     192
     193bool Observable::isBlocked(){
     194  return depth.count(this) > 0;
    190195}
    191196
  • src/Patterns/Observer.hpp

    r052b8d0 r4fb5a3  
    9595  virtual void signOff(Observer *target);
    9696
     97  /**
     98   * Ask an Observer if it is currently in a blocked state, i.e. if
     99   * Changes are in Progress, that are not yet published.
     100   */
     101  virtual bool isBlocked();
     102
    97103protected:
    98104  virtual void update(Observable *publisher);
     
    119125  static std::set<Observable*> busyObservables;
    120126
     127  //! @cond
    121128  // Structure for RAII-Style notification
    122129protected:
     
    133140    Observable *protege;
    134141  };
     142  //! @endcond
    135143};
    136144
Note: See TracChangeset for help on using the changeset viewer.