-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
84 lines (74 loc) · 2.32 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
77
78
79
80
81
82
83
/*****************************
* Project part B of:
* Ori Kopel 205533151
* Shlomo Rabinovich 308432517
* Januar 2019
******************************/
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include "CashManager.h"
#include "Solver.h"
#include "FileCacheManager.h"
#include "Bestfs.h"
#include "SolverSearchAdapter.h"
#include "ClientHandler.h"
#include "MyMatrixClientHandler.h"
#include "BFS.h"
#include "DFS.h"
#include "Astar.h"
#include "ReadFromFile.h"
#include "Server.h"
#include "StringReverseHandler.h"
#include "StringReverseClientHandler.h"
#include "Servers.h"
#include "Astar.h"
using std::string;
using std::cout;
using std::endl;
using std::vector;
using std::istream;
using std::ofstream;
using std::ostream;
using namespace std;
namespace boot {
int main(int argc, char **argv) {
CashManager *cm = new FileCacheManager("db.txt");
Solver<Searchable *, vector<Point *> *> *solver = new SolveSearchAdapter(new AStar());
ClientHandler<Searchable *, vector<Point *> *> *clientHandler = new MyMatrixClient(solver, cm);
auto server = new MyParallelServer<Searchable *, vector<Point *> *>();
server->start(stoi(argv[1]), clientHandler);
delete cm;
delete solver;
delete clientHandler;
delete server;
}
int mainOfFile(int argc, char **argv) {
CashManager *cm = new FileCacheManager("db.txt");
auto searchers = new vector<Searcher *>;
searchers->push_back(new AStar());
searchers->push_back(new DFS());
searchers->push_back(new BFS());
searchers->push_back(new Bestfs());
for (auto iter: *searchers) {
Solver<Searchable *, vector<Point *> *> *solver = new SolveSearchAdapter(iter);
ClientHandler<Searchable *, vector<Point *> *> *clientHandler = new MyMatrixClient(solver, cm);
ReadFromFile fromFile(argv[1]);
string prob = fromFile.getStringOfMatrix();
string solu;
clientHandler->handleClient(prob, solu);
cout << solu << endl;
delete clientHandler;
}
for (auto iter: *searchers) {
delete iter;
}
delete cm;
cout << "GOOD JOB" << endl;
}
};
int main(int argc, char **argv) {
boot::main(argc, argv);
return 0;
};