Changeset ea7176 for src/Patterns


Ignore:
Timestamp:
Mar 19, 2010, 1:29:01 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:
e0b6fd
Parents:
80c63d
Message:

FIX: Made AtomCount a Cacheable so that the number of atoms in a molecule will always be correct

All unittests working.
All Complete testcases fail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/Cacheable.hpp

    r80c63d rea7176  
    2121    virtual ~Cacheable();
    2222
    23     const bool isValid();
    24     const T& operator*();
    25     const bool operator==(const T&);
    26     const bool operator!=(const T&);
     23    const bool isValid() const;
     24    const T& operator*() const;
    2725
    2826    // methods implemented for base-class Observer
     
    3028    void subjectKilled(Observable *subject);
    3129  private:
    32     void checkValid();
     30    void checkValid() const;
    3331
    34     T content;
     32    mutable T content;
    3533    Observable *owner;
    36     bool valid;
    37     bool canBeUsed;
     34    mutable bool valid;
     35    mutable bool canBeUsed;
    3836    boost::function<T()> recalcMethod;
    3937  };
     
    5351
    5452  template<typename T>
    55   const T& Cacheable<T>::operator*(){
     53  const T& Cacheable<T>::operator*() const{
    5654    checkValid();
    5755    return content;
    58   }
    59 
    60   template<typename T>
    61   const bool Cacheable<T>::operator==(const T& rval){
    62     checkValid();
    63     return (content == rval);
    64   }
    65 
    66   template<typename T>
    67   const bool Cacheable<T>::operator!=(const T& rval){
    68     checkValid();
    69     return (content != rval);
    7056  }
    7157
     
    7763
    7864  template<typename T>
    79   const bool Cacheable<T>::isValid(){
     65  const bool Cacheable<T>::isValid() const{
    8066    return valid;
    8167  }
     
    9379
    9480  template<typename T>
    95   void Cacheable<T>::checkValid(){
     81  void Cacheable<T>::checkValid() const{
    9682    assert(canBeUsed && "Cacheable used after owner was deleted");
    9783    if(!isValid()){
     
    10793    virtual ~Cacheable();
    10894
    109     const bool isValid();
    110     const T& operator*();
    111     const bool operator==(const T&);
    112     const bool operator!=(const T&);
     95    const bool isValid() const;
     96    const T& operator*() const;
    11397
    11498    // methods implemented for base-class Observer
     
    126110
    127111  template<typename T>
    128   const T& Cacheable<T>::operator*(){
     112  const T& Cacheable<T>::operator*() const{
    129113    return recalcMethod();
    130   }
    131 
    132   template<typename T>
    133   const bool Cacheable<T>::operator==(const T& rval){
    134     return (recalcMethod() == rval);
    135   }
    136 
    137   template<typename T>
    138   const bool Cacheable<T>::operator!=(const T& rval){
    139     return (recalcMethod() != rval);
    140114  }
    141115
     
    145119
    146120  template<typename T>
    147   const bool Cacheable<T>::isValid(){
     121  const bool Cacheable<T>::isValid() const{
    148122    return true;
    149123  }
     
    155129
    156130  template<typename T>
    157   void Cacheable<T>::subjectKilled(Observable *subject) {
     131  void Cacheable<T>::subjectKilled(Observable *subject){
    158132    assert(0 && "Cacheable::subjectKilled should never be called when caching is disabled");
    159133  }
Note: See TracChangeset for help on using the changeset viewer.