Ignore:
Timestamp:
Sep 1, 2011, 11:07:47 AM (14 years ago)
Author:
Frederik Heber <heber@…>
Children:
9e776f
Parents:
451f17
git-author:
Frederik Heber <heber@…> (09/01/11 11:02:49)
git-committer:
Frederik Heber <heber@…> (09/01/11 11:07:47)
Message:

Extended Observables by NotificationChannels member variable.

  • new class Channels that aggregates Notifications.
  • NOTIFY now just takes a channel number.
  • may or may not be instantiated for a given Observable.
  • Observable just needs to add enum of all desired channels and addChannel on each of these.
  • ObserverUnitTest has been adapted.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/unittests/ObserverUnitTest.cpp

    r451f17 r74e0f7  
    6161  observer4 = new UpdateCountObserver();
    6262
    63   notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
    64   notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
     63  notificationObserver1 = new NotificationObserver(
     64      notificationObservable->getChannel(NotificationObservable::Operation1Notify));
     65  notificationObserver2 = new NotificationObserver(
     66      notificationObservable->getChannel(NotificationObservable::Operation2Notify));
    6567}
    6668
     
    157159
    158160void ObserverTest::doesNotifyTest(){
     161  CPPUNIT_ASSERT_EQUAL(
     162      (size_t)NotificationObservable::Operation1Notify,
     163      notificationObservable->getChannel(NotificationObservable::Operation1Notify)->getChannelNo());
     164  CPPUNIT_ASSERT_EQUAL(
     165      (size_t)NotificationObservable::Operation2Notify,
     166      notificationObservable->getChannel(NotificationObservable::Operation2Notify)->getChannelNo());
    159167  notificationObservable->signOn(notificationObserver1,
    160                                  notificationObservable->notification1);
     168                                 notificationObservable->getChannel(NotificationObservable::Operation1Notify));
    161169  notificationObservable->signOn(notificationObserver2,
    162                                  notificationObservable->notification2);
     170                                 notificationObservable->getChannel(NotificationObservable::Operation2Notify));
    163171
    164172  notificationObservable->operation1();
Note: See TracChangeset for help on using the changeset viewer.