-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp.orig
384 lines (294 loc) · 16.5 KB
/
main.cpp.orig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#include <iostream>
#include "EmergencyCenter.h"
#include "main.h"
#include "mail.h"
using namespace std;
int main()
{
/*
************************************************************ SCENARIO 3 - Sam ************************************************************
*/
auto *twig = EmergencyCenter::getInstance();
auto Galaxy= make_shared<Location>("twix galaxy");
auto planet1= make_shared<Location>("X AE A-12");
auto planet2=make_shared<Location>("LV-426");
auto orange_volcano=make_shared<Location>("redstone");
auto red_volcano= make_shared<Location>("orangestone");
auto Moon_unit= make_shared<Location>("Moon Unit");
auto Dweezil=make_shared<Location>("Dweezil");
auto sensor_galaxy= make_shared<MotionSensor>("nokia", "twig galaxy");
auto redstone_smoke= make_shared<SmokeSensor>("alcatel", "red volcano");
auto orangestone_smoke= make_shared<SmokeSensor>("alcatel", "orange stone");
auto sensor_planet1 = make_shared<SmokeSensor>("Disney","X AE A-12");
auto oxygen_sensor= make_shared<SmokeSensor>("samsung", "LV-426");
auto motion_planet2= make_shared<MotionSensor>("Disney", "LV-426");
auto motion_dweezil = make_shared<MotionSensor>("Disney", "Dweezil", 20, 8);
auto motion_moon= make_shared<MotionSensor>("Disney", "Moon Unit",20, 8);
auto smoke_dweezil= make_shared<SmokeSensor>("Disney", "Dweezil");
auto smoke_moon= make_shared<SmokeSensor>("Disney", "Moon Unit");
twig->add(Galaxy);
twig->addChildToParent(Galaxy, sensor_galaxy);
twig->addChildToParent(Galaxy, planet1);
twig->addChildToParent(Galaxy, planet2);
twig->addChildToParent(planet1, orange_volcano);
twig->addChildToParent(orange_volcano, orangestone_smoke);
twig->addChildToParent(planet1, sensor_planet1);
twig->addChildToParent(planet1, red_volcano);
twig->addChildToParent(red_volcano, redstone_smoke);
twig->addChildToParent(planet2, oxygen_sensor);
twig->addChildToParent(planet2, motion_planet2);
twig->addChildToParent(planet2, Dweezil);
twig->addChildToParent(Dweezil, motion_dweezil);
twig->addChildToParent(Dweezil, smoke_dweezil);
twig->addChildToParent(planet2, Moon_unit);
twig->addChildToParent(Moon_unit, motion_moon);
twig->addChildToParent(Moon_unit, smoke_moon);
auto peacekeeping_warning= std::make_shared<Mail>("warning", "peacekeeping force");
sensor_galaxy->addStrategy(peacekeeping_warning);
auto alarm_planet1 = std::make_shared<Alarm>("X AE A-12");
auto scientist_warning = std::make_shared<Mail>(" Eletronic message", "Scientists");
sensor_planet1->addStrategy(scientist_warning);
sensor_planet1->addStrategy(alarm_planet1);
auto magma_cooling = make_shared<Activation>("magma_cooling spinklers");
redstone_smoke->addStrategy(magma_cooling);
orangestone_smoke->addStrategy(magma_cooling);
motion_planet2->addStrategy(peacekeeping_warning);
motion_planet2->addStrategy(scientist_warning);
auto alarm_planet2 = std::make_shared<Alarm>("LV-426");
oxygen_sensor->addStrategy(alarm_planet2);
auto fire = make_shared<Mail>("alert", "fire fighters");
smoke_dweezil->addStrategy(fire);
smoke_moon->addStrategy(fire);
auto eggs= make_shared<Mail>("alert", "us (the eggs are hatching");
twig->overviewSensors();
cout << "----------------TEST 1-----------------" << endl;
++*oxygen_sensor;
++*sensor_planet1;
cout << "----------------TEST 1 : RESULTS-----------------" << endl;
twig->testAllByLocationPointer(Galaxy);
--*oxygen_sensor;
--*sensor_planet1;
cout << "----------------TEST 2-----------------" << endl;
twig->activateAllByLocationPointer(planet1);
cout << "----------------TEST 2 : RESULTS-----------------" << endl;
twig->testAllByLocationPointer(Galaxy);
cout << "----------------TEST 3-----------------" << endl;
twig->deActivateAllByLocationPointer(planet2);
cout << "----------------TEST 3 : RESULTS-----------------" << endl;
twig->testAllByLocationPointer(planet2);
twig->overviewByLocationPointer(planet2);
cout << "----------------TEST 4-----------------" << endl;
twig->activateAllByLocationPointer(planet2);
cout << "----------------TEST 4 : RESULTS-----------------" << endl;
twig->testAllByLocationPointer(planet2);
cout << "------------------------------------------------------" << endl;
twig->testAllByLocationPointer(Moon_unit);
cout << "------------------------------------------------------" << endl;
twig->testAllByLocationPointer(Dweezil);
cout << "----------------TEST 5-----------------" << endl;
twig->overviewSensors();
cout << "end of program" << endl;
return 0;
/*
auto *GTCenter = EmergencyCenter::getInstance();
Location GT{"Group T"};
Location labChem{"Lab Chemistry 5.01"};
Location labElec1{"Lab Electronics 10.01"};
Location labElec2{"Lab Electronics 10.02"};
Location kitchen{"Alma kitchen"};
SmokeSensor sensor1{"Sensor Solution", "Lab Chemistry 5.01"};
GasSensor sensor2{"GasSense", "Lab Chemistry 5.01"};
SmokeSensor sensor3{"Sensor Solution", "Lab Electronics 10.01"};
MotionSensor sensor4{"GotYou", "Lab Electronics 10.01", 22, 7};
MotionSensor sensor5{"GotYou", "Lab Electronics 10.02", 22, 7};
SmokeSensor sensor6{"Kitchensafe", "Alma kitchen"};
GasSensor sensor7{"KitchenSafe", "Alma kitchen"};
MotionSensor sensor8{"BigBrother Is Watching You", "Alma kitchen"};
GTCenter->add(make_shared<Location>(GT));
twig->addLocation(make_shared<Location>(Galaxy));
twig->addChildToParent(make_shared<Location>(Galaxy), make_shared<Sensor>(sensor1));
GTCenter->addChildToParent(make_shared<Location>(GT), make_shared<Location>(labChem));
GTCenter->add(make_shared<Location>(labChem));
GTCenter->addChildToParent(make_shared<Location>(labChem), make_shared<Sensor>(sensor1));
GTCenter->addChildToParent(make_shared<Location>(labChem), make_shared<Sensor>(sensor2));
twig->addLocation(make_shared<Location>(Galaxy));
twig->addChildToParent(make_shared<Location>(Galaxy), make_shared<Sensor>(sensor_twig));
Alarm alarmChem1{"building"};
Contact messageChem{"KULeuven central dispatch"};
Alarm alarmChem2{"Lab Chemistry 5.01"};
sensor1.addStrategy(make_shared<Alarm>(alarmChem1));
twig->addChildToParent(make_shared<Location>(Galaxy), make_shared<Location>(planet2));
twig->addChildToParent(make_shared<Location>(planet1), make_shared<Location>(orange_volcano));
twig->addChildToParent(make_shared<Location>(planet1), make_shared<Location>(red_volcano));
twig->addChildToParent(make_shared<Location>(orange_volcano), make_shared<Sensor>(orangestone_smoke));
twig->addChildToParent(make_shared<Location>(red_volcano), make_shared<Sensor>(redstone_smoke));
GTCenter->addLocation(make_shared<Location>(labElec1));
GTCenter->addChildToParent(make_shared<Location>(GT), make_shared<Location>(labElec1));
GTCenter->addChildToParent(make_shared<Location>(labElec1), make_shared<Sensor>(sensor3));
GTCenter->addChildToParent(make_shared<Location>(labElec1), make_shared<Sensor>(sensor4));
twig->addChildToParent(make_shared<Location>(planet1), make_shared<Location>(orange_volcano));
twig->addChildToParent(make_shared<Location>(planet1), make_shared<Location>(red_volcano));
twig->addChildToParent(make_shared<Location>(planet2), make_shared<Sensor>(sensor_oxygen));
twig->addChildToParent(make_shared<Location>(orange_volcano), make_shared<Sensor>(orangestone_smoke));
twig->addChildToParent(make_shared<Location>(red_volcano), make_shared<Sensor>(redstone_smoke));
//twig->overviewSensors();
twig->overviewByLocation("twig galaxy");
twig->addChildToParent(make_shared<Location>(Galaxy), make_shared<Location>(planet2));
twig->addChildToParent(make_shared<Location>(planet2), make_shared<Sensor>(sensor3));
twig->overviewSensors();
//twig->overviewByLocation("LV-426");
cout << "end of program" << endl;
return 0;
GTCenter->add(make_shared<Location>(labElec2));
GTCenter->addChildToParent(make_shared<Location>(GT), make_shared<Location>(labElec2));
GTCenter->addChildToParent(make_shared<Location>(labElec2), make_shared<Sensor>(sensor5));
twig->addChildToParent(make_shared<Location>(Galaxy), make_shared<Location>(planet2));
twig->addChildToParent(make_shared<Location>(planet2), make_shared<Sensor>(sensor3));
//twig->overviewByLocation("LV-426");
cout << "end of program" << endl;
return 0;
GTCenter->add(make_shared<Location>(kitchen));
GTCenter->addChildToParent(make_shared<Location>(GT), make_shared<Location>(kitchen));
GTCenter->addChildToParent(make_shared<Location>(kitchen), make_shared<Sensor>(sensor6));
GTCenter->addChildToParent(make_shared<Location>(kitchen), make_shared<Sensor>(sensor7));
GTCenter->addChildToParent(make_shared<Location>(kitchen), make_shared<Sensor>(sensor8));
*/
/*
************************************************************ SCENARIO 2 - Louise ************************************************************
*/
/*
auto* instanceEmergencyCenter = EmergencyCenter::getInstance();
auto residentialArea = make_shared<Location>("Residential Area");
auto house1 = make_shared<Location>("House of John and Vicky");
auto shed = make_shared<Location>("Shed of John");
auto kitchen = make_shared<Location>("Kitchen of Vicky");
auto house2 = make_shared<Location>("House of Dave");
auto livingRoom = make_shared<Location>("Living room of Dave");
auto house3 = make_shared<Location>("House of Kaitlin");
auto lab = make_shared<Location>("Lab of Kaitlin");
*/
//TODO: change the share pointer to the specific sensor it is.
//TODO: change the sensor classes to have a constructor that also includes the type of sensor
/*
* Initializing Sensors
*/
/*
auto smokeSensor1 = std::make_shared<Sensor>("Smokey", "John's shed");
auto motionSensor1 = std::make_shared<Sensor>("IcanCU", "John's shed");
auto smokeSensor2 = std::make_shared<Sensor>("Smokey", "Vicky's kitchen");
auto motionSensor2 = std::make_shared<Sensor>("IcanCU", "Vicky's kitchen");
auto gasSensor1 = std::make_shared<Sensor>("BreatheLabs", "Dave's living room");
auto smokeSensor3 = std::make_shared<Sensor>("BurningInc", "Dave's living room");
auto gasSensor2 = std::make_shared<Sensor>("TN2S", "Kaitlin's house");
auto motionSensor3 = std::make_shared<Sensor>("IcanCU", "Kaitlin's lab");
//TODO: configure the alarms per sensor location
*/
/*
* Building the heirarchy - adding locations and sensors to a locations
*/
/*
instanceEmergencyCenter->add(residentialArea);
instanceEmergencyCenter->addChildToParent(residentialArea, house1);
instanceEmergencyCenter->addChildToParent(house1, shed);
instanceEmergencyCenter->addChildToParent(shed, smokeSensor1);
instanceEmergencyCenter->addChildToParent(shed, motionSensor1);
instanceEmergencyCenter->addChildToParent(house1, kitchen);
instanceEmergencyCenter->addChildToParent(kitchen, smokeSensor2);
instanceEmergencyCenter->addChildToParent(kitchen, motionSensor2);
instanceEmergencyCenter->addChildToParent(residentialArea, house2);
instanceEmergencyCenter->addChildToParent(house2, livingRoom);
instanceEmergencyCenter->addChildToParent(livingRoom, gasSensor1);
instanceEmergencyCenter->addChildToParent(livingRoom, smokeSensor3);
instanceEmergencyCenter->addChildToParent(residentialArea, house3);
instanceEmergencyCenter->addChildToParent(house3, gasSensor2);
instanceEmergencyCenter->addChildToParent(house3, lab);
instanceEmergencyCenter->addChildToParent(lab, motionSensor3);
<<<<<<< HEAD
cout<< "------------------------ TEST 1: activate and test the smoke sensor in the shed -----------------------" << endl;
=======
instanceEmergencyCenter->overviewSensors();
//cout<< "******" <<endl;
//instanceEmergencyCenter->overviewByLocation("John's shed");
//cout<< "******" <<endl;
//instanceEmergencyCenter->overviewByLocation("Vicky's kitchen");
//cout<< "******" <<endl;
//instanceEmergencyCenter->overviewByLocation("Dave's living room");
//cout<< "******" <<endl;
//instanceEmergencyCenter->overviewByLocation("Kaitlin's house");
//cout<< "******" <<endl;
//instanceEmergencyCenter->overviewByLocation("Kaitlin's lab");
//cout<< "******" <<endl;
//instanceEmergencyCenter->overviewByVendor("IcanCU");
*/
/*
cout<< "------------------------ TEST 1 -----------------------" << endl;
>>>>>>> c140e76717fa81c4f901651b69f7d628e26a6012
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocation("John's shed");
//--- Start of code to be tested ---
instanceEmergencyCenter->activateSpecificSensor(smokeSensor1->getSensorID());
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocation("John's shed");
cout<< "------------------------ TEST 2: activate and test all sensors in Vicky and John’s house -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(house1);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->activateAllByLocationPointer(house1);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(house1);
cout<< "------------------------ TEST 3: test all sensors in the neighborhood -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->testAllByLocationPointer(residentialArea);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 4: activate all sensors using the ++ operator -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->activateAllComponents();
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 5: test the whole neighborhood -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->testAllByLocationPointer(residentialArea);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 6: test the mad scientist’s house -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->testAllByLocationPointer(house3);
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------------------------ TEST 7: give an overview of all sensors ordered by id -----------------------" << endl;
cout<< "------ Before ------" << endl;
instanceEmergencyCenter->overviewByLocationPointer(residentialArea);
cout<< "------ Test Output ------" << endl;
//--- Start of code to be tested ---
instanceEmergencyCenter->overviewSensorsInVector(instanceEmergencyCenter->orderByLocation(instanceEmergencyCenter->getSensorList()));
//--- End of code to be tested ---
cout<< "------ After ------" << endl;
//instanceEmergencyCenter->overviewSensorsInVector(instanceEmergencyCenter->orderByLocation(instanceEmergencyCenter->getSensorList()));
//instanceEmergencyCenter->deActivateAllByLocationPointer(house3);
instanceEmergencyCenter->deActivateSpecificSensor(3);
instanceEmergencyCenter->overviewSensors();
cout << "end of program" << endl;
return 0;
*/
}
/*some random comment*/