diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-22 15:37:09 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-27 18:10:21 +0200 |
commit | 361982fef83a145769da5c04d1c19731df89921c (patch) | |
tree | e6212cb782cf9df83ecc3e32cb52beaebeb73ab8 /include/mbgl/style/layer.hpp | |
parent | cca37e765bf9b853262783a6f7cc3d1a4c72957d (diff) | |
download | qtlocation-mapboxgl-361982fef83a145769da5c04d1c19731df89921c.tar.gz |
[core][Android][Darwin] LayerManager creates RenderLayer instances
`LayerManager` is now responsible for `RenderLayer` instances creation,
so that there is a single entry point for creating of objects, which
correspond to a certain layer type.
The `LayerType type` field is dropped from `Layer::Impl`.
Diffstat (limited to 'include/mbgl/style/layer.hpp')
-rw-r--r-- | include/mbgl/style/layer.hpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index 5c1b361419..9e73e994e6 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -74,8 +74,7 @@ public: Layer& operator=(const Layer&) = delete; virtual ~Layer(); - // Note: LayerType is deprecated, do not use it. - LayerType getType() const; + std::string getID() const; // Source std::string getSourceID() const; @@ -126,6 +125,10 @@ protected: LayerObserver* observer; }; +} // namespace style + +class RenderLayer; +// TODO: The following classes shall not be here. Move layer factories and manager to a dedicated folder. /** * @brief The LayerFactory abstract class @@ -136,17 +139,19 @@ class LayerFactory { public: virtual ~LayerFactory() = default; /// Returns the layer type data. - virtual const LayerTypeInfo* getTypeInfo() const noexcept = 0; + virtual const style::LayerTypeInfo* getTypeInfo() const noexcept = 0; /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. - virtual std::unique_ptr<Layer> createLayer(const std::string& id, const conversion::Convertible& value) = 0; + virtual std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept = 0; + /// Returns a new RenderLayer instance on success call; returns `nulltptr` otherwise. + virtual std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept = 0; protected: - optional<std::string> getSource(const conversion::Convertible& value) const noexcept; - bool initSourceLayerAndFilter(Layer*, const conversion::Convertible& value) const noexcept; + optional<std::string> getSource(const style::conversion::Convertible& value) const noexcept; + bool initSourceLayerAndFilter(style::Layer*, const style::conversion::Convertible& value) const noexcept; }; /** - * @brief A singleton class forwarding calls to the corresponding \c LayerFactory instance. + * @brief A singleton class responsible for creating layer instances. */ class LayerManager { public: @@ -157,13 +162,16 @@ public: */ static LayerManager* get() noexcept; - virtual ~LayerManager() = default; /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. - virtual std::unique_ptr<Layer> createLayer(const std::string& type, const std::string& id, const conversion::Convertible& value, conversion::Error& error) noexcept = 0; + std::unique_ptr<style::Layer> createLayer(const std::string& type, const std::string& id, + const style::conversion::Convertible& value, style::conversion::Error& error) noexcept; + /// Returns a new RenderLayer instance on success call; returns `nulltptr` otherwise. + std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept; protected: - LayerManager() = default; + virtual ~LayerManager() = default; + virtual LayerFactory* getFactory(const std::string& type) noexcept = 0; + virtual LayerFactory* getFactory(const style::LayerTypeInfo*) noexcept = 0; }; -} // namespace style } // namespace mbgl |