source: ThirdParty/CodePatterns/src/Observer/unittests/stubs/ObserverStub.hpp@ 41e8e2

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 41e8e2 was 41e8e2, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '084729c5923f0123e695fbe2548b393288c1f13d' as 'ThirdParty/CodePatterns'

  • Property mode set to 100644
File size: 3.2 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 "CodePatterns/Observer/Observer.hpp"
12#include "CodePatterns/Observer/Observable.hpp"
13#include "CodePatterns/Observer/ObservedIterator.hpp"
14#include "CodePatterns/Observer/Relay.hpp"
15
16class UpdateCountObserver : public Observer {
17public:
18 UpdateCountObserver();
19 virtual ~UpdateCountObserver();
20
21 void update(Observable *publisher);
22 void subjectKilled(Observable *publisher);
23
24 int updates;
25};
26
27class SimpleObservable : public Observable {
28public:
29 SimpleObservable();
30
31 void changeMethod();
32};
33
34class CallObservable : public Observable {
35public:
36 CallObservable();
37
38 void changeMethod1();
39 void changeMethod2();
40};
41
42class BlockObservable : public Observable {
43public:
44 BlockObservable();
45
46 void changeMethod1();
47 void changeMethod2();
48
49 void internalMethod1();
50 void internalMethod2();
51
52 void noChangeMethod();
53};
54
55class SuperObservable : public Observable {
56public:
57 SuperObservable();
58 virtual ~SuperObservable();
59
60 void changeMethod();
61
62 SimpleObservable *subObservable;
63};
64
65class NotificationObservable : public Observable {
66public:
67 NotificationObservable();
68 virtual ~NotificationObservable();
69
70 enum NotificationType {
71 Operation1Notify = 0,
72 Operation2Notify = 1
73 };
74
75 void operation1();
76 void operation2();
77};
78
79class NotificationObserver : public Observer {
80public:
81 NotificationObserver(Notification_ptr notification);
82 virtual ~NotificationObserver();
83
84 void update(Observable*);
85 void subjectKilled(Observable*);
86 void recieveNotification(Observable *publisher, Notification_ptr notification);
87
88 Notification_ptr requestedNotification;
89
90 bool wasNotified;
91};
92
93class ObservableSet : public Observable {
94public:
95 typedef std::set<SimpleObservable*> set;
96 typedef ObservedIterator<set> iterator;
97 typedef set::const_iterator const_iterator;
98
99 ObservableSet(int _num);
100 virtual ~ObservableSet();
101
102 iterator begin();
103 iterator end();
104
105 const int num;
106
107private:
108 set theSet;
109};
110
111class ObservableMap : public Observable {
112public:
113 typedef std::map<int,SimpleObservable*> set;
114 typedef ObservedIterator<set> iterator;
115 typedef set::const_iterator const_iterator;
116
117 ObservableMap(int _num);
118 virtual ~ObservableMap();
119
120 iterator begin();
121 iterator end();
122
123 const int num;
124
125private:
126 set theSet;
127};
128
129class RelayTest : public Relay
130{
131public:
132 RelayTest();
133 ~RelayTest();
134private:
135};
136
137class RelayCountObserver : public Observer {
138public:
139 RelayCountObserver(const Observable * const relay);
140 virtual ~RelayCountObserver();
141
142 void update(Observable *publisher);
143 void subjectKilled(Observable *publisher);
144
145 int updates;
146private:
147 const Observable * const relay;
148};
149
150class RelayNotification : public Relay
151{
152public:
153 RelayNotification();
154 ~RelayNotification();
155private:
156};
157
158class RelayNotificationObserver : public Observer {
159public:
160 RelayNotificationObserver(const Observable * const _relay);
161 virtual ~RelayNotificationObserver();
162
163 void update(Observable*);
164 void subjectKilled(Observable*);
165 void recieveNotification(Observable *publisher, Notification_ptr notification);
166
167 bool wasNotified;
168private:
169 const Observable * const relay;
170};
171
172#endif /* OBSERVERSTUB_HPP_ */
Note: See TracBrowser for help on using the repository browser.