-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
61 lines (51 loc) · 1.78 KB
/
Copy pathmain.cpp
File metadata and controls
61 lines (51 loc) · 1.78 KB
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
#include "Lifeguard.h"
#include "library.cpp"
#include "clockthread.cpp"
using namespace std;
int main()
{
// Create a TimeData structure to hold the time values
TimeData timeData;
// Create a mutex to synchronize access to the TimeData structure
std::mutex dataMutex;
// Starts the clock thread and detaches it so that the clock runs separately in the background
thread clockThread(updateClock, std::ref(timeData), std::ref(dataMutex));
clockThread.detach();
// Create a vector to hold lifeguards in rotation
vector<Lifeguard> rotation;
// Flag to track if rotation has started
bool rotationStarted = false;
while (true)
{
// Issue with this is that it's the first in the line. I think i need to put this in it's own thread
// if(timeData.minute == 30 || timeData.minute == 0 || timeData.minute == 60)
// UpdateList(rotation, timeData);
// Get user input for operation
string input = opt();
if (input == "list")
{
// Call the function to list lifeguards in rotation
list(rotation);
} else if (input == "update")
{
UpdateList(rotation, timeData);
} else if (input == "add")
{
// Call the function to add a lifeguard to rotation
add(rotation, timeData);
} else if (input == "remove")
{
// Call the function to remove a lifeguard from rotation
remove(rotation);
} else if (input == "swap")
{
// Call the function to swap lifeguards in rotation
swap(rotation);
} else if (input == "end")
{
// Exit the program
return 0;
}
}
// The loop is infinite, so this point is never reached.
}