diff options
author | tatiana-yan <tatiana.kondakova@gmail.com> | 2018-07-24 13:28:42 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-07-30 12:36:04 +0300 |
commit | ffaf23d30763c1167c9b36290eb62fde67c7291c (patch) | |
tree | e4d5c6f8026cbe65cf43b22c858b294470aeff15 /editor | |
parent | f771f419b43c67a79d786db0c2740effdbe072c6 (diff) |
[indexer] Convert LoaderBase methods to const, do not store FeatureType * in shared feature loader. Remove mutable from FeatureType. Remove methods which use uninitialized FeatureType * LoaderBase::m_pFt from FeatureBase. Remove FeatureBase because noone else uses it.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_tests/osm_editor_test.cpp | 4 | ||||
-rw-r--r-- | editor/editor_tests_support/helpers.hpp | 2 | ||||
-rw-r--r-- | editor/edits_migration.cpp | 3 | ||||
-rw-r--r-- | editor/osm_editor.cpp | 30 | ||||
-rw-r--r-- | editor/osm_editor.hpp | 6 | ||||
-rw-r--r-- | editor/xml_feature.cpp | 2 | ||||
-rw-r--r-- | editor/xml_feature.hpp | 2 |
7 files changed, 24 insertions, 25 deletions
diff --git a/editor/editor_tests/osm_editor_test.cpp b/editor/editor_tests/osm_editor_test.cpp index 97a9907c50..46fd140e56 100644 --- a/editor/editor_tests/osm_editor_test.cpp +++ b/editor/editor_tests/osm_editor_test.cpp @@ -69,14 +69,14 @@ void ForEachCafeAtPoint(DataSource & dataSource, m2::PointD const & mercator, TF dataSource.ForEachInRect(f, rect, scales::GetUpperScale()); } -void FillEditableMapObject(osm::Editor const & editor, FeatureType const & ft, osm::EditableMapObject & emo) +void FillEditableMapObject(osm::Editor const & editor, FeatureType & ft, osm::EditableMapObject & emo) { emo.SetFromFeatureType(ft); emo.SetHouseNumber(ft.GetHouseNumber()); emo.SetEditableProperties(editor.GetEditableProperties(ft)); } -void SetBuildingLevelsToOne(FeatureType const & ft) +void SetBuildingLevelsToOne(FeatureType & ft) { EditFeature(ft, [](osm::EditableMapObject & emo) { diff --git a/editor/editor_tests_support/helpers.hpp b/editor/editor_tests_support/helpers.hpp index 046d431881..7431fbb582 100644 --- a/editor/editor_tests_support/helpers.hpp +++ b/editor/editor_tests_support/helpers.hpp @@ -16,7 +16,7 @@ void SetUpEditorForTesting(unique_ptr<osm::Editor::Delegate> delegate); void TearDownEditorForTesting(); template <typename TFn> -void EditFeature(FeatureType const & ft, TFn && fn) +void EditFeature(FeatureType & ft, TFn && fn) { auto & editor = osm::Editor::Instance(); diff --git a/editor/edits_migration.cpp b/editor/edits_migration.cpp index 6e94f39f53..fb5ae5627e 100644 --- a/editor/edits_migration.cpp +++ b/editor/edits_migration.cpp @@ -63,8 +63,7 @@ FeatureID MigrateWayOrRelatonFeatureIndex( auto const someFeaturePoint = geometry[0]; forEach( - [&feature, &geometry, &count, &bestScore](FeatureType const & ft) - { + [&feature, &geometry, &count, &bestScore](FeatureType & ft) { if (ft.GetFeatureType() != feature::GEOM_AREA) return; ++count; diff --git a/editor/osm_editor.cpp b/editor/osm_editor.cpp index b3d1fe4f29..4fb8efe886 100644 --- a/editor/osm_editor.cpp +++ b/editor/osm_editor.cpp @@ -120,7 +120,7 @@ bool NeedsUpload(string const & uploadStatus) } /// Compares editable fields connected with feature ignoring street. -bool AreFeaturesEqualButStreet(FeatureType const & a, FeatureType const & b) +bool AreFeaturesEqualButStreet(FeatureType & a, FeatureType & b) { feature::TypesHolder const aTypes(a); feature::TypesHolder const bTypes(b); @@ -140,7 +140,7 @@ bool AreFeaturesEqualButStreet(FeatureType const & a, FeatureType const & b) return true; } -XMLFeature GetMatchingFeatureFromOSM(osm::ChangesetWrapper & cw, FeatureType const & ft) +XMLFeature GetMatchingFeatureFromOSM(osm::ChangesetWrapper & cw, FeatureType & ft) { ASSERT_NOT_EQUAL(ft.GetFeatureType(), feature::GEOM_LINE, ("Line features are not supported yet.")); @@ -233,7 +233,7 @@ void Editor::LoadEdits() Save(); } -bool Editor::Save() const +bool Editor::Save() { // TODO(AlexZ): Improve synchronization in Editor code. static mutex saveMutex; @@ -249,7 +249,7 @@ bool Editor::Save() const xml_node root = doc.append_child(kXmlRootNode); // Use format_version for possible future format changes. root.append_attribute("format_version") = 1; - for (auto const & mwm : m_features) + for (auto & mwm : m_features) { xml_node mwmNode = root.append_child(kXmlMwmNode); mwmNode.append_attribute("name") = mwm.first.GetInfo()->GetCountryName().c_str(); @@ -258,9 +258,9 @@ bool Editor::Save() const xml_node modified = mwmNode.append_child(kModifySection); xml_node created = mwmNode.append_child(kCreateSection); xml_node obsolete = mwmNode.append_child(kObsoleteSection); - for (auto const & index : mwm.second) + for (auto & index : mwm.second) { - FeatureTypeInfo const & fti = index.second; + FeatureTypeInfo & fti = index.second; // TODO: Do we really need to serialize deleted features in full details? Looks like mwm ID // and meta fields are enough. XMLFeature xf = @@ -399,7 +399,7 @@ Editor::SaveResult Editor::SaveEditedFeature(EditableMapObject const & emo) if (featureStatus == FeatureStatus::Created) { - auto const & editedFeatureInfo = m_features[fid.m_mwmId][fid.m_index]; + auto & editedFeatureInfo = m_features[fid.m_mwmId][fid.m_index]; if (AreFeaturesEqualButStreet(fti.m_feature, editedFeatureInfo.m_feature) && emo.GetStreet().m_defaultName == editedFeatureInfo.m_street) { @@ -428,7 +428,7 @@ Editor::SaveResult Editor::SaveEditedFeature(EditableMapObject const & emo) if (featureStatus != FeatureStatus::Untouched) { // A feature was modified and equals to the one in editor. - auto const & editedFeatureInfo = m_features[fid.m_mwmId][fid.m_index]; + auto & editedFeatureInfo = m_features[fid.m_mwmId][fid.m_index]; if (AreFeaturesEqualButStreet(fti.m_feature, editedFeatureInfo.m_feature) && emo.GetStreet().m_defaultName == editedFeatureInfo.m_street) { @@ -492,9 +492,9 @@ void Editor::ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id, // TODO(AlexZ): Check that features are visible at this scale. // Process only new (created) features. - for (auto const & index : mwmFound->second) + for (auto & index : mwmFound->second) { - FeatureTypeInfo const & ftInfo = index.second; + FeatureTypeInfo & ftInfo = index.second; if (ftInfo.m_status == FeatureStatus::Created && rect.IsPointInside(ftInfo.m_feature.GetCenter())) f(index.first); @@ -543,7 +543,7 @@ vector<uint32_t> Editor::GetFeaturesByStatus(MwmSet::MwmId const & mwmId, return features; } -EditableProperties Editor::GetEditableProperties(FeatureType const & feature) const +EditableProperties Editor::GetEditableProperties(FeatureType & feature) const { ASSERT(version::IsSingleMwm(feature.GetID().m_mwmId.GetInfo()->m_version.GetVersion()), ("Edit mode should be available only on new data")); @@ -960,15 +960,15 @@ bool Editor::RemoveFeature(FeatureID const & fid) return Save(); } -Editor::Stats Editor::GetStats() const +Editor::Stats Editor::GetStats() { Stats stats; LOG(LDEBUG, ("Edited features status:")); - for (auto const & id : m_features) + for (auto & id : m_features) { - for (auto const & index : id.second) + for (auto & index : id.second) { - Editor::FeatureTypeInfo const & fti = index.second; + Editor::FeatureTypeInfo & fti = index.second; stats.m_edits.push_back(make_pair(FeatureID(id.first, index.first), fti.m_uploadStatus + " " + fti.m_uploadError)); LOG(LDEBUG, (fti.m_uploadAttemptTimestamp == my::INVALID_TIME_STAMP diff --git a/editor/osm_editor.hpp b/editor/osm_editor.hpp index 8c74061eb5..8567abfe5b 100644 --- a/editor/osm_editor.hpp +++ b/editor/osm_editor.hpp @@ -135,7 +135,7 @@ public: /// @returns false if a feature was uploaded. bool RollBackChanges(FeatureID const & fid); - EditableProperties GetEditableProperties(FeatureType const & feature) const; + EditableProperties GetEditableProperties(FeatureType & feature) const; bool HaveMapEditsOrNotesToUpload() const; bool HaveMapEditsToUpload(MwmSet::MwmId const & mwmId) const; @@ -173,7 +173,7 @@ public: size_t m_uploadedCount = 0; time_t m_lastUploadTimestamp = my::INVALID_TIME_STAMP; }; - Stats GetStats() const; + Stats GetStats(); // Don't use this function to determine if a feature in editor was created. // Use GetFeatureStatus(fid) instead. This function is used when a feature is @@ -183,7 +183,7 @@ public: private: // TODO(AlexZ): Synchronize Save call/make it on a separate thread. /// @returns false if fails. - bool Save() const; + bool Save(); void RemoveFeatureFromStorageIfExists(MwmSet::MwmId const & mwmId, uint32_t index); void RemoveFeatureFromStorageIfExists(FeatureID const & fid); /// Notify framework that something has changed and should be redisplayed. diff --git a/editor/xml_feature.cpp b/editor/xml_feature.cpp index 91f97c4a47..a9847c891f 100644 --- a/editor/xml_feature.cpp +++ b/editor/xml_feature.cpp @@ -401,7 +401,7 @@ void ApplyPatch(XMLFeature const & xml, FeatureType & feature) feature.UpdateHeader(true /* commonParsed */, true /* metadataParsed */); } -XMLFeature ToXML(FeatureType const & fromFeature, bool serializeType) +XMLFeature ToXML(FeatureType & fromFeature, bool serializeType) { bool const isPoint = fromFeature.GetFeatureType() == feature::GEOM_POINT; XMLFeature toFeature(isPoint ? XMLFeature::Type::Node : XMLFeature::Type::Way); diff --git a/editor/xml_feature.hpp b/editor/xml_feature.hpp index 086a5fa397..ce5c648c0f 100644 --- a/editor/xml_feature.hpp +++ b/editor/xml_feature.hpp @@ -180,7 +180,7 @@ void ApplyPatch(XMLFeature const & xml, FeatureType & feature); /// @param serializeType if false, types are not serialized. /// Useful for applying modifications to existing OSM features, to avoid issues when someone /// has changed a type in OSM, but our users uploaded invalid outdated type after modifying feature. -XMLFeature ToXML(FeatureType const & feature, bool serializeType); +XMLFeature ToXML(FeatureType & feature, bool serializeType); /// Creates new feature, including geometry and types. /// @Note: only nodes (points) are supported at the moment. |