This repository has been archived by the owner on May 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.h
91 lines (70 loc) · 2.01 KB
/
application.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*************************************************/
/* Bacteria - The interesting bacteria simulator */
/* (c) Kristian K. Skordal 2009 - 2012 */
/*************************************************/
#ifndef APPLICATION_H
#define APPLICATION_H
#include <ctime>
#include <list>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <getopt.h>
#include <SDL.h>
#include <SDL_ttf.h>
#include "bacteria.h"
#include "config.h"
#include "config_db.h"
#include "config_parser.h"
#include "food.h"
#include "image.h"
#include "info_field.h"
#include "logger.h"
#include "statistics.h"
#include "window.h"
#define UPDATE_EVENT {SDL_USEREVENT, 0, NULL, NULL}
#define LOGGER_EVENT {SDL_USEREVENT, 1, NULL, NULL}
class application
{
public:
static application * init(int argc, char * argv[]);
static application * get() { return global_app; }
// Runs the simulator:
int run();
// Returns the current info mode for printing various bacteria information:
info_field::mode get_info_mode() const { return info_mode; }
// Finds a file in the application search path:
static const char * find_file(const char * filename);
private:
application();
~application();
// Clean up function, called by atexit:
static void cleanup();
// Initialization functions:
bool init_cmd_args(int argc, char * argv[]);
bool init_config();
bool init_graphics();
bool init_logging();
bool init_populations();
bool init_timers();
// Functions used for handling events:
void handle_update();
void handle_key(SDLKey key);
void display_help();
void display_version();
// Variables:
int logging_interval;
int ancestor_counter;
int starting_pop, starting_food;
std::string config_filename;
info_field::mode info_mode;
bool display_stats, running;
logger * data_logger;
statistics * stats;
window * main_window;
SDL_TimerID refresh_timer, logger_timer;
std::list<bacteria>::iterator bacteria_iterator;
std::list<food>::iterator food_iterator;
static application * global_app;
};
#endif