diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-30 12:10:33 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-30 19:09:17 +0200 |
commit | 92352de87d4068985fa56100f2c6e16bf26a1c86 (patch) | |
tree | e3dd5729e2ef8e32931b8e42ab34a3d0b806ee18 /include | |
parent | 8bc362e3a2836cfa96ef14a41a0e882a1d08e881 (diff) | |
download | qtlocation-mapboxgl-92352de87d4068985fa56100f2c6e16bf26a1c86.tar.gz |
[core] layermanager folder
Move `LayerManager` and `LayerFactory` abstract classes to a dedicated folder.
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/layermanager/layer_factory.hpp | 29 | ||||
-rw-r--r-- | include/mbgl/layermanager/layer_manager.hpp | 56 | ||||
-rw-r--r-- | include/mbgl/style/layer.hpp | 70 | ||||
-rw-r--r-- | include/mbgl/style/layers/background_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/circle_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/custom_layer.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/style/layers/fill_extrusion_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/fill_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/heatmap_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/hillshade_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/layer.hpp.ejs | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/line_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/raster_layer.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/layers/symbol_layer.hpp | 2 |
14 files changed, 96 insertions, 80 deletions
diff --git a/include/mbgl/layermanager/layer_factory.hpp b/include/mbgl/layermanager/layer_factory.hpp new file mode 100644 index 0000000000..3e2b2c3ddd --- /dev/null +++ b/include/mbgl/layermanager/layer_factory.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include <mbgl/style/layer.hpp> + +namespace mbgl { + +class RenderLayer; + +/** + * @brief The LayerFactory abstract class + * + * This class is responsible for creation of the layer objects that belong to a concrete layer type. + */ +class LayerFactory { +public: + virtual ~LayerFactory() = default; + /// Returns the layer type data. + virtual const style::LayerTypeInfo* getTypeInfo() const noexcept = 0; + /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. + 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 style::conversion::Convertible& value) const noexcept; + bool initSourceLayerAndFilter(style::Layer*, const style::conversion::Convertible& value) const noexcept; +}; + +} // namespace mbgl diff --git a/include/mbgl/layermanager/layer_manager.hpp b/include/mbgl/layermanager/layer_manager.hpp new file mode 100644 index 0000000000..038a6dcb04 --- /dev/null +++ b/include/mbgl/layermanager/layer_manager.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include <mbgl/style/layer.hpp> + +namespace mbgl { + +class LayerFactory; +class RenderLayer; + +/** + * @brief A singleton class responsible for creating layer instances. + * + * The LayerManager has implementation per platform. The LayerManager implementation + * defines what layer types are available and it can also disable annotations. + * + * Linker excludes the unreachable code for the disabled annotations and layers + * from the binaries, significantly reducing their size. + */ +class LayerManager { +public: + /** + * @brief A singleton getter. + * + * @return LayerManager* + */ + static LayerManager* get() noexcept; + + /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. + 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; + + /** + * @brief a build-time flag to enable/disable annotations in mapbox-gl-native core. + * + * At the moment, the annotations implementation in core is creating concrete + * layer instances apart from LayerManager/LayerFactory code path. + * + * So, annotations must be disabled if the LayerManager implementation does + * not provide line, fill or symbol layers (those, used by the annotations + * implementation). + * + * Note: in future, annotations implemantation will be moved from the core to platform + * SDK (see https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation) + * and this flag won't be needed any more. + */ + static const bool annotationsEnabled; + +protected: + virtual ~LayerManager() = default; + virtual LayerFactory* getFactory(const std::string& type) noexcept = 0; + virtual LayerFactory* getFactory(const style::LayerTypeInfo*) noexcept = 0; +}; + +} // namespace mbgl diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index d85f459815..bd0905cd6d 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -126,74 +126,4 @@ protected: }; } // 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 - * - * This class is responsible for creation of the layer objects that belong to a concrete layer type. - */ -class LayerFactory { -public: - virtual ~LayerFactory() = default; - /// Returns the layer type data. - virtual const style::LayerTypeInfo* getTypeInfo() const noexcept = 0; - /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. - 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 style::conversion::Convertible& value) const noexcept; - bool initSourceLayerAndFilter(style::Layer*, const style::conversion::Convertible& value) const noexcept; -}; - -/** - * @brief A singleton class responsible for creating layer instances. - * - * The LayerManager has implementation per platform. The LayerManager implementation - * defines what layer types are available and it can also disable annotations. - * - * Linker excludes the unreachable code for the disabled annotations and layers - * from the binaries, significantly reducing their size. - */ -class LayerManager { -public: - /** - * @brief A singleton getter. - * - * @return LayerManager* - */ - static LayerManager* get() noexcept; - - /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. - 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; - - /** - * @brief a build-time flag to enable/disable annotations in mapbox-gl-native core. - * - * At the moment, the annotations implementation in core is creating concrete - * layer instances apart from LayerManager/LayerFactory code path. - * - * So, annotations must be disabled if the LayerManager implementation does - * not provide line, fill or symbol layers (those, used by the annotations - * implementation). - * - * Note: in future, annotations implemantation will be moved from the core to platform - * SDK (see https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation) - * and this flag won't be needed any more. - */ - static const bool annotationsEnabled; - -protected: - virtual ~LayerManager() = default; - virtual LayerFactory* getFactory(const std::string& type) noexcept = 0; - virtual LayerFactory* getFactory(const style::LayerTypeInfo*) noexcept = 0; -}; - } // namespace mbgl diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp index b471d8613e..e501954620 100644 --- a/include/mbgl/style/layers/background_layer.hpp +++ b/include/mbgl/style/layers/background_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp index 46951653b7..6d8969e834 100644 --- a/include/mbgl/style/layers/circle_layer.hpp +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/custom_layer.hpp b/include/mbgl/style/layers/custom_layer.hpp index d204a782f2..27c16fbbc5 100644 --- a/include/mbgl/style/layers/custom_layer.hpp +++ b/include/mbgl/style/layers/custom_layer.hpp @@ -1,5 +1,6 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <array> diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp index dec1628bb3..fd0888c1eb 100644 --- a/include/mbgl/style/layers/fill_extrusion_layer.hpp +++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp index 222142daf3..6c235b6ab7 100644 --- a/include/mbgl/style/layers/fill_layer.hpp +++ b/include/mbgl/style/layers/fill_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp index 004d77c487..6ff377cf8f 100644 --- a/include/mbgl/style/layers/heatmap_layer.hpp +++ b/include/mbgl/style/layers/heatmap_layer.hpp @@ -2,12 +2,12 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/color_ramp_property_value.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp index f840386907..0c1843af75 100644 --- a/include/mbgl/style/layers/hillshade_layer.hpp +++ b/include/mbgl/style/layers/hillshade_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs index 84a8edd9de..e4c9d69dbf 100644 --- a/include/mbgl/style/layers/layer.hpp.ejs +++ b/include/mbgl/style/layers/layer.hpp.ejs @@ -7,6 +7,7 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> <% if (type === 'heatmap' || type === 'line') { -%> #include <mbgl/style/color_ramp_property_value.hpp> <% } -%> @@ -14,7 +15,6 @@ #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> <% if (type === 'line' || type === 'symbol') { -%> diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp index bbc0213c53..083bac6b9c 100644 --- a/include/mbgl/style/layers/line_layer.hpp +++ b/include/mbgl/style/layers/line_layer.hpp @@ -2,12 +2,12 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/color_ramp_property_value.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> #include <vector> diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp index 0def2faacd..ef84ee569a 100644 --- a/include/mbgl/style/layers/raster_layer.hpp +++ b/include/mbgl/style/layers/raster_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> namespace mbgl { diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index e17df295f3..3d23120559 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -2,11 +2,11 @@ #pragma once +#include <mbgl/layermanager/layer_factory.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/filter.hpp> #include <mbgl/style/property_value.hpp> #include <mbgl/style/expression/formatted.hpp> - #include <mbgl/util/color.hpp> #include <vector> |