diff options
author | tatiana-yan <tatiana.kondakova@gmail.com> | 2019-03-12 15:31:48 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-03-18 22:38:39 +0300 |
commit | f1c58fbfcc0fd0bbd98285734e9a2d9e4435a33d (patch) | |
tree | 9c1d71beb7bcb46a3a94e4e9990ed19e5358aa02 /editor | |
parent | 2bf94c95dd55f70951a82b5c306b8a29a72a4180 (diff) |
[indexer] Disallow copy and move of FeatureType, remove FeatureType::ParseEverything().
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editable_feature_source.cpp | 4 | ||||
-rw-r--r-- | editor/editable_feature_source.hpp | 2 | ||||
-rw-r--r-- | editor/editor_tests/osm_editor_test.cpp | 23 | ||||
-rw-r--r-- | editor/osm_editor.cpp | 15 | ||||
-rw-r--r-- | editor/osm_editor.hpp | 6 |
5 files changed, 19 insertions, 31 deletions
diff --git a/editor/editable_feature_source.cpp b/editor/editable_feature_source.cpp index ee55e84cbf..d880a06833 100644 --- a/editor/editable_feature_source.cpp +++ b/editor/editable_feature_source.cpp @@ -8,10 +8,10 @@ FeatureStatus EditableFeatureSource::GetFeatureStatus(uint32_t index) const return editor.GetFeatureStatus(m_handle.GetId(), index); } -bool EditableFeatureSource::GetModifiedFeature(uint32_t index, FeatureType & feature) const +unique_ptr<FeatureType> EditableFeatureSource::GetModifiedFeature(uint32_t index) const { osm::Editor & editor = osm::Editor::Instance(); - return editor.GetEditedFeature(m_handle.GetId(), index, feature); + return editor.GetEditedFeature(FeatureID(m_handle.GetId(), index)); } void EditableFeatureSource::ForEachAdditionalFeature(m2::RectD const & rect, int scale, diff --git a/editor/editable_feature_source.hpp b/editor/editable_feature_source.hpp index 63f58fe6ba..85d94ce4ca 100644 --- a/editor/editable_feature_source.hpp +++ b/editor/editable_feature_source.hpp @@ -17,7 +17,7 @@ public: // FeatureSource overrides: FeatureStatus GetFeatureStatus(uint32_t index) const override; - bool GetModifiedFeature(uint32_t index, FeatureType & feature) const override; + std::unique_ptr<FeatureType> GetModifiedFeature(uint32_t index) const override; void ForEachAdditionalFeature(m2::RectD const & rect, int scale, std::function<void(uint32_t)> const & fn) const override; }; diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index 946c61a3b4..135517761e 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -249,8 +249,7 @@ void EditorTest::GetEditedFeatureTest() { FeatureID feature; - FeatureType ft; - TEST(!editor.GetEditedFeature(feature, ft), ()); + TEST(!editor.GetEditedFeature(feature), ()); } auto const mwmId = ConstructTestMwm([](TestMwmBuilder & builder) @@ -259,21 +258,20 @@ void EditorTest::GetEditedFeatureTest() builder.Add(cafe); }); - ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) - { - FeatureType featureType; - TEST(!editor.GetEditedFeature(ft.GetID(), featureType), ()); + ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { + TEST(!editor.GetEditedFeature(ft.GetID()), ()); SetBuildingLevelsToOne(ft); - TEST(editor.GetEditedFeature(ft.GetID(), featureType), ()); + auto featureType = editor.GetEditedFeature(ft.GetID()); + TEST(featureType, ()); osm::EditableMapObject savedEmo; - FillEditableMapObject(editor, featureType, savedEmo); + FillEditableMapObject(editor, *featureType, savedEmo); TEST_EQUAL(savedEmo.GetBuildingLevels(), "1", ()); - TEST_EQUAL(ft.GetID(), featureType.GetID(), ()); + TEST_EQUAL(ft.GetID(), featureType->GetID(), ()); }); } @@ -472,11 +470,10 @@ void EditorTest::DeleteFeatureTest() osm::EditableMapObject emo; CreateCafeAtPoint({3.0, 3.0}, mwmId, emo); - FeatureType ft; - editor.GetEditedFeature(emo.GetID().m_mwmId, emo.GetID().m_index, ft); - editor.DeleteFeature(ft.GetID()); + auto ft = editor.GetEditedFeature(emo.GetID()); + editor.DeleteFeature(ft->GetID()); - TEST_EQUAL(editor.GetFeatureStatus(ft.GetID()), FeatureStatus::Untouched, ()); + TEST_EQUAL(editor.GetFeatureStatus(ft->GetID()), FeatureStatus::Untouched, ()); ForEachCafeAtPoint(m_dataSource, m2::PointD(1.0, 1.0), [&editor](FeatureType & ft) { diff --git a/editor/osm_editor.cpp b/editor/osm_editor.cpp index 59838edc76..f08fb47b57 100644 --- a/editor/osm_editor.cpp +++ b/editor/osm_editor.cpp @@ -516,21 +516,14 @@ void Editor::ForEachCreatedFeature(MwmSet::MwmId const & id, FeatureIndexFunctor } } -bool Editor::GetEditedFeature(MwmSet::MwmId const & mwmId, uint32_t index, - FeatureType & outFeature) const +unique_ptr<FeatureType> Editor::GetEditedFeature(FeatureID const & fid) const { auto const features = m_features.Get(); - auto const * featureInfo = GetFeatureTypeInfo(*features, mwmId, index); + auto const * featureInfo = GetFeatureTypeInfo(*features, fid.m_mwmId, fid.m_index); if (featureInfo == nullptr) - return false; - - outFeature = FeatureType::ConstructFromMapObject(featureInfo->m_object); - return true; -} + return {}; -bool Editor::GetEditedFeature(FeatureID const & fid, FeatureType & outFeature) const -{ - return GetEditedFeature(fid.m_mwmId, fid.m_index, outFeature); + return make_unique<FeatureType>(featureInfo->m_object); } bool Editor::GetEditedFeatureStreet(FeatureID const & fid, string & outFeatureStreet) const diff --git a/editor/osm_editor.hpp b/editor/osm_editor.hpp index 859723596e..4c9101502d 100644 --- a/editor/osm_editor.hpp +++ b/editor/osm_editor.hpp @@ -142,10 +142,8 @@ public: /// Marks feature as "deleted" from MwM file. void DeleteFeature(FeatureID const & fid); - /// @returns false if feature wasn't edited. - /// @param outFeature is valid only if true was returned. - bool GetEditedFeature(MwmSet::MwmId const & mwmId, uint32_t index, FeatureType & outFeature) const; - bool GetEditedFeature(FeatureID const & fid, FeatureType & outFeature) const; + /// @returns nullptr if feature wasn't edited. + std::unique_ptr<FeatureType> GetEditedFeature(FeatureID const & fid) const; /// @returns false if feature wasn't edited. /// @param outFeatureStreet is valid only if true was returned. |