-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCCellGrid.h
More file actions
80 lines (50 loc) · 1.77 KB
/
CCellGrid.h
File metadata and controls
80 lines (50 loc) · 1.77 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef _CCELLGRID_H_
#define _CCELLGRID_H_
#include "includer.h"
#include "CCell.h"
class CCellGrid
{
public:
enum GridState {
GRID_CALC = 0,
GRID_INTERMED
};
private:
CCellGrid();
uint16_t rows;
uint16_t cols;
uint32_t generation;
bool calculating;
GridState state;
std::vector< std::vector< CCell* > > Grid;
std::map< CCell*, bool > Changed;
public:
CCellGrid( uint16_t rows, uint16_t cols );
~CCellGrid();
uint16_t getRows() { return rows; }
uint16_t getCols() { return cols; }
uint32_t getGeneration() { return generation; }
bool isCalculating() { return calculating; }
GridState getState() { return state; }
void setState( GridState newState ) { state = newState; }
CCell* getCellAt( uint16_t row, uint16_t col );
CCell::CCellState getStateAt( uint16_t row, uint16_t col );
std::map< CCell*, bool>* getChanged() { return &Changed; }
uint8_t getSurrounding( CCell* cell );
uint8_t getSurrounding( uint16_t row, uint16_t col );
void setCellState( CCell* cell, bool alive );
void setCellAt( uint16_t row, uint16_t col, bool alive );
bool getRule( CCell* cell, uint8_t amt );
void calcChanges();
void setIntermediate();
//Half-step
void nextState();
//Full next step
void nextStep();
friend std::ostream& operator<< ( std::ostream& out, CCellGrid& cg );
bool toFile( const std::string outfile );
static CCellGrid* fromFile( const std::string infile, CCellGrid* cg = NULL );
void clearGrid();
void reset();
}; //CCellGrid
#endif // _CCELLGRID_H_