From c2a5894f2dbe9982830066ab9347b059e6e7d845 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 25 Apr 2017 18:20:26 -0700 Subject: [core] Immutable Impls --- include/mbgl/style/layers/background_layer.hpp | 16 ++++++++++++---- include/mbgl/style/layers/circle_layer.hpp | 16 ++++++++++++---- include/mbgl/style/layers/custom_layer.hpp | 13 +++++++++++-- include/mbgl/style/layers/fill_extrusion_layer.hpp | 16 ++++++++++++---- include/mbgl/style/layers/fill_layer.hpp | 16 ++++++++++++---- include/mbgl/style/layers/layer.hpp.ejs | 16 ++++++++++++---- include/mbgl/style/layers/line_layer.hpp | 16 ++++++++++++---- include/mbgl/style/layers/raster_layer.hpp | 16 ++++++++++++---- include/mbgl/style/layers/symbol_layer.hpp | 16 ++++++++++++---- 9 files changed, 107 insertions(+), 34 deletions(-) (limited to 'include/mbgl/style/layers') diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp index 6604a868f3..63708a449f 100644 --- a/include/mbgl/style/layers/background_layer.hpp +++ b/include/mbgl/style/layers/background_layer.hpp @@ -19,6 +19,13 @@ public: BackgroundLayer(const std::string& layerID); ~BackgroundLayer() final; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Paint properties static PropertyValue getDefaultBackgroundColor(); @@ -42,15 +49,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - BackgroundLayer(const Impl&); - BackgroundLayer(const BackgroundLayer&) = delete; + Mutable mutableImpl() const; + BackgroundLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::Background; + return getType() == LayerType::Background; } } // namespace style diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp index 3a3723249f..f40c507e28 100644 --- a/include/mbgl/style/layers/circle_layer.hpp +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -27,6 +27,13 @@ public: void setFilter(const Filter&); const Filter& getFilter() const; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Paint properties static DataDrivenPropertyValue getDefaultCircleRadius(); @@ -92,15 +99,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - CircleLayer(const Impl&); - CircleLayer(const CircleLayer&) = delete; + Mutable mutableImpl() const; + CircleLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::Circle; + return getType() == LayerType::Circle; } } // namespace style diff --git a/include/mbgl/style/layers/custom_layer.hpp b/include/mbgl/style/layers/custom_layer.hpp index edc8d43f89..79a353b047 100644 --- a/include/mbgl/style/layers/custom_layer.hpp +++ b/include/mbgl/style/layers/custom_layer.hpp @@ -55,12 +55,21 @@ public: void* context); ~CustomLayer() final; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Private implementation class Impl; - Impl* impl; + const Impl& impl() const; + + Mutable mutableImpl() const; + std::unique_ptr cloneRef(const std::string& id) const final; - CustomLayer(const Impl&); CustomLayer(const CustomLayer&) = delete; }; diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp index 1f79f87fac..bc6890e82f 100644 --- a/include/mbgl/style/layers/fill_extrusion_layer.hpp +++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp @@ -27,6 +27,13 @@ public: void setFilter(const Filter&); const Filter& getFilter() const; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Paint properties static PropertyValue getDefaultFillExtrusionOpacity(); @@ -74,15 +81,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - FillExtrusionLayer(const Impl&); - FillExtrusionLayer(const FillExtrusionLayer&) = delete; + Mutable mutableImpl() const; + FillExtrusionLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::FillExtrusion; + return getType() == LayerType::FillExtrusion; } } // namespace style diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp index 8371ff7a8f..3d08e75a1c 100644 --- a/include/mbgl/style/layers/fill_layer.hpp +++ b/include/mbgl/style/layers/fill_layer.hpp @@ -27,6 +27,13 @@ public: void setFilter(const Filter&); const Filter& getFilter() const; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Paint properties static PropertyValue getDefaultFillAntialias(); @@ -74,15 +81,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - FillLayer(const Impl&); - FillLayer(const FillLayer&) = delete; + Mutable mutableImpl() const; + FillLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::Fill; + return getType() == LayerType::Fill; } } // namespace style diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs index 59d7cd6415..033ae88956 100644 --- a/include/mbgl/style/layers/layer.hpp.ejs +++ b/include/mbgl/style/layers/layer.hpp.ejs @@ -44,6 +44,13 @@ public: <% } -%> <% } -%> + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + <% if (layoutProperties.length) { -%> // Layout properties @@ -67,15 +74,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - <%- camelize(type) %>Layer(const Impl&); - <%- camelize(type) %>Layer(const <%- camelize(type) %>Layer&) = delete; + Mutable mutableImpl() const; + <%- camelize(type) %>Layer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is<<%- camelize(type) %>Layer>() const { - return type == LayerType::<%- camelize(type) %>; + return getType() == LayerType::<%- camelize(type) %>; } } // namespace style diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp index a5f08e553c..6000839d1c 100644 --- a/include/mbgl/style/layers/line_layer.hpp +++ b/include/mbgl/style/layers/line_layer.hpp @@ -29,6 +29,13 @@ public: void setFilter(const Filter&); const Filter& getFilter() const; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Layout properties static PropertyValue getDefaultLineCap(); @@ -112,15 +119,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - LineLayer(const Impl&); - LineLayer(const LineLayer&) = delete; + Mutable mutableImpl() const; + LineLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::Line; + return getType() == LayerType::Line; } } // namespace style diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp index c0351da5d0..ad9a68f1b0 100644 --- a/include/mbgl/style/layers/raster_layer.hpp +++ b/include/mbgl/style/layers/raster_layer.hpp @@ -22,6 +22,13 @@ public: // Source const std::string& getSourceID() const; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Paint properties static PropertyValue getDefaultRasterOpacity(); @@ -69,15 +76,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - RasterLayer(const Impl&); - RasterLayer(const RasterLayer&) = delete; + Mutable mutableImpl() const; + RasterLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::Raster; + return getType() == LayerType::Raster; } } // namespace style diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index ea6bda55d7..e7df5a92ae 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -29,6 +29,13 @@ public: void setFilter(const Filter&); const Filter& getFilter() const; + // Visibility + void setVisibility(VisibilityType) final; + + // Zoom range + void setMinZoom(float) final; + void setMaxZoom(float) final; + // Layout properties static PropertyValue getDefaultSymbolPlacement(); @@ -256,15 +263,16 @@ public: // Private implementation class Impl; - Impl* const impl; + const Impl& impl() const; - SymbolLayer(const Impl&); - SymbolLayer(const SymbolLayer&) = delete; + Mutable mutableImpl() const; + SymbolLayer(Immutable); + std::unique_ptr cloneRef(const std::string& id) const final; }; template <> inline bool Layer::is() const { - return type == LayerType::Symbol; + return getType() == LayerType::Symbol; } } // namespace style -- cgit v1.2.1