Ignore:
Timestamp:
Oct 30, 2015, 11:43:01 AM (10 years ago)
Author:
Frederik Heber <heber@…>
Children:
e24dde
Parents:
1b5188
git-author:
Frederik Heber <heber@…> (06/19/15 22:28:24)
git-committer:
Frederik Heber <heber@…> (10/30/15 11:43:01)
Message:

Added new pattern ObservedValue, contrary to Cacheable.

  • essentially updates immediately and caches a value for off-line use, safe- guard with mutexes.
  • added unit test for ObservedValue.
  • factored threeNumbers stub out of CacheableUnitTest, also used the stub in ObservedValueUnitTest.
  • we may now signOn() to Notification with a priority.
  • Cacheable can also update now via notification channels not just for global updates.
  • Observable can now also instantiate the channels directly if given a list. This was necessary as Cacheable or ObservedValue are instantiated in the constructor, too, and if listening to channels, these must already be present.
  • FIX: Channels::addChannels() used NDEBUG wrong way round.
  • ObservedValue::get() returns reference.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodePatterns/Observer/Notification.hpp

    r1b5188 r454bc54  
    1515
    1616#include <set>
     17
     18#include <boost/thread/recursive_mutex.hpp>
    1719
    1820class Channels;
     
    4143protected:
    4244
    43   void addObserver(Observer *target);
     45  void addObserver(Observer *target, const int priority);
    4446  void removeObserver(Observer *target);
    4547
     
    7375
    7476private:
    75   typedef std::set<Observer*> targets_t;
     77  typedef std::multimap<int,Observer*> targets_t;
    7678  targets_t targets;
    7779  const size_t channelno;
     80
     81  mutable boost::recursive_mutex TargetsLock; //!< a lock for the pointer of the instance
    7882};
    7983
Note: See TracChangeset for help on using the changeset viewer.