-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstate_mach.h
59 lines (44 loc) · 872 Bytes
/
state_mach.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef INCLUDED_STATE_MACH
#define INCLUDED_STATE_MACH
enum RAFT_STATE {
RAFT_STATE_NONE,
RAFT_STATE_FOLLOWER,
RAFT_STATE_CANDIDATE,
RAFT_STATE_LEADER
};
namespace Raft {
class State {
RAFT_STATE d_state;
public:
/**
* @brief This creates a defualt constrcuted state object.
* The default state is NONE
*/
State();
/**
* @brief The default destructor
*/
virtual ~State();
/**
* @brief Return true iff state is leader
*/
bool is_leader();
/**
* @brief Returns true iff state is follower
*/
bool is_follower();
/**
* @brief Returns true iff state is candidate
*/
bool is_candidate();
/**
* @brief Sets the state of this object
*/
void set(RAFT_STATE state);
/**
* @brief Gets the current state of the object
*/
RAFT_STATE get();
};
} //namespace Raft
#endif