Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/openlr
diff options
context:
space:
mode:
authortatiana-yan <tatiana.kondakova@gmail.com>2018-06-26 10:51:37 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2018-06-27 19:20:52 +0300
commit570b2b0b35df1fad001460eccf35da31e334b8b0 (patch)
tree2f805cf3122db499b794248f3f6c1bdd232b258c /openlr
parentdd7186b48be4636c1e67d223817a47f3f3a026e9 (diff)
[indexer] DataSource refactoring
Diffstat (limited to 'openlr')
-rw-r--r--openlr/candidate_points_getter.hpp4
-rw-r--r--openlr/decoded_path.cpp4
-rw-r--r--openlr/decoded_path.hpp4
-rw-r--r--openlr/graph.cpp4
-rw-r--r--openlr/graph.hpp4
-rw-r--r--openlr/openlr_decoder.cpp10
-rw-r--r--openlr/openlr_decoder.hpp4
-rw-r--r--openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp2
-rw-r--r--openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp3
-rw-r--r--openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp5
-rw-r--r--openlr/openlr_stat/openlr_stat.cpp10
-rw-r--r--openlr/openlr_tests/decoded_path_test.cpp4
-rw-r--r--openlr/road_info_getter.cpp4
-rw-r--r--openlr/road_info_getter.hpp6
14 files changed, 34 insertions, 34 deletions
diff --git a/openlr/candidate_points_getter.hpp b/openlr/candidate_points_getter.hpp
index 618ddea02f..3b1e7de5f6 100644
--- a/openlr/candidate_points_getter.hpp
+++ b/openlr/candidate_points_getter.hpp
@@ -17,7 +17,7 @@ class CandidatePointsGetter
{
public:
CandidatePointsGetter(size_t const maxJunctionCandidates, size_t const maxProjectionCandidates,
- DataSourceBase const & dataSource, Graph & graph)
+ DataSource const & dataSource, Graph & graph)
: m_maxJunctionCandidates(maxJunctionCandidates)
, m_maxProjectionCandidates(maxProjectionCandidates)
, m_dataSource(dataSource)
@@ -38,7 +38,7 @@ private:
size_t const m_maxJunctionCandidates;
size_t const m_maxProjectionCandidates;
- DataSourceBase const & m_dataSource;
+ DataSource const & m_dataSource;
Graph & m_graph;
};
} // namespace openlr
diff --git a/openlr/decoded_path.cpp b/openlr/decoded_path.cpp
index 33642c2567..1871e10b6d 100644
--- a/openlr/decoded_path.cpp
+++ b/openlr/decoded_path.cpp
@@ -45,7 +45,7 @@ void LatLonFromXML(pugi::xml_node const & node, ms::LatLon & latLon)
latLon.lon = node.child("lon").text().as_double();
}
-void FeatureIdFromXML(pugi::xml_node const & node, DataSourceBase const & dataSource, FeatureID & fid)
+void FeatureIdFromXML(pugi::xml_node const & node, DataSource const & dataSource, FeatureID & fid)
{
THROW_IF_NODE_IS_EMPTY(node, openlr::DecodedPathLoadError, ("Can't parse CountryName"));
auto const countryName = node.child("CountryName").text().as_string();
@@ -109,7 +109,7 @@ void WriteAsMappingForSpark(std::ostream & ost, std::vector<DecodedPath> const &
}
}
-void PathFromXML(pugi::xml_node const & node, DataSourceBase const & dataSource, Path & p)
+void PathFromXML(pugi::xml_node const & node, DataSource const & dataSource, Path & p)
{
auto const edges = node.select_nodes("RoadEdge");
for (auto const xmlE : edges)
diff --git a/openlr/decoded_path.hpp b/openlr/decoded_path.hpp
index 18875937f3..19a66a1409 100644
--- a/openlr/decoded_path.hpp
+++ b/openlr/decoded_path.hpp
@@ -11,7 +11,7 @@
#include "3party/pugixml/src/pugixml.hpp"
-class DataSourceBase;
+class DataSource;
namespace openlr
{
@@ -33,7 +33,7 @@ struct DecodedPath
void WriteAsMappingForSpark(std::string const & fileName, std::vector<DecodedPath> const & paths);
void WriteAsMappingForSpark(std::ostream & ost, std::vector<DecodedPath> const & paths);
-void PathFromXML(pugi::xml_node const & node, DataSourceBase const & dataSource, Path & path);
+void PathFromXML(pugi::xml_node const & node, DataSource const & dataSource, Path & path);
void PathToXML(Path const & path, pugi::xml_node & node);
} // namespace openlr
diff --git a/openlr/graph.cpp b/openlr/graph.cpp
index c2da01d639..cad486d404 100644
--- a/openlr/graph.cpp
+++ b/openlr/graph.cpp
@@ -1,7 +1,5 @@
#include "openlr/graph.hpp"
-class DataSourceBase;
-
using namespace routing;
namespace openlr
@@ -30,7 +28,7 @@ void GetRegularEdges(Junction const & junction, IRoadGraph const & graph,
}
} // namespace
-Graph::Graph(DataSourceBase const & dataSource, shared_ptr<CarModelFactory> carModelFactory)
+Graph::Graph(DataSource const & dataSource, shared_ptr<CarModelFactory> carModelFactory)
: m_graph(dataSource, IRoadGraph::Mode::ObeyOnewayTag, carModelFactory)
{
}
diff --git a/openlr/graph.hpp b/openlr/graph.hpp
index 7a5863a4d2..5196f08273 100644
--- a/openlr/graph.hpp
+++ b/openlr/graph.hpp
@@ -12,7 +12,7 @@
#include <memory>
#include <vector>
-class DataSourceBase;
+class DataSource;
namespace openlr
{
@@ -24,7 +24,7 @@ public:
using EdgeVector = routing::FeaturesRoadGraph::TEdgeVector;
using Junction = routing::Junction;
- Graph(DataSourceBase const & dataSource, std::shared_ptr<routing::CarModelFactory> carModelFactory);
+ Graph(DataSource const & dataSource, std::shared_ptr<routing::CarModelFactory> carModelFactory);
// Appends edges such as that edge.GetStartJunction() == junction to the |edges|.
void GetOutgoingEdges(routing::Junction const & junction, EdgeVector & edges);
diff --git a/openlr/openlr_decoder.cpp b/openlr/openlr_decoder.cpp
index 42adfb9689..8c6c12ddd2 100644
--- a/openlr/openlr_decoder.cpp
+++ b/openlr/openlr_decoder.cpp
@@ -81,7 +81,7 @@ struct alignas(kCacheLineSize) Stats
bool IsRealVertex(m2::PointD const & p, FeatureID const & fid, DataSource const & dataSource)
{
- DataSource::FeaturesLoaderGuard g(dataSource, fid.m_mwmId);
+ DataSource::FeaturesLoaderGuard g(dataSource, fid.m_mwmId, FeatureSourceFactory());
auto const ft = g.GetOriginalFeatureByIndex(fid.m_index);
bool matched = false;
ft->ForEachPoint(
@@ -189,7 +189,7 @@ void CopyWithoutOffsets(InputIterator const start, InputIterator const stop, Out
class SegmentsDecoderV1
{
public:
- SegmentsDecoderV1(DataSourceBase const & dataSource, unique_ptr<CarModelFactory> cmf)
+ SegmentsDecoderV1(DataSource const & dataSource, unique_ptr<CarModelFactory> cmf)
: m_roadGraph(dataSource, IRoadGraph::Mode::ObeyOnewayTag, move(cmf))
, m_infoGetter(dataSource)
, m_router(m_roadGraph, m_infoGetter)
@@ -378,7 +378,7 @@ bool OpenLRDecoder::SegmentsFilter::Matches(LinearSegment const & segment) const
}
// OpenLRDecoder -----------------------------------------------------------------------------
-OpenLRDecoder::OpenLRDecoder(vector<DataSource> const & dataSources,
+OpenLRDecoder::OpenLRDecoder(vector<unique_ptr<DataSource>> const & dataSources,
CountryParentNameGetter const & countryParentNameGetter)
: m_dataSources(dataSources), m_countryParentNameGetter(countryParentNameGetter)
{
@@ -430,9 +430,9 @@ void OpenLRDecoder::Decode(vector<LinearSegment> const & segments,
vector<Stats> stats(numThreads);
vector<thread> workers;
for (size_t i = 1; i < numThreads; ++i)
- workers.emplace_back(worker, i, ref(m_dataSources[i]), ref(stats[i]));
+ workers.emplace_back(worker, i, ref(*m_dataSources[i]), ref(stats[i]));
- worker(0 /* threadNum */, m_dataSources[0], stats[0]);
+ worker(0 /* threadNum */, *m_dataSources[0], stats[0]);
for (auto & worker : workers)
worker.join();
diff --git a/openlr/openlr_decoder.hpp b/openlr/openlr_decoder.hpp
index f893217718..a50cd08247 100644
--- a/openlr/openlr_decoder.hpp
+++ b/openlr/openlr_decoder.hpp
@@ -40,7 +40,7 @@ public:
bool const m_multipointsOnly;
};
- OpenLRDecoder(std::vector<DataSource> const & dataSources,
+ OpenLRDecoder(std::vector<std::unique_ptr<DataSource>> const & dataSources,
CountryParentNameGetter const & countryParentNameGetter);
// Maps partner segments to mwm paths. |segments| should be sorted by partner id.
@@ -55,7 +55,7 @@ private:
void Decode(std::vector<LinearSegment> const & segments, uint32_t const numThreads,
std::vector<DecodedPath> & paths);
- std::vector<DataSource> const & m_dataSources;
+ std::vector<std::unique_ptr<DataSource>> const & m_dataSources;
CountryParentNameGetter m_countryParentNameGetter;
};
} // namespace openlr
diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp
index 8cb93fc125..1ee4a5f296 100644
--- a/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp
+++ b/openlr/openlr_match_quality/openlr_assessment_tool/mainwindow.cpp
@@ -229,7 +229,7 @@ public:
private:
Framework & m_framework;
- DataSourceBase const & m_dataSource;
+ DataSource const & m_dataSource;
routing::FeaturesRoadGraph m_roadGraph;
};
} // namespace
diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp
index 1c8fe93757..e1fbe1929f 100644
--- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp
+++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.cpp
@@ -102,8 +102,7 @@ void RoadPointCandidate::SetActivePoint(FeatureID const & fid)
namespace openlr
{
// TrafficMode -------------------------------------------------------------------------------------
-TrafficMode::TrafficMode(std::string const & dataFileName,
- DataSourceBase const & dataSource,
+TrafficMode::TrafficMode(std::string const & dataFileName, DataSource const & dataSource,
std::unique_ptr<TrafficDrawerDelegateBase> drawerDelegate,
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate,
QObject * parent)
diff --git a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp
index 42ad40cd24..4d7c88654d 100644
--- a/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp
+++ b/openlr/openlr_match_quality/openlr_assessment_tool/traffic_mode.hpp
@@ -67,8 +67,7 @@ class TrafficMode : public QAbstractTableModel
public:
// TODO(mgsergio): Check we are on the right mwm. I.e. right mwm version and everything.
- TrafficMode(std::string const & dataFileName,
- DataSourceBase const & dataSource,
+ TrafficMode(std::string const & dataFileName, DataSource const & dataSource,
std::unique_ptr<TrafficDrawerDelegateBase> drawerDelegate,
std::unique_ptr<PointsControllerDelegateBase> pointsDelegate,
QObject * parent = Q_NULLPTR);
@@ -114,7 +113,7 @@ private:
void HandlePoint(m2::PointD clickPoint, Qt::MouseButton const button);
bool StartBuildingPathChecks() const;
- DataSourceBase const & m_dataSource;
+ DataSource const & m_dataSource;
std::vector<SegmentCorrespondence> m_segments;
// Non-owning pointer to an element of m_segments.
SegmentCorrespondence * m_currentSegment = nullptr;
diff --git a/openlr/openlr_stat/openlr_stat.cpp b/openlr/openlr_stat/openlr_stat.cpp
index 705d1d17d0..7b34a6ad99 100644
--- a/openlr/openlr_stat/openlr_stat.cpp
+++ b/openlr/openlr_stat/openlr_stat.cpp
@@ -58,7 +58,8 @@ int32_t const kMinNumThreads = 1;
int32_t const kMaxNumThreads = 128;
int32_t const kHandleAllSegments = -1;
-void LoadDataSources(std::string const & pathToMWMFolder, std::vector<DataSource> & dataSources)
+void LoadDataSources(std::string const & pathToMWMFolder,
+ std::vector<std::unique_ptr<DataSource>> & dataSources)
{
CHECK(Platform::IsDirectory(pathToMWMFolder), (pathToMWMFolder, "must be a directory."));
@@ -84,7 +85,7 @@ void LoadDataSources(std::string const & pathToMWMFolder, std::vector<DataSource
localFile.SyncWithDisk();
for (size_t i = 0; i < numDataSources; ++i)
{
- auto const result = dataSources[i].RegisterMap(localFile);
+ auto const result = dataSources[i]->RegisterMap(localFile);
CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ("Can't register mwm:", localFile));
auto const & info = result.first.GetInfo();
@@ -259,7 +260,10 @@ int main(int argc, char * argv[])
auto const numThreads = static_cast<uint32_t>(FLAGS_num_threads);
- std::vector<DataSource> dataSources(numThreads);
+ std::vector<std::unique_ptr<DataSource>> dataSources(numThreads);
+ for (size_t i = 0; i < numThreads; ++i)
+ dataSources.push_back(std::make_unique<DataSource>(std::make_unique<FeatureSourceFactory>()));
+
LoadDataSources(FLAGS_mwms_path, dataSources);
OpenLRDecoder decoder(dataSources, storage::CountryParentGetter(FLAGS_countries_filename,
diff --git a/openlr/openlr_tests/decoded_path_test.cpp b/openlr/openlr_tests/decoded_path_test.cpp
index 9f1753bb21..01c12a4015 100644
--- a/openlr/openlr_tests/decoded_path_test.cpp
+++ b/openlr/openlr_tests/decoded_path_test.cpp
@@ -133,14 +133,14 @@ void WithRoad(vector<m2::PointD> const & points, Func && fn)
builder.Add(TestRoad(points, "Interstate 60", "en"));
}
- DataSource dataSource;
+ DataSource dataSource(make_unique<FeatureSourceFactory>());
auto const regResult = dataSource.RegisterMap(country);
TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ());
MwmSet::MwmHandle mwmHandle = dataSource.GetMwmHandleById(regResult.first);
TEST(mwmHandle.IsAlive(), ());
- DataSource::FeaturesLoaderGuard const guard(dataSource, regResult.first);
+ DataSource::FeaturesLoaderGuard const guard(dataSource, regResult.first, FeatureSourceFactory());
FeatureType road;
TEST(guard.GetFeatureByIndex(0, road), ());
road.ParseEverything();
diff --git a/openlr/road_info_getter.cpp b/openlr/road_info_getter.cpp
index 96ffac93aa..bce9bb9c47 100644
--- a/openlr/road_info_getter.cpp
+++ b/openlr/road_info_getter.cpp
@@ -10,7 +10,7 @@
namespace openlr
{
-RoadInfoGetter::RoadInfoGetter(DataSourceBase const & dataSource)
+RoadInfoGetter::RoadInfoGetter(DataSource const & dataSource)
: m_dataSource(dataSource), m_c(classif())
{
}
@@ -21,7 +21,7 @@ RoadInfoGetter::RoadInfo RoadInfoGetter::Get(FeatureID const & fid)
if (it != end(m_cache))
return it->second;
- DataSource::FeaturesLoaderGuard g(m_dataSource, fid.m_mwmId);
+ DataSource::FeaturesLoaderGuard g(m_dataSource, fid.m_mwmId, FeatureSourceFactory());
FeatureType ft;
CHECK(g.GetOriginalFeatureByIndex(fid.m_index, ft), ());
diff --git a/openlr/road_info_getter.hpp b/openlr/road_info_getter.hpp
index 45c7f69060..9a83343623 100644
--- a/openlr/road_info_getter.hpp
+++ b/openlr/road_info_getter.hpp
@@ -8,7 +8,7 @@
#include "std/map.hpp"
class Classificator;
-class DataSourceBase;
+class DataSource;
namespace feature
{
@@ -28,7 +28,7 @@ public:
FormOfWay m_fow = FormOfWay::NotAValue;
};
- RoadInfoGetter(DataSourceBase const & dataSource);
+ RoadInfoGetter(DataSource const & dataSource);
RoadInfo Get(FeatureID const & fid);
@@ -36,7 +36,7 @@ public:
FunctionalRoadClass GetFunctionalRoadClass(feature::TypesHolder const & types) const;
FormOfWay GetFormOfWay(feature::TypesHolder const & types) const;
- DataSourceBase const & m_dataSource;
+ DataSource const & m_dataSource;
Classificator const & m_c;
TrunkChecker const m_trunkChecker;