source: src/Patterns/unittests/stubs/ObserverStub.hpp@ 451f17

Last change on this file since 451f17 was 56d62f, checked in by Frederik Heber <heber@…>, 15 years ago

Placed various Observer stubs into own module.

  • Library version is now 4:0:1, API version is still 1.0.7.
  • the stubs are also much easier to read when declared additionally in a header file.
  • Property mode set to 100644
File size: 2.1 KB
Line 
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
11#include "Observer.hpp"
12#include "ObservedIterator.hpp"
13
14class UpdateCountObserver : public Observer {
15public:
16 UpdateCountObserver();
17 void update(Observable *publisher);
18 void subjectKilled(Observable *publisher);
19
20 int updates;
21};
22
23class SimpleObservable : public Observable {
24public:
25 SimpleObservable();
26
27 void changeMethod();
28};
29
30class CallObservable : public Observable {
31public:
32 CallObservable();
33
34 void changeMethod1();
35 void changeMethod2();
36};
37
38class BlockObservable : public Observable {
39public:
40 BlockObservable();
41
42 void changeMethod1();
43 void changeMethod2();
44
45 void internalMethod1();
46 void internalMethod2();
47
48 void noChangeMethod();
49};
50
51class SuperObservable : public Observable {
52public:
53 SuperObservable();
54 ~SuperObservable();
55
56 void changeMethod();
57
58 SimpleObservable *subObservable;
59};
60
61class NotificationObservable : public Observable {
62public:
63 NotificationObservable();
64 ~NotificationObservable();
65
66 void operation1();
67 void operation2();
68
69 Notification_ptr notification1;
70 Notification_ptr notification2;
71};
72
73class NotificationObserver : public Observer {
74public:
75 NotificationObserver(Notification_ptr notification);
76
77 void update(Observable*);
78 void subjectKilled(Observable*);
79 void recieveNotification(Observable *publisher, Notification_ptr notification);
80
81 Notification_ptr requestedNotification;
82
83 bool wasNotified;
84};
85
86class ObservableSet : public Observable {
87public:
88 typedef std::set<SimpleObservable*> set;
89 typedef ObservedIterator<set> iterator;
90 typedef set::const_iterator const_iterator;
91
92 ObservableSet(int _num);
93 ~ObservableSet();
94
95 iterator begin();
96 iterator end();
97
98 const int num;
99
100private:
101 set theSet;
102};
103
104class ObservableMap : public Observable {
105public:
106 typedef std::map<int,SimpleObservable*> set;
107 typedef ObservedIterator<set> iterator;
108 typedef set::const_iterator const_iterator;
109
110 ObservableMap(int _num);
111 ~ObservableMap();
112
113 iterator begin();
114 iterator end();
115
116 const int num;
117
118private:
119 set theSet;
120};
121
122
123#endif /* OBSERVERSTUB_HPP_ */
Note: See TracBrowser for help on using the repository browser.