-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
53 lines (40 loc) · 1.42 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
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <optional>
#include "map_renderer.h"
#include "json_reader.h"
#include "transport_catalogue.h"
#include "transport_router.h"
#include "serialization.h"
#include "svg.h"
using namespace std;
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]);
TransportCatalogue transport_catalogue;
MapRenderer map_renderer(transport_catalogue);
TransportRouter transport_router(transport_catalogue);
Serialization serialization;
TransportManagers transport_managers(transport_catalogue, map_renderer, transport_router, serialization);
if (mode == "make_base"sv) {
ReadJSON(transport_managers);
serialization.Serialize(transport_catalogue, map_renderer, transport_router);
} else if (mode == "process_requests"sv) {
json::Document input_document = json::Load(std::cin);
json::Dict dict = input_document.GetRoot().AsDict();
transport_managers.serialization.SetSerializationSettings(GetSerializationSettings(dict.at("serialization_settings").AsDict()));
serialization.Deserialize(transport_catalogue, map_renderer, transport_router);
PrintCatatlog(transport_managers, dict.at("stat_requests").AsArray(), std::cout);
} else {
PrintUsage();
return 1;
}
}