-
Notifications
You must be signed in to change notification settings - Fork 0
/
StateManager.h
43 lines (35 loc) · 1004 Bytes
/
StateManager.h
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
#ifndef STATE_MANAGER_H
#define STATE_MANAGER_H
#include <string>
enum NetworkState {
DISCONNECTED,
CONNECTING,
HUB_NETWORK,
CUSTOM_NETWORK,
CAPTIVE_PORTAL
};
class StateManager {
private:
NetworkState networkState;
public:
StateManager() : networkState(DISCONNECTED) {}
void updateNetworkState(NetworkState newState) {
if (networkState != newState) {
networkState = newState;
}
}
NetworkState getNetworkState() const {
return networkState;
}
std::string getNetworkStateString() const {
switch (networkState) { // Correct variable name used
case DISCONNECTED: return "DISCONNECTED";
case CONNECTING: return "CONNECTING";
case HUB_NETWORK: return "HUB_NETWORK";
case CUSTOM_NETWORK: return "CUSTOM_NETWORK";
case CAPTIVE_PORTAL: return "CAPTIVE_PORTAL";
default: return "UNKNOWN_STATE";
}
}
};
#endif // STATE_MANAGER_H