Changeset ea7176 for src/Patterns
- Timestamp:
- Mar 19, 2010, 1:29:01 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:
- e0b6fd
- Parents:
- 80c63d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Cacheable.hpp
r80c63d rea7176 21 21 virtual ~Cacheable(); 22 22 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; 27 25 28 26 // methods implemented for base-class Observer … … 30 28 void subjectKilled(Observable *subject); 31 29 private: 32 void checkValid() ;30 void checkValid() const; 33 31 34 T content;32 mutable T content; 35 33 Observable *owner; 36 bool valid;37 bool canBeUsed;34 mutable bool valid; 35 mutable bool canBeUsed; 38 36 boost::function<T()> recalcMethod; 39 37 }; … … 53 51 54 52 template<typename T> 55 const T& Cacheable<T>::operator*() {53 const T& Cacheable<T>::operator*() const{ 56 54 checkValid(); 57 55 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);70 56 } 71 57 … … 77 63 78 64 template<typename T> 79 const bool Cacheable<T>::isValid() {65 const bool Cacheable<T>::isValid() const{ 80 66 return valid; 81 67 } … … 93 79 94 80 template<typename T> 95 void Cacheable<T>::checkValid() {81 void Cacheable<T>::checkValid() const{ 96 82 assert(canBeUsed && "Cacheable used after owner was deleted"); 97 83 if(!isValid()){ … … 107 93 virtual ~Cacheable(); 108 94 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; 113 97 114 98 // methods implemented for base-class Observer … … 126 110 127 111 template<typename T> 128 const T& Cacheable<T>::operator*() {112 const T& Cacheable<T>::operator*() const{ 129 113 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);140 114 } 141 115 … … 145 119 146 120 template<typename T> 147 const bool Cacheable<T>::isValid() {121 const bool Cacheable<T>::isValid() const{ 148 122 return true; 149 123 } … … 155 129 156 130 template<typename T> 157 void Cacheable<T>::subjectKilled(Observable *subject) 131 void Cacheable<T>::subjectKilled(Observable *subject){ 158 132 assert(0 && "Cacheable::subjectKilled should never be called when caching is disabled"); 159 133 }
Note:
See TracChangeset
for help on using the changeset viewer.