/* * ObserverStub.hpp * * Created on: Jan 16, 2011 * Author: heber */ #ifndef OBSERVERSTUB_HPP_ #define OBSERVERSTUB_HPP_ #include "CodePatterns/Observer/Observer.hpp" #include "CodePatterns/Observer/Observable.hpp" #include "CodePatterns/Observer/ObservedIterator.hpp" #include "CodePatterns/Observer/Relay.hpp" class UpdateCountObserver : public Observer { public: UpdateCountObserver(); virtual ~UpdateCountObserver(); void update(Observable *publisher); void subjectKilled(Observable *publisher); int updates; }; class SimpleObservable : public Observable { public: SimpleObservable(); void changeMethod(); }; class CallObservable : public Observable { public: CallObservable(); void changeMethod1(); void changeMethod2(); }; class BlockObservable : public Observable { public: BlockObservable(); void changeMethod1(); void changeMethod2(); void internalMethod1(); void internalMethod2(); void noChangeMethod(); }; class SuperObservable : public Observable { public: SuperObservable(); virtual ~SuperObservable(); void changeMethod(); SimpleObservable *subObservable; }; class NotificationObservable : public Observable { public: NotificationObservable(); virtual ~NotificationObservable(); enum NotificationType { Operation1Notify = 0, Operation2Notify = 1 }; void operation1(); void operation2(); }; class NotificationObserver : public Observer { public: NotificationObserver(Notification_ptr notification); virtual ~NotificationObserver(); void update(Observable*); void subjectKilled(Observable*); void recieveNotification(Observable *publisher, Notification_ptr notification); Notification_ptr requestedNotification; bool wasNotified; }; class ObservableSet : public Observable { public: typedef std::set set; typedef ObservedIterator iterator; typedef set::const_iterator const_iterator; ObservableSet(int _num); virtual ~ObservableSet(); iterator begin(); iterator end(); const int num; private: set theSet; }; class ObservableMap : public Observable { public: typedef std::map set; typedef ObservedIterator iterator; typedef set::const_iterator const_iterator; ObservableMap(int _num); virtual ~ObservableMap(); iterator begin(); iterator end(); const int num; private: set theSet; }; class RelayTest : public Relay { public: RelayTest(); ~RelayTest(); private: }; class RelayCountObserver : public Observer { public: RelayCountObserver(const Observable * const relay); virtual ~RelayCountObserver(); void update(Observable *publisher); void subjectKilled(Observable *publisher); int updates; private: const Observable * const relay; }; class RelayNotification : public Relay { public: RelayNotification(); ~RelayNotification(); private: }; class RelayNotificationObserver : public Observer { public: RelayNotificationObserver(const Observable * const _relay); virtual ~RelayNotificationObserver(); void update(Observable*); void subjectKilled(Observable*); void recieveNotification(Observable *publisher, Notification_ptr notification); bool wasNotified; private: const Observable * const relay; }; #endif /* OBSERVERSTUB_HPP_ */