Changes in src/Patterns/Cacheable.hpp [adc42b:c72112]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Cacheable.hpp
radc42b rc72112 28 28 owner(_owner) 29 29 {} 30 virtual T getValue()=0;30 virtual T& getValue()=0; 31 31 virtual void invalidate()=0; 32 32 virtual bool isValid()=0; … … 46 46 {} 47 47 48 virtual T getValue(){48 virtual T& getValue(){ 49 49 // set the state to valid 50 50 State::owner->switchState(State::owner->validState); … … 72 72 {} 73 73 74 virtual T getValue(){74 virtual T& getValue(){ 75 75 return content; 76 76 } … … 100 100 {} 101 101 102 virtual T getValue(){102 virtual T& getValue(){ 103 103 ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died"); 104 104 // we have to return a grossly invalid reference, because no value can be produced anymore … … 134 134 void subjectKilled(Observable *subject); 135 135 private: 136 137 136 void switchState(state_ptr newState); 138 137 … … 144 143 145 144 Observable *owner; 146 147 145 boost::function<T()> recalcMethod; 148 146 … … 221 219 222 220 const bool isValid() const; 223 const T operator*() const;221 const T& operator*() const; 224 222 225 223 // methods implemented for base-class Observer … … 237 235 238 236 template<typename T> 239 const T Cacheable<T>::operator*() const{237 const T& Cacheable<T>::operator*() const{ 240 238 return recalcMethod(); 241 239 }
Note:
See TracChangeset
for help on using the changeset viewer.