summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/layer.cpp58
-rw-r--r--src/mbgl/style/layer_impl.hpp2
-rw-r--r--src/mbgl/style/layers/background_layer.cpp21
-rw-r--r--src/mbgl/style/layers/background_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp21
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/custom_layer.cpp24
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.cpp4
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp21
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp21
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/heatmap_layer.cpp21
-rw-r--r--src/mbgl/style/layers/heatmap_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/hillshade_layer.cpp21
-rw-r--r--src/mbgl/style/layers/hillshade_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs21
-rw-r--r--src/mbgl/style/layers/line_layer.cpp21
-rw-r--r--src/mbgl/style/layers/line_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp21
-rw-r--r--src/mbgl/style/layers/raster_layer_impl.hpp1
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp21
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.hpp1
24 files changed, 230 insertions, 78 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
diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp
index f350044925..f30db14cc9 100644
--- a/src/mbgl/style/layer_impl.hpp
+++ b/src/mbgl/style/layer_impl.hpp
@@ -41,6 +41,8 @@ public:
// Utility function for automatic layer grouping.
virtual void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const = 0;
+ virtual LayerFactory* getLayerFactory() const = 0;
+
const LayerType type;
std::string id;
std::string source;
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index b2db8332bc..8b3ce5ff68 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> BackgroundLayer::cloneRef(const std::string& id_) const {
void BackgroundLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* BackgroundLayer::Impl::getLayerFactory() const {
+ return BackgroundLayerFactory::get();
+}
+
// Layout properties
@@ -270,10 +274,23 @@ Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+BackgroundLayerFactory* BackgroundLayerFactory::instance = nullptr;
+
+BackgroundLayerFactory::BackgroundLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
BackgroundLayerFactory::~BackgroundLayerFactory() = default;
-const char* BackgroundLayerFactory::type() const {
- return "background";
+// static
+BackgroundLayerFactory* BackgroundLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool BackgroundLayerFactory::supportsType(const std::string& type) const {
+ return type == "background";
}
std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/background_layer_impl.hpp b/src/mbgl/style/layers/background_layer_impl.hpp
index 248a751027..d48f0f62c8 100644
--- a/src/mbgl/style/layers/background_layer_impl.hpp
+++ b/src/mbgl/style/layers/background_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
BackgroundPaintProperties::Transitionable paint;
};
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index eda4a9644e..01a71df6d3 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> CircleLayer::cloneRef(const std::string& id_) const {
void CircleLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* CircleLayer::Impl::getLayerFactory() const {
+ return CircleLayerFactory::get();
+}
+
// Layout properties
@@ -687,10 +691,23 @@ Mutable<Layer::Impl> CircleLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+CircleLayerFactory* CircleLayerFactory::instance = nullptr;
+
+CircleLayerFactory::CircleLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
CircleLayerFactory::~CircleLayerFactory() = default;
-const char* CircleLayerFactory::type() const {
- return "circle";
+// static
+CircleLayerFactory* CircleLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool CircleLayerFactory::supportsType(const std::string& type) const {
+ return type == "circle";
}
std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp
index 4b148cdc42..8390feb97e 100644
--- a/src/mbgl/style/layers/circle_layer_impl.hpp
+++ b/src/mbgl/style/layers/circle_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
CirclePaintProperties::Transitionable paint;
};
diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp
index 90b97104a0..060e455217 100644
--- a/src/mbgl/style/layers/custom_layer.cpp
+++ b/src/mbgl/style/layers/custom_layer.cpp
@@ -39,5 +39,29 @@ Mutable<Layer::Impl> CustomLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+CustomLayerFactory* CustomLayerFactory::instance = nullptr;
+
+CustomLayerFactory::CustomLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
+CustomLayerFactory::~CustomLayerFactory() = default;
+
+// static
+CustomLayerFactory* CustomLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool CustomLayerFactory::supportsType(const std::string&) const {
+ return false;
+}
+
+std::unique_ptr<style::Layer> CustomLayerFactory::createLayer(const std::string&, const conversion::Convertible&) {
+ assert(false);
+ return nullptr;
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp
index 05c41623c4..ce8d5263dd 100644
--- a/src/mbgl/style/layers/custom_layer_impl.cpp
+++ b/src/mbgl/style/layers/custom_layer_impl.cpp
@@ -16,5 +16,9 @@ bool CustomLayer::Impl::hasLayoutDifference(const Layer::Impl&) const {
void CustomLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* CustomLayer::Impl::getLayerFactory() const {
+ return CustomLayerFactory::get();
+}
+
} // namespace style
} // namespace mbgl
diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp
index a41962c276..ad39478df9 100644
--- a/src/mbgl/style/layers/custom_layer_impl.hpp
+++ b/src/mbgl/style/layers/custom_layer_impl.hpp
@@ -18,6 +18,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
std::shared_ptr<CustomLayerHost> host;
};
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index f72414557e..3eccf045ea 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> FillExtrusionLayer::cloneRef(const std::string& id_) cons
void FillExtrusionLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* FillExtrusionLayer::Impl::getLayerFactory() const {
+ return FillExtrusionLayerFactory::get();
+}
+
// Layout properties
@@ -489,10 +493,23 @@ Mutable<Layer::Impl> FillExtrusionLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+FillExtrusionLayerFactory* FillExtrusionLayerFactory::instance = nullptr;
+
+FillExtrusionLayerFactory::FillExtrusionLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
FillExtrusionLayerFactory::~FillExtrusionLayerFactory() = default;
-const char* FillExtrusionLayerFactory::type() const {
- return "fill-extrusion";
+// static
+FillExtrusionLayerFactory* FillExtrusionLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool FillExtrusionLayerFactory::supportsType(const std::string& type) const {
+ return type == "fill-extrusion";
}
std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
index 9a9a52dea4..dfbc3939f0 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
Properties<>::Unevaluated layout;
FillExtrusionPaintProperties::Transitionable paint;
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 9314d5026a..53eb328326 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> FillLayer::cloneRef(const std::string& id_) const {
void FillLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* FillLayer::Impl::getLayerFactory() const {
+ return FillLayerFactory::get();
+}
+
// Layout properties
@@ -489,10 +493,23 @@ Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+FillLayerFactory* FillLayerFactory::instance = nullptr;
+
+FillLayerFactory::FillLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
FillLayerFactory::~FillLayerFactory() = default;
-const char* FillLayerFactory::type() const {
- return "fill";
+// static
+FillLayerFactory* FillLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool FillLayerFactory::supportsType(const std::string& type) const {
+ return type == "fill";
}
std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp
index 22573e0d5d..b99f4303d9 100644
--- a/src/mbgl/style/layers/fill_layer_impl.hpp
+++ b/src/mbgl/style/layers/fill_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
Properties<>::Unevaluated layout;
FillPaintProperties::Transitionable paint;
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp
index 2201a39c8b..5afd951d58 100644
--- a/src/mbgl/style/layers/heatmap_layer.cpp
+++ b/src/mbgl/style/layers/heatmap_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> HeatmapLayer::cloneRef(const std::string& id_) const {
void HeatmapLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* HeatmapLayer::Impl::getLayerFactory() const {
+ return HeatmapLayerFactory::get();
+}
+
// Layout properties
@@ -374,10 +378,23 @@ Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+HeatmapLayerFactory* HeatmapLayerFactory::instance = nullptr;
+
+HeatmapLayerFactory::HeatmapLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
HeatmapLayerFactory::~HeatmapLayerFactory() = default;
-const char* HeatmapLayerFactory::type() const {
- return "heatmap";
+// static
+HeatmapLayerFactory* HeatmapLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool HeatmapLayerFactory::supportsType(const std::string& type) const {
+ return type == "heatmap";
}
std::unique_ptr<style::Layer> HeatmapLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/heatmap_layer_impl.hpp b/src/mbgl/style/layers/heatmap_layer_impl.hpp
index cc27c3076a..55de21341b 100644
--- a/src/mbgl/style/layers/heatmap_layer_impl.hpp
+++ b/src/mbgl/style/layers/heatmap_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
HeatmapPaintProperties::Transitionable paint;
};
diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp
index b0cb812971..2bc0120ac1 100644
--- a/src/mbgl/style/layers/hillshade_layer.cpp
+++ b/src/mbgl/style/layers/hillshade_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> HillshadeLayer::cloneRef(const std::string& id_) const {
void HillshadeLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* HillshadeLayer::Impl::getLayerFactory() const {
+ return HillshadeLayerFactory::get();
+}
+
// Layout properties
@@ -421,10 +425,23 @@ Mutable<Layer::Impl> HillshadeLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+HillshadeLayerFactory* HillshadeLayerFactory::instance = nullptr;
+
+HillshadeLayerFactory::HillshadeLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
HillshadeLayerFactory::~HillshadeLayerFactory() = default;
-const char* HillshadeLayerFactory::type() const {
- return "hillshade";
+// static
+HillshadeLayerFactory* HillshadeLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool HillshadeLayerFactory::supportsType(const std::string& type) const {
+ return type == "hillshade";
}
std::unique_ptr<style::Layer> HillshadeLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/hillshade_layer_impl.hpp b/src/mbgl/style/layers/hillshade_layer_impl.hpp
index 5618b7dfe2..ad94ac9790 100644
--- a/src/mbgl/style/layers/hillshade_layer_impl.hpp
+++ b/src/mbgl/style/layers/hillshade_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
HillshadePaintProperties::Transitionable paint;
};
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 6d08370342..85173c2eac 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -59,6 +59,10 @@ void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer<rapidjs
}
<% } -%>
+LayerFactory* <%- camelize(type) %>Layer::Impl::getLayerFactory() const {
+ return <%- camelize(type) %>LayerFactory::get();
+}
+
// Layout properties
<% for (const property of layoutProperties) { -%>
@@ -260,10 +264,23 @@ Mutable<Layer::Impl> <%- camelize(type) %>Layer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+<%- camelize(type) %>LayerFactory* <%- camelize(type) %>LayerFactory::instance = nullptr;
+
+<%- camelize(type) %>LayerFactory::<%- camelize(type) %>LayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
<%- camelize(type) %>LayerFactory::~<%- camelize(type) %>LayerFactory() = default;
-const char* <%- camelize(type) %>LayerFactory::type() const {
- return "<%- type %>";
+// static
+<%- camelize(type) %>LayerFactory* <%- camelize(type) %>LayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool <%- camelize(type) %>LayerFactory::supportsType(const std::string& type) const {
+ return type == "<%- type %>";
}
std::unique_ptr<style::Layer> <%- camelize(type) %>LayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index f80cba85f1..2175ab54a1 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -43,6 +43,10 @@ void LineLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>
layout.stringify(writer);
}
+LayerFactory* LineLayer::Impl::getLayerFactory() const {
+ return LineLayerFactory::get();
+}
+
// Layout properties
PropertyValue<LineCapType> LineLayer::getDefaultLineCap() {
@@ -828,10 +832,23 @@ Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+LineLayerFactory* LineLayerFactory::instance = nullptr;
+
+LineLayerFactory::LineLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
LineLayerFactory::~LineLayerFactory() = default;
-const char* LineLayerFactory::type() const {
- return "line";
+// static
+LineLayerFactory* LineLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool LineLayerFactory::supportsType(const std::string& type) const {
+ return type == "line";
}
std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp
index 04adc0e85c..9faa192c5f 100644
--- a/src/mbgl/style/layers/line_layer_impl.hpp
+++ b/src/mbgl/style/layers/line_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
LineLayoutProperties::Unevaluated layout;
LinePaintProperties::Transitionable paint;
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 4cadd26cd3..f45b86f796 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -42,6 +42,10 @@ std::unique_ptr<Layer> RasterLayer::cloneRef(const std::string& id_) const {
void RasterLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
+LayerFactory* RasterLayer::Impl::getLayerFactory() const {
+ return RasterLayerFactory::get();
+}
+
// Layout properties
@@ -510,10 +514,23 @@ Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+RasterLayerFactory* RasterLayerFactory::instance = nullptr;
+
+RasterLayerFactory::RasterLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
RasterLayerFactory::~RasterLayerFactory() = default;
-const char* RasterLayerFactory::type() const {
- return "raster";
+// static
+RasterLayerFactory* RasterLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool RasterLayerFactory::supportsType(const std::string& type) const {
+ return type == "raster";
}
std::unique_ptr<style::Layer> RasterLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp
index adbe703e92..9916a01d47 100644
--- a/src/mbgl/style/layers/raster_layer_impl.hpp
+++ b/src/mbgl/style/layers/raster_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
RasterPaintProperties::Transitionable paint;
};
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index d453ddb58d..682c7fbdf6 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -43,6 +43,10 @@ void SymbolLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffe
layout.stringify(writer);
}
+LayerFactory* SymbolLayer::Impl::getLayerFactory() const {
+ return SymbolLayerFactory::get();
+}
+
// Layout properties
PropertyValue<SymbolPlacementType> SymbolLayer::getDefaultSymbolPlacement() {
@@ -1978,10 +1982,23 @@ Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+SymbolLayerFactory* SymbolLayerFactory::instance = nullptr;
+
+SymbolLayerFactory::SymbolLayerFactory() {
+ assert(!instance);
+ instance = this;
+}
+
SymbolLayerFactory::~SymbolLayerFactory() = default;
-const char* SymbolLayerFactory::type() const {
- return "symbol";
+// static
+SymbolLayerFactory* SymbolLayerFactory::get() {
+ assert(instance);
+ return instance;
+}
+
+bool SymbolLayerFactory::supportsType(const std::string& type) const {
+ return type == "symbol";
}
std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp
index f8ef87dcdf..2b88bad315 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.hpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.hpp
@@ -13,6 +13,7 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
+ LayerFactory* getLayerFactory() const final;
SymbolLayoutProperties::Unevaluated layout;
SymbolPaintProperties::Transitionable paint;