-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
76 lines (68 loc) · 1.62 KB
/
main.cpp
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
#include <unistd.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include "CLife.h"
int main ( int argc, char** argv )
{
int rows = 30;
int cols = 60;
int cellsize = 8;
bool hs = false;
char* ifile = NULL;
char* ofile = NULL;
int c;
while ( ( c = getopt( argc, argv, "r:c:z:i:o:s" ) ) != -1 )
{
switch ( c )
{
case 'r':
{
rows = std::atoi( optarg );
break;
}
case 'c':
{
cols = std::atoi( optarg );
break;
}
case 'z':
{
cellsize = std::atoi( optarg );
break;
}
case 'i':
{
ifile = optarg;
break;
}
case 'o':
{
ofile = optarg;
break;
}
case 's':
{
hs = true;
break;
}
case '?':
{
std::cout << "Wrong argument: " << optopt << std::endl;
break;
}
default:
exit(1);
}
}
CLife gol = CLife();
if ( ifile != NULL )
{
gol.Initialize( std::string(ifile), cellsize, static_cast<CLife::GridStep>(hs+1), ( ofile == NULL ? std::string() : std::string( ofile ) ) );
}
else
{
gol.Initialize( cols, rows, cellsize, static_cast<CLife::GridStep>(hs+1), ( ofile == NULL ? std::string() : std::string( ofile ) ) );
}
return gol.OnExecute();
}