-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialization.h
66 lines (47 loc) · 2.14 KB
/
serialization.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
#pragma once
#include <filesystem>
#include <fstream>
#include <string>
#include <optional>
#include <vector>
#include <memory>
#include <variant>
#include "transport_catalogue.pb.h"
#include "map_renderer.pb.h"
#include "svg.pb.h"
#include "transport_router.pb.h"
#include "graph.pb.h"
#include "transport_catalogue.h"
#include "map_renderer.h"
#include "transport_router.h"
#include "svg.h"
#include "domain.h"
using Path = std::filesystem::path;
struct SerializationSettings{
Path file_name;
};
class Serialization{
public:
Serialization() = default;
void Serialize(TransportCatalogue& transport_catalogue, MapRenderer& map_renderer, TransportRouter& transport_router);
void Deserialize(TransportCatalogue& transport_catalogue, MapRenderer& map_renderer, TransportRouter& transport_router);
void SetSerializationSettings(SerializationSettings serialization_settings);
private:
SerializationSettings serialization_settings_;
transport_proto::TransportCatalogue ConvertTransportCatalogue_(TransportCatalogue& transport_catalogue);
std::string GetStopNameById_(transport_proto::TransportCatalogue& converted_catalogue, int id);
TransportCatalogue ConvertProtoTransportCatalogue_(transport_proto::TransportCatalogue& converted_catalogue);
transport_proto::Color ConvertColor_(svg::Color color);
transport_proto::RenderSettings ConvertRenderSettings_(RenderSettings render_settings);
svg::Color ConvertProtoColor_(transport_proto::Color converted_color);
RenderSettings ConvertProtoRenderSettings_(transport_proto::RenderSettings converted_settings);
transport_proto::RouteSettings ConvertRouteSettings_(RouteSettings& route_settings);
transport_proto::Graph ConvertGraph_(TransportRouter& transport_router);
transport_proto::Router ConvertRouter_(TransportRouter& transport_router);
void ConvertProtoRouteSettings_(RouteSettings& route_settings,
transport_proto::RouteSettings converted_settings);
void ConvertProtoGraph_(transport_proto::Graph& converted_graph,
std::shared_ptr<graph::DirectedWeightedGraph<double>> graph);
void ConvertProtoRouter_(transport_proto::Router& converted_router,
std::shared_ptr<graph::Router<double>> router);
};