-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (40 loc) · 1.68 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (40 loc) · 1.68 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
#include <fstream>
#include <iostream>
#include <string_view>
#include "json_reader.h"
using namespace std::literals;
void PrintUsage(std::ostream& stream = std::cerr) {
stream << "Usage: transport_catalogue [make_base|process_requests]\n"sv;
}
int main(int argc, char* argv[]) {
if (argc != 2) {
PrintUsage();
return 1;
}
const std::string_view mode(argv[1]);
transport_catalogue::TransportCatalogue catalogue;
renderer::MapRenderer render;
transport_router::TransportRouter router;
serialize::Serializator proto_catalogue;
TransportCatalogueHandler handler(catalogue, render, router); // Создание фасада
if (mode == "make_base"sv) {
json_reader::Json_TC data(std::cin);
data.LoadCatalogueData(catalogue); // выгрузка данных из json_reader в каталог
data.LoadRenderSetings(render); // выгрузка данных из json_reader в MapRender
router.AddRouterSetting(data.GetRouterSettings());
router.InicializeGraph(catalogue);
proto_catalogue.SetSerializeSettings(data.GetSerializeSettings());
proto_catalogue.AddTransportCatalogue(catalogue);
proto_catalogue.AddRenderSettings(render);
proto_catalogue.SetProtoTransportRouter(router);
proto_catalogue.Serialize();
} else if (mode == "process_requests"sv) {
json_reader::Json_TC data(std::cin);
proto_catalogue.SetSerializeSettings(data.GetSerializeSettings());
proto_catalogue.Deserialize(catalogue, render, router);
data.PrintCatalogueStatRequests(handler, std::cout);
} else {
PrintUsage();
return 1;
}
}