Ignore:
Timestamp:
Oct 30, 2015, 11:43:20 AM (10 years ago)
Author:
Frederik Heber <heber@…>
Children:
959c82
Parents:
454bc54
git-author:
Frederik Heber <heber@…> (06/21/15 11:28:54)
git-committer:
Frederik Heber <heber@…> (10/30/15 11:43:20)
Message:

FIX: Made Cacheables internally stored Observable const.

  • recalcMethod() functor is given as ref in cstor.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodePatterns/Cacheable.hpp

    r454bc54 re24dde  
    3131    class State{
    3232    public:
    33       State(Cacheable *_owner) :
     33      State(Cacheable * const _owner) :
    3434        busy(false),
    3535        owner(_owner)
     
    4545    protected:
    4646      bool busy;
    47       Cacheable *owner;
     47      Cacheable * const owner;
    4848    };
    4949
    5050    class InvalidState : public State{
    5151    public:
    52       InvalidState(Cacheable *_owner):
     52      InvalidState(Cacheable * const _owner):
    5353        State(_owner)
    5454        {}
     
    8080    class ValidState : public State{
    8181    public:
    82       ValidState(Cacheable *_owner) :
     82      ValidState(Cacheable * const _owner) :
    8383        State(_owner)
    8484        {}
     
    112112    class DestroyedState : public State {
    113113    public:
    114       DestroyedState(Cacheable *_owner) :
     114      DestroyedState(Cacheable * const _owner) :
    115115        State(_owner)
    116116        {}
     
    145145  public:
    146146    Cacheable(
    147         Observable *_owner,
    148         const boost::function<T()> _recalcMethod,
     147        const Observable * const _owner,
     148        const boost::function<T()> &_recalcMethod,
    149149        const std::string &name,
    150150        const Observable::channels_t &_channels = Observable::channels_t());
     
    167167    // destroyed state is not predefined, because we rarely enter that state and never leave
    168168
    169     const Observable * owner;
     169    const Observable * const owner;
    170170    const boost::function<T()> recalcMethod;
    171171
     
    180180  template<typename T>
    181181  Cacheable<T>::Cacheable(
    182       Observable *_owner,
    183       const boost::function<T()> _recalcMethod,
     182      const Observable * const _owner,
     183      const boost::function<T()> &_recalcMethod,
    184184      const std::string &_name,
    185185      const Observable::channels_t &_channels) :
     
    234234          owner->signOff(this,*iter);
    235235      }
     236      const_cast<const Observable *&>(owner) = NULL;
    236237    }
    237238  }
     
    283284  {
    284285  public:
    285     Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name);
     286    Cacheable(
     287        const Observable * const _owner,
     288        boost::function<T()> &_recalcMethod,
     289        std::string name,
     290        const Observable::channels_t &_channels);
    286291    virtual ~Cacheable();
    287292
     
    299304
    300305  template<typename T>
    301   Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
     306  Cacheable<T>::Cacheable(
     307      const Observable * const _owner,
     308      boost::function<T()> &_recalcMethod,
     309      std::string name,
     310      const Observable::channels_t &_channels) :
    302311    Observer(name),
    303312    recalcMethod(_recalcMethod)
Note: See TracChangeset for help on using the changeset viewer.