summaryrefslogtreecommitdiff
path: root/src/mbgl/style/style_impl.cpp
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-10-25 16:15:31 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-10-25 22:42:43 +0300
commit7a9461a8d439458b18656ecfb839923adc5f0e9b (patch)
tree5617367418dafc5b7b45c4ba7cca4b74f40200f3 /src/mbgl/style/style_impl.cpp
parentfdd8b54900d963d01f9b643fa7edd9e988eb7785 (diff)
downloadqtlocation-mapboxgl-7a9461a8d439458b18656ecfb839923adc5f0e9b.tar.gz
Consolidate `style::Layer` properties API
The `style::Layer` class now exposes all the properties contained at `style::LayerImpl`. This allowed to drop `style::Layer::accept()` method usage, avoid the repeated generated code and thus save some binary size. This patch is a part of the layers modularization effort.
Diffstat (limited to 'src/mbgl/style/style_impl.cpp')
-rw-r--r--src/mbgl/style/style_impl.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp
index 5c9edc789f..760e2bc396 100644
--- a/src/mbgl/style/style_impl.cpp
+++ b/src/mbgl/style/style_impl.cpp
@@ -146,28 +146,13 @@ void Style::Impl::addSource(std::unique_ptr<Source> source) {
sources.add(std::move(source));
}
-struct SourceIdUsageEvaluator {
- const std::string& sourceId;
-
- bool operator()(BackgroundLayer&) { return false; }
- bool operator()(CustomLayer&) { return false; }
-
- template <class LayerType>
- bool operator()(LayerType& layer) {
- return layer.getSourceID() == sourceId;
- }
-};
-
std::unique_ptr<Source> Style::Impl::removeSource(const std::string& id) {
// Check if source is in use
- SourceIdUsageEvaluator sourceIdEvaluator {id};
- auto layerIt = std::find_if(layers.begin(), layers.end(), [&](const auto& layer) {
- return layer->accept(sourceIdEvaluator);
- });
-
- if (layerIt != layers.end()) {
- Log::Warning(Event::General, "Source '%s' is in use, cannot remove", id.c_str());
- return nullptr;
+ for (const auto& layer: layers) {
+ if (layer->getSourceID() == id) {
+ Log::Warning(Event::General, "Source '%s' is in use, cannot remove", id.c_str());
+ return nullptr;
+ }
}
std::unique_ptr<Source> source = sources.remove(id);