diff options
Diffstat (limited to 'include/mbgl/style/layer.hpp')
-rw-r--r-- | include/mbgl/style/layer.hpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 56f2c48fa7..10176879c5 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -2,6 +2,7 @@ #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/any.hpp> +#include <mbgl/util/immutable.hpp> #include <mbgl/style/layer_type.hpp> #include <mbgl/style/types.hpp> @@ -19,6 +20,7 @@ class RasterLayer; class BackgroundLayer; class CustomLayer; class FillExtrusionLayer; +class LayerObserver; /** * The runtime representation of a [layer](https://www.mapbox.com/mapbox-gl-style-spec/#layers) from the Mapbox Style @@ -38,15 +40,6 @@ class FillExtrusionLayer; */ class Layer : public mbgl::util::noncopyable { public: - class Impl; - -protected: - - const LayerType type; - Layer(LayerType, std::unique_ptr<Impl>); - -public: - virtual ~Layer(); // Check whether this layer is of the given subtype. @@ -78,7 +71,7 @@ public: // template <class V> auto accept(V&& visitor) { - switch (type) { + switch (getType()) { case LayerType::Fill: return visitor(*as<FillLayer>()); case LayerType::Line: @@ -98,20 +91,30 @@ public: } } + LayerType getType() const; const std::string& getID() const; // Visibility VisibilityType getVisibility() const; - void setVisibility(VisibilityType); + virtual void setVisibility(VisibilityType) = 0; // Zoom range float getMinZoom() const; - void setMinZoom(float) const; float getMaxZoom() const; - void setMaxZoom(float) const; + virtual void setMinZoom(float) = 0; + virtual void setMaxZoom(float) = 0; // Private implementation - const std::unique_ptr<Impl> baseImpl; + class Impl; + Immutable<Impl> baseImpl; + + Layer(Immutable<Impl>); + + // Create a layer, copying all properties except id and paint properties from this layer. + virtual std::unique_ptr<Layer> cloneRef(const std::string& id) const = 0; + + LayerObserver* observer = nullptr; + void setObserver(LayerObserver*); // For use in SDK bindings, which store a reference to a platform-native peer // object here, so that separately-obtained references to this object share |