forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollector_interface.hpp
106 lines (91 loc) · 3.45 KB
/
collector_interface.hpp
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include "platform/platform.hpp"
#include "base/assert.hpp"
#include "base/logging.hpp"
#include <atomic>
#include <fstream>
#include <memory>
#include <string>
struct OsmElement;
class RelationElement;
namespace feature
{
class FeatureBuilder;
} // namespace feature
namespace base
{
class GeoObjectId;
} // namespace base
namespace feature
{
class MetalinesBuilder;
} // namespace feature
namespace routing
{
class CameraCollector;
class RestrictionWriter;
class RoadAccessWriter;
} // namespace routing
namespace generator
{
class BoundaryPostcodeCollector;
class CollectorAddresses;
class CollectorCollection;
class CollectorTag;
class MaxspeedsCollector;
class MiniRoundaboutCollector;
class CityAreaCollector;
class CrossMwmOsmWaysCollector;
class RoutingCityBoundariesCollector;
class BuildingPartsCollector;
namespace cache
{
class IntermediateDataReaderInterface;
} // namespace cache
namespace regions
{
class CollectorRegionInfo;
} // namespace regions
// Implementing this interface allows an object to collect data from RelationElement,
// OsmElement and FeatureBuilder elements.
class CollectorInterface
{
public:
CollectorInterface(std::string const & filename = {}) : m_id(CreateId()), m_filename(filename) {}
virtual ~CollectorInterface() { CHECK(Platform::RemoveFileIfExists(GetTmpFilename()), (GetTmpFilename())); }
virtual std::shared_ptr<CollectorInterface> Clone(
std::shared_ptr<cache::IntermediateDataReaderInterface> const & = {}) const = 0;
virtual void Collect(OsmElement const &) {}
virtual void CollectRelation(RelationElement const &) {}
virtual void CollectFeature(feature::FeatureBuilder const &, OsmElement const &) {}
virtual void Finish() {}
virtual void Save() = 0;
virtual void Merge(CollectorInterface const &) = 0;
virtual void MergeInto(BoundaryPostcodeCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(CityAreaCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(routing::CameraCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(MiniRoundaboutCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(routing::RestrictionWriter &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(routing::RoadAccessWriter &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(CollectorAddresses &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(CollectorTag &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(MaxspeedsCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(feature::MetalinesBuilder &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(regions::CollectorRegionInfo &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(CollectorCollection &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(CrossMwmOsmWaysCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(RoutingCityBoundariesCollector &) const { FailIfMethodUnsupported(); }
virtual void MergeInto(BuildingPartsCollector &) const { FailIfMethodUnsupported(); }
std::string GetTmpFilename() const { return m_filename + "." + std::to_string(m_id); }
std::string const & GetFilename() const { return m_filename; }
private:
void FailIfMethodUnsupported() const { CHECK(false, ("This method is unsupported.")); }
int CreateId()
{
static std::atomic_int id{0};
return id++;
}
int m_id;
std::string m_filename;
};
} // namespace generator