diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-10-28 22:33:06 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-10-31 18:05:01 +0200 |
commit | cfcb53128b41941a9cdacfec18d618b0866a96bc (patch) | |
tree | 27ee48ad45fca144d21f71673137c470bbb19459 /src/mbgl/style/layers/raster_layer.cpp | |
parent | 278aa3370374154ad6fac7790d2da1546e8493f3 (diff) | |
download | qtlocation-mapboxgl-cfcb53128b41941a9cdacfec18d618b0866a96bc.tar.gz |
Introduce the style::Layer factory classes
This patch introduces the initial implementation of
- A `LayerFactory` abstract class that creates `style::Layer` instances of
a certain layer type (line, hillshade, round, ..)
- A singleton `LayerManager` class, which is responsible for initializing
the `LayerFactory` instances and forwarding the `create()` calls to the
corresponding factory.
Diffstat (limited to 'src/mbgl/style/layers/raster_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/raster_layer.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index 76e433aa73..4cadd26cd3 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -510,5 +510,21 @@ Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const { return staticMutableCast<Layer::Impl>(mutableImpl()); } +RasterLayerFactory::~RasterLayerFactory() = default; + +const char* RasterLayerFactory::type() const { + return "raster"; +} + +std::unique_ptr<style::Layer> RasterLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) { + optional<std::string> source = getSource(value); + if (!source) { + return nullptr; + } + + std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new RasterLayer(id, *source)); + return layer; +} + } // namespace style } // namespace mbgl |