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/Observable.hpp

    r1b5188 r454bc54  
    4545class Observable : public Observer {
    4646public:
    47   Observable(std::string _name);
     47  //!> typedef for a vector of channels
     48  typedef std::vector<size_t> channels_t;
     49
     50  Observable(std::string _name, const channels_t &_channels = channels_t());
    4851  virtual ~Observable();
    4952
     
    6366    static range<int> ValidRange;
    6467  };
     68
     69private:
     70  /** Helper class to create a unique increasing list.
     71   *
     72   */
     73  struct UniqueNumber
     74  {
     75    int operator()()
     76    { return value++; }
     77    int value;
     78  };
     79
     80public:
     81  static channels_t getChannelList(const size_t max);
    6582
    6683  /**
     
    86103   * Sign on for specialized notifications
    87104   */
    88   virtual void signOn(Observer *target, size_t channelno) const;
     105  virtual void signOn(
     106      Observer *target,
     107      size_t channelno,
     108      PriorityLevel priority = PriorityDefault) const;
    89109
    90110  /**
Note: See TracChangeset for help on using the changeset viewer.