-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simulator.h
44 lines (43 loc) · 1.55 KB
/
Simulator.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
#include "Auxiliary.h"
#include "Score.h"
#include "Sensor.h"
#include "Encoder.h"
class Simulator {
int numOfHouses = 0; // based on number of files in folder (before threads start)
atomic<int> numOfWorkingHouses{ 0 }; // based on proper formatted and readable files (while threads work)
int numOfAlgorithms = 0;
int numOfThreads = 1;
bool score_loaded = false;
void* score_hndl = NULL;
int (*score_function)(const map<string, int>& score_params);
atomic<int> nextHouse{ 0 };
vector<string> houseFileNames; // full path + ending (.house)
unique_ptr<bool[]> isValidHouses;
unique_ptr<string[]> houseErrors;
unique_ptr<string[]> walkingIntoWallsErrors;
vector<string> videoErrors;
bool algorithmIntoWall = false;
// map algorithm (name) to vector of scores (score[i] for houses[i])
// no intereference between different threads because each one accesses a different index in the score array
map<string, unique_ptr<int[]>> scores;
int isErrorInScoreCalc = false;
AlgorithmRegistrar& registrar = AlgorithmRegistrar::getInstance();
map<string, int> config = {};
bool isFlagVideoUp = false;
vector<string> flags{ defaultConfigPath, defaultScorePath, defaultHousePath, defaultAlgorithmPath, defaultThreads };
public:
void handleArguments(int argc, const char* argv[]);
int handleAll();
int handleConfiguration();
int handleScore();
int handleAlgorithms();
int handleHouses();
void handleThreads();
int handleVideo();
void startSimulation();
void threadSimulation();
void runThreadOnHouse(int houseIndex);
void printScores();
void printErrors();
void end();
};