source: src/Patterns/Observer/unittests/stubs/ObserverStub.hpp@ 549b62

Last change on this file since 549b62 was e2e035e, checked in by Frederik Heber <heber@…>, 14 years ago

Refactored all Observer stuff into own subfolder and split up into distinct modules.

  • Observer/all.hpp is all that's needed.
  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[56d62f]1/*
2 * ObserverStub.hpp
3 *
4 * Created on: Jan 16, 2011
5 * Author: heber
6 */
7
8#ifndef OBSERVERSTUB_HPP_
9#define OBSERVERSTUB_HPP_
10
[e2e035e]11#include "Observer/Observer.hpp"
12#include "Observer/Observable.hpp"
13#include "Observer/ObservedIterator.hpp"
[56d62f]14
15class UpdateCountObserver : public Observer {
16public:
17 UpdateCountObserver();
[74e0f7]18 virtual ~UpdateCountObserver();
19
[56d62f]20 void update(Observable *publisher);
21 void subjectKilled(Observable *publisher);
22
23 int updates;
24};
25
26class SimpleObservable : public Observable {
27public:
28 SimpleObservable();
29
30 void changeMethod();
31};
32
33class CallObservable : public Observable {
34public:
35 CallObservable();
36
37 void changeMethod1();
38 void changeMethod2();
39};
40
41class BlockObservable : public Observable {
42public:
43 BlockObservable();
44
45 void changeMethod1();
46 void changeMethod2();
47
48 void internalMethod1();
49 void internalMethod2();
50
51 void noChangeMethod();
52};
53
54class SuperObservable : public Observable {
55public:
56 SuperObservable();
[74e0f7]57 virtual ~SuperObservable();
[56d62f]58
59 void changeMethod();
60
61 SimpleObservable *subObservable;
62};
63
64class NotificationObservable : public Observable {
65public:
66 NotificationObservable();
[74e0f7]67 virtual ~NotificationObservable();
68
69 enum NotificationType {
70 Operation1Notify = 0,
71 Operation2Notify = 1
72 };
[56d62f]73
74 void operation1();
75 void operation2();
76};
77
78class NotificationObserver : public Observer {
79public:
80 NotificationObserver(Notification_ptr notification);
[74e0f7]81 virtual ~NotificationObserver();
[56d62f]82
83 void update(Observable*);
84 void subjectKilled(Observable*);
85 void recieveNotification(Observable *publisher, Notification_ptr notification);
86
87 Notification_ptr requestedNotification;
88
89 bool wasNotified;
90};
91
92class ObservableSet : public Observable {
93public:
94 typedef std::set<SimpleObservable*> set;
95 typedef ObservedIterator<set> iterator;
96 typedef set::const_iterator const_iterator;
97
98 ObservableSet(int _num);
[74e0f7]99 virtual ~ObservableSet();
[56d62f]100
101 iterator begin();
102 iterator end();
103
104 const int num;
105
106private:
107 set theSet;
108};
109
110class ObservableMap : public Observable {
111public:
112 typedef std::map<int,SimpleObservable*> set;
113 typedef ObservedIterator<set> iterator;
114 typedef set::const_iterator const_iterator;
115
116 ObservableMap(int _num);
[74e0f7]117 virtual ~ObservableMap();
[56d62f]118
119 iterator begin();
120 iterator end();
121
122 const int num;
123
124private:
125 set theSet;
126};
127
128
129#endif /* OBSERVERSTUB_HPP_ */
Note: See TracBrowser for help on using the repository browser.