summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/mbgl/style/layer.cpp48
-rw-r--r--src/mbgl/style/layers/background_layer.cpp32
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp60
-rw-r--r--src/mbgl/style/layers/custom_layer.cpp29
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp60
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp60
-rw-r--r--src/mbgl/style/layers/heatmap_layer.cpp60
-rw-r--r--src/mbgl/style/layers/hillshade_layer.cpp38
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs64
-rw-r--r--src/mbgl/style/layers/line_layer.cpp60
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp38
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp60
-rw-r--r--src/mbgl/style/style_impl.cpp25
13 files changed, 97 insertions, 537 deletions
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp
index e08b71e6b3..58c38403bc 100644
--- a/src/mbgl/style/layer.cpp
+++ b/src/mbgl/style/layer.cpp
@@ -24,10 +24,44 @@ std::string Layer::getID() const {
return baseImpl->id;
}
+std::string Layer::getSourceID() const {
+ return baseImpl->source;
+}
+
+std::string Layer::getSourceLayer() const {
+ return baseImpl->sourceLayer;
+}
+
+void Layer::setSourceLayer(const std::string& sourceLayer) {
+ auto impl_ = mutableBaseImpl();
+ impl_->sourceLayer = sourceLayer;
+ baseImpl = std::move(impl_);
+}
+
+const Filter& Layer::getFilter() const {
+ return baseImpl->filter;
+}
+
+void Layer::setFilter(const Filter& filter) {
+ auto impl_ = mutableBaseImpl();
+ impl_->filter = filter;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
VisibilityType Layer::getVisibility() const {
return baseImpl->visibility;
}
+void Layer::setVisibility(VisibilityType value) {
+ if (value == getVisibility())
+ return;
+ auto impl_ = mutableBaseImpl();
+ impl_->visibility = value;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
float Layer::getMinZoom() const {
return baseImpl->minZoom;
}
@@ -36,6 +70,20 @@ float Layer::getMaxZoom() const {
return baseImpl->maxZoom;
}
+void Layer::setMinZoom(float minZoom) {
+ auto impl_ = mutableBaseImpl();
+ impl_->minZoom = minZoom;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
+void Layer::setMaxZoom(float maxZoom) {
+ auto impl_ = mutableBaseImpl();
+ impl_->maxZoom = maxZoom;
+ baseImpl = std::move(impl_);
+ observer->onLayerChanged(*this);
+}
+
void Layer::setObserver(LayerObserver* observer_) {
observer = observer_ ? observer_ : &nullObserver;
}
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index f2e85ce7e7..417d288107 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -42,34 +42,6 @@ std::unique_ptr<Layer> BackgroundLayer::cloneRef(const std::string& id_) const {
void BackgroundLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-
-// Visibility
-
-void BackgroundLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void BackgroundLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void BackgroundLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -294,5 +266,9 @@ optional<Error> BackgroundLayer::setLayoutProperty(const std::string& name, cons
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index c301a83c9e..34ea80c54c 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -42,62 +42,6 @@ std::unique_ptr<Layer> CircleLayer::cloneRef(const std::string& id_) const {
void CircleLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-// Source
-
-const std::string& CircleLayer::getSourceID() const {
- return impl().source;
-}
-
-void CircleLayer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& CircleLayer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void CircleLayer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& CircleLayer::getFilter() const {
- return impl().filter;
-}
-
-// Visibility
-
-void CircleLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void CircleLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void CircleLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -739,5 +683,9 @@ optional<Error> CircleLayer::setLayoutProperty(const std::string& name, const Co
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> CircleLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp
index d1ac1a705c..a31586f708 100644
--- a/src/mbgl/style/layers/custom_layer.cpp
+++ b/src/mbgl/style/layers/custom_layer.cpp
@@ -25,31 +25,6 @@ std::unique_ptr<Layer> CustomLayer::cloneRef(const std::string&) const {
return nullptr;
}
-// Visibility
-
-void CustomLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void CustomLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
-}
-
-void CustomLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
-}
-
using namespace conversion;
optional<Error> CustomLayer::setPaintProperty(const std::string&, const Convertible&) {
@@ -60,6 +35,10 @@ optional<Error> CustomLayer::setLayoutProperty(const std::string&, const Convert
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> CustomLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
template <>
bool Layer::is<CustomLayer>() const {
return getType() == LayerType::Custom;
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index 9301f8dd00..3a06cb78c4 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -42,62 +42,6 @@ std::unique_ptr<Layer> FillExtrusionLayer::cloneRef(const std::string& id_) cons
void FillExtrusionLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-// Source
-
-const std::string& FillExtrusionLayer::getSourceID() const {
- return impl().source;
-}
-
-void FillExtrusionLayer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& FillExtrusionLayer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void FillExtrusionLayer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& FillExtrusionLayer::getFilter() const {
- return impl().filter;
-}
-
-// Visibility
-
-void FillExtrusionLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void FillExtrusionLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void FillExtrusionLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -541,5 +485,9 @@ optional<Error> FillExtrusionLayer::setLayoutProperty(const std::string& name, c
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> FillExtrusionLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 69b3a16004..b244df6eea 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -42,62 +42,6 @@ std::unique_ptr<Layer> FillLayer::cloneRef(const std::string& id_) const {
void FillLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-// Source
-
-const std::string& FillLayer::getSourceID() const {
- return impl().source;
-}
-
-void FillLayer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& FillLayer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void FillLayer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& FillLayer::getFilter() const {
- return impl().filter;
-}
-
-// Visibility
-
-void FillLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void FillLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void FillLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -541,5 +485,9 @@ optional<Error> FillLayer::setLayoutProperty(const std::string& name, const Conv
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp
index a90aab7009..b85cbf5f40 100644
--- a/src/mbgl/style/layers/heatmap_layer.cpp
+++ b/src/mbgl/style/layers/heatmap_layer.cpp
@@ -42,62 +42,6 @@ std::unique_ptr<Layer> HeatmapLayer::cloneRef(const std::string& id_) const {
void HeatmapLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-// Source
-
-const std::string& HeatmapLayer::getSourceID() const {
- return impl().source;
-}
-
-void HeatmapLayer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& HeatmapLayer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void HeatmapLayer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& HeatmapLayer::getFilter() const {
- return impl().filter;
-}
-
-// Visibility
-
-void HeatmapLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void HeatmapLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void HeatmapLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -426,5 +370,9 @@ optional<Error> HeatmapLayer::setLayoutProperty(const std::string& name, const C
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp
index aed49f6441..badc9ef30f 100644
--- a/src/mbgl/style/layers/hillshade_layer.cpp
+++ b/src/mbgl/style/layers/hillshade_layer.cpp
@@ -42,40 +42,6 @@ std::unique_ptr<Layer> HillshadeLayer::cloneRef(const std::string& id_) const {
void HillshadeLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-// Source
-
-const std::string& HillshadeLayer::getSourceID() const {
- return impl().source;
-}
-
-
-// Visibility
-
-void HillshadeLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void HillshadeLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void HillshadeLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -451,5 +417,9 @@ optional<Error> HillshadeLayer::setLayoutProperty(const std::string& name, const
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> HillshadeLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index b5fb1a97a4..d4404ed949 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -59,66 +59,6 @@ void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer<rapidjs
}
<% } -%>
-<% if (type !== 'background') { -%>
-// Source
-
-const std::string& <%- camelize(type) %>Layer::getSourceID() const {
- return impl().source;
-}
-
-<% if (type !== 'raster' && type !== 'hillshade') { -%>
-void <%- camelize(type) %>Layer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& <%- camelize(type) %>Layer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void <%- camelize(type) %>Layer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& <%- camelize(type) %>Layer::getFilter() const {
- return impl().filter;
-}
-<% } -%>
-<% } -%>
-
-// Visibility
-
-void <%- camelize(type) %>Layer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void <%- camelize(type) %>Layer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void <%- camelize(type) %>Layer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
<% for (const property of layoutProperties) { -%>
@@ -316,5 +256,9 @@ optional<Error> <%- camelize(type) %>Layer::setLayoutProperty(const std::string&
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> <%- camelize(type) %>Layer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index f5354e2bdb..f9fc058ed7 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -43,62 +43,6 @@ void LineLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>
layout.stringify(writer);
}
-// Source
-
-const std::string& LineLayer::getSourceID() const {
- return impl().source;
-}
-
-void LineLayer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& LineLayer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void LineLayer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& LineLayer::getFilter() const {
- return impl().filter;
-}
-
-// Visibility
-
-void LineLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void LineLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void LineLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
PropertyValue<LineCapType> LineLayer::getDefaultLineCap() {
@@ -880,5 +824,9 @@ optional<Error> LineLayer::setLayoutProperty(const std::string& name, const Conv
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 7bd01c92e1..76e433aa73 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -42,40 +42,6 @@ std::unique_ptr<Layer> RasterLayer::cloneRef(const std::string& id_) const {
void RasterLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-// Source
-
-const std::string& RasterLayer::getSourceID() const {
- return impl().source;
-}
-
-
-// Visibility
-
-void RasterLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void RasterLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void RasterLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
@@ -540,5 +506,9 @@ optional<Error> RasterLayer::setLayoutProperty(const std::string& name, const Co
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 848678b5f1..d7d024d0e0 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -43,62 +43,6 @@ void SymbolLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffe
layout.stringify(writer);
}
-// Source
-
-const std::string& SymbolLayer::getSourceID() const {
- return impl().source;
-}
-
-void SymbolLayer::setSourceLayer(const std::string& sourceLayer) {
- auto impl_ = mutableImpl();
- impl_->sourceLayer = sourceLayer;
- baseImpl = std::move(impl_);
-}
-
-const std::string& SymbolLayer::getSourceLayer() const {
- return impl().sourceLayer;
-}
-
-// Filter
-
-void SymbolLayer::setFilter(const Filter& filter) {
- auto impl_ = mutableImpl();
- impl_->filter = filter;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-const Filter& SymbolLayer::getFilter() const {
- return impl().filter;
-}
-
-// Visibility
-
-void SymbolLayer::setVisibility(VisibilityType value) {
- if (value == getVisibility())
- return;
- auto impl_ = mutableImpl();
- impl_->visibility = value;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-// Zoom range
-
-void SymbolLayer::setMinZoom(float minZoom) {
- auto impl_ = mutableImpl();
- impl_->minZoom = minZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
-void SymbolLayer::setMaxZoom(float maxZoom) {
- auto impl_ = mutableImpl();
- impl_->maxZoom = maxZoom;
- baseImpl = std::move(impl_);
- observer->onLayerChanged(*this);
-}
-
// Layout properties
PropertyValue<SymbolPlacementType> SymbolLayer::getDefaultSymbolPlacement() {
@@ -2030,5 +1974,9 @@ optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Co
return Error { "layer doesn't support this property" };
}
+Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const {
+ return staticMutableCast<Layer::Impl>(mutableImpl());
+}
+
} // namespace style
} // namespace mbgl
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);