Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/Cacheable.hpp

    radc42b rc72112  
    2828        owner(_owner)
    2929        {}
    30       virtual T getValue()=0;
     30      virtual T& getValue()=0;
    3131      virtual void invalidate()=0;
    3232      virtual bool isValid()=0;
     
    4646        {}
    4747
    48       virtual T getValue(){
     48      virtual T& getValue(){
    4949        // set the state to valid
    5050        State::owner->switchState(State::owner->validState);
     
    7272        {}
    7373
    74       virtual T getValue(){
     74      virtual T& getValue(){
    7575        return content;
    7676      }
     
    100100        {}
    101101
    102       virtual T getValue(){
     102      virtual T& getValue(){
    103103        ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died");
    104104        // we have to return a grossly invalid reference, because no value can be produced anymore
     
    134134    void subjectKilled(Observable *subject);
    135135  private:
    136 
    137136    void switchState(state_ptr newState);
    138137
     
    144143
    145144    Observable *owner;
    146 
    147145    boost::function<T()> recalcMethod;
    148146
     
    221219
    222220    const bool isValid() const;
    223     const T operator*() const;
     221    const T& operator*() const;
    224222
    225223    // methods implemented for base-class Observer
     
    237235
    238236  template<typename T>
    239   const T Cacheable<T>::operator*() const{
     237  const T& Cacheable<T>::operator*() const{
    240238    return recalcMethod();
    241239  }
Note: See TracChangeset for help on using the changeset viewer.