diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-05 19:49:40 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-07 16:34:20 +0200 |
commit | ffdeef3a26306e447f1cc52a8e14d42fb035611d (patch) | |
tree | 7e3217d761581161d39b2552072d1b3cef8df67a /src/mbgl/style/layer.cpp | |
parent | f560b4f9efebb4d448181724304f63b683a26b67 (diff) | |
download | qtlocation-mapboxgl-ffdeef3a26306e447f1cc52a8e14d42fb035611d.tar.gz |
Refer corresponding LayerFactory instance from the Layer::Impl
Diffstat (limited to 'src/mbgl/style/layer.cpp')
-rw-r--r-- | src/mbgl/style/layer.cpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp index 573e6125b4..e26a02686e 100644 --- a/src/mbgl/style/layer.cpp +++ b/src/mbgl/style/layer.cpp @@ -5,17 +5,6 @@ #include <mbgl/style/conversion/filter.hpp> #include <mbgl/style/conversion_impl.hpp> -#include <mbgl/style/layers/symbol_layer.hpp> -#include <mbgl/style/layers/background_layer.hpp> -#include <mbgl/style/layers/circle_layer.hpp> -#include <mbgl/style/layers/fill_extrusion_layer.hpp> -#include <mbgl/style/layers/fill_layer.hpp> -#include <mbgl/style/layers/heatmap_layer.hpp> -#include <mbgl/style/layers/hillshade_layer.hpp> -#include <mbgl/style/layers/line_layer.hpp> -#include <mbgl/style/layers/raster_layer.hpp> -#include <mbgl/style/layers/symbol_layer.hpp> - namespace mbgl { namespace style { @@ -155,52 +144,5 @@ bool LayerFactory::initSourceLayerAndFilter(Layer* layer, const conversion::Conv return true; } -// TODO: Move the LayerManager implementation to the dedicated .cpp file per platform. -class LayerManagerImpl : public LayerManager { -public: - void addLayerFactory(LayerFactory* factory) { - factories.emplace(std::make_pair(factory->type(), std::unique_ptr<LayerFactory>(factory))); - } -private: - // LayerManager overrides. - std::unique_ptr<Layer> createLayer(const std::string& type, const std::string& id, const conversion::Convertible& value, conversion::Error& error) final; - - std::unordered_map<std::string, std::unique_ptr<LayerFactory>> factories; -}; - -std::unique_ptr<Layer> LayerManagerImpl::createLayer(const std::string& type, const std::string& id, const conversion::Convertible& value, conversion::Error& error) { - auto search = factories.find(type); - if (search != factories.end()) { - if (auto layer = search->second->createLayer(id, value)) { - return layer; - } - error.message = "Error parsing a layer of type: " + type; - } else { - error.message = "Unsupported layer type: " + type; - } - return nullptr; -} - -// static -LayerManager* LayerManager::get() { - static LayerManager* instance = nullptr; - if (instance == nullptr) { - static LayerManagerImpl impl; - impl.addLayerFactory(new FillLayerFactory); - impl.addLayerFactory(new LineLayerFactory); - impl.addLayerFactory(new CircleLayerFactory); - impl.addLayerFactory(new SymbolLayerFactory); - impl.addLayerFactory(new RasterLayerFactory); - impl.addLayerFactory(new BackgroundLayerFactory); - impl.addLayerFactory(new HillshadeLayerFactory); - impl.addLayerFactory(new FillExtrusionLayerFactory); - impl.addLayerFactory(new HeatmapLayerFactory); - - instance = &impl; - } - return instance; -} - - } // namespace style } // namespace mbgl |