Changes in src/Patterns/Cacheable.hpp [c72112:adc42b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/Cacheable.hpp
rc72112 radc42b 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 136 137 void switchState(state_ptr newState); 137 138 … … 143 144 144 145 Observable *owner; 146 145 147 boost::function<T()> recalcMethod; 146 148 … … 219 221 220 222 const bool isValid() const; 221 const T &operator*() const;223 const T operator*() const; 222 224 223 225 // methods implemented for base-class Observer … … 235 237 236 238 template<typename T> 237 const T &Cacheable<T>::operator*() const{239 const T Cacheable<T>::operator*() const{ 238 240 return recalcMethod(); 239 241 }
Note:
See TracChangeset
for help on using the changeset viewer.