-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.h
60 lines (44 loc) · 1.14 KB
/
Cell.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
60
#pragma once
#include <stdint.h>
#include "CellPosition.h"
enum class CellState {
alive,
dead,
};
/**
Lifecycle of a cell:
1) exist - determine the status of the cell on the next cycle
2) commitFate - fulfill its destiny. a.k.a _currentState becomes what it was fated to become
*/
class Cell {
public:
Cell(const CellState &state, uint32_t posX, uint32_t posY) :
_currentState(state),
_nextState(CellState::dead),
_position(posX, posY) {}
CellState getCurrentState() const {
return _currentState;
}
CellState getNextState() const {
return _nextState;
}
void commitFate() {
_currentState = _nextState;
}
uint32_t getPosX() const {
return _position.posX;
}
uint32_t getPosY() const {
return _position.posY;
}
void setCurrentState(const CellState &state) {
_currentState = state;
}
void setNextState(const CellState &state) {
_nextState = state;
}
private:
CellState _currentState;
CellState _nextState;
Position _position;
};