diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-03-18 16:46:24 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-03-24 20:53:55 +0200 |
commit | 280b80677797ceda07ddf75f567dd3613f285319 (patch) | |
tree | ef1eef74a7c17677fdff50dbf4bbbb8452b5ce0f /src/mbgl/style | |
parent | 99dbb3eed50f1b89d23604916cee6de965e1f4cb (diff) | |
download | qtlocation-mapboxgl-280b80677797ceda07ddf75f567dd3613f285319.tar.gz |
[core] Move generic setProperty() parts to the base Layer class
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/background_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/circle_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/fill_extrusion_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/fill_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/heatmap_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/hillshade_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/layer.cpp.ejs | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/line_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/raster_layer.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 7 |
11 files changed, 27 insertions, 50 deletions
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp index 3183d84ab5..efbc91434f 100644 --- a/src/mbgl/style/layer.cpp +++ b/src/mbgl/style/layer.cpp @@ -143,6 +143,13 @@ void Layer::setObserver(LayerObserver* observer_) { observer = observer_ ? observer_ : &nullObserver; } +optional<conversion::Error> Layer::setProperty(const std::string& name, const conversion::Convertible& value) { + optional<conversion::Error> error = setPropertyInternal(name, value); + if (!error) return error; // Successfully set by the derived class implementation. + if (name == "visibility") return setVisibility(value); + return error; // Must be Error{"layer doesn't support this property"}. +} + optional<conversion::Error> Layer::setVisibility(const conversion::Convertible& value) { using namespace conversion; diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index 0b7f0afe4f..d3dd02f8a8 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -211,12 +211,9 @@ Value BackgroundLayer::serialize() const { return result; } -optional<Error> BackgroundLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> BackgroundLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index ca2f93306f..959f9447b0 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -491,12 +491,9 @@ Value CircleLayer::serialize() const { return result; } -optional<Error> CircleLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> CircleLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index c9819f66f1..b9f4e4fa6d 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -386,12 +386,9 @@ Value FillExtrusionLayer::serialize() const { return result; } -optional<Error> FillExtrusionLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> FillExtrusionLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index 914a23d96b..b6cc1eb50a 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -371,12 +371,9 @@ Value FillLayer::serialize() const { return result; } -optional<Error> FillLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> FillLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index bfac173d63..54add7203f 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -283,12 +283,9 @@ Value HeatmapLayer::serialize() const { return result; } -optional<Error> HeatmapLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> HeatmapLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp index bfbd3d1d14..04c793575a 100644 --- a/src/mbgl/style/layers/hillshade_layer.cpp +++ b/src/mbgl/style/layers/hillshade_layer.cpp @@ -316,12 +316,9 @@ Value HillshadeLayer::serialize() const { return result; } -optional<Error> HillshadeLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> HillshadeLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index a17b9e803c..bfdcd6e054 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -271,12 +271,9 @@ Value <%- camelize(type) %>Layer::serialize() const { return result; } -optional<Error> <%- camelize(type) %>Layer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> <%- camelize(type) %>Layer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 69c0af0958..94ec582931 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -588,12 +588,9 @@ Value LineLayer::serialize() const { return result; } -optional<Error> LineLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> LineLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index 3222eebd73..66ad873882 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -386,12 +386,9 @@ Value RasterLayer::serialize() const { return result; } -optional<Error> RasterLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> RasterLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 7154bffff2..70f731f30b 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -1376,12 +1376,9 @@ Value SymbolLayer::serialize() const { return result; } -optional<Error> SymbolLayer::setProperty(const std::string& name, const Convertible& value) { +optional<Error> SymbolLayer::setPropertyInternal(const std::string& name, const Convertible& value) { const auto it = layerProperties.find(name.c_str()); - if (it == layerProperties.end()) { - if (name == "visibility") return setVisibility(value); - return Error{"layer doesn't support this property"}; - } + if (it == layerProperties.end()) return Error{"layer doesn't support this property"}; auto property = static_cast<Property>(it->second); |