Refer corresponding LayerFactory instance from the Layer::Impl
This commit is contained in:
@@ -40,7 +40,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
|
||||
@@ -82,11 +82,11 @@ public:
|
||||
// object here, so that separately-obtained references to this object share
|
||||
// identical platform-native peers.
|
||||
util::peer peer;
|
||||
Layer(Immutable<Impl>);
|
||||
protected:
|
||||
Layer(Immutable<Impl>);
|
||||
virtual Mutable<Impl> mutableBaseImpl() const = 0;
|
||||
|
||||
LayerObserver* observer = nullptr;
|
||||
LayerObserver* observer;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -97,10 +97,11 @@ protected:
|
||||
class LayerFactory {
|
||||
public:
|
||||
virtual ~LayerFactory() = default;
|
||||
/// Returns the type of the layers, created by this factory.
|
||||
virtual const char* type() const = 0;
|
||||
/// Returns \c true if this factory can produce layers of the given type of the layers; returns \c false otherwise.
|
||||
virtual bool supportsType(const std::string& type) const = 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;
|
||||
|
||||
protected:
|
||||
optional<std::string> getSource(const conversion::Convertible& value) const;
|
||||
bool initSourceLayerAndFilter(Layer*, const conversion::Convertible& value) const;
|
||||
|
||||
@@ -57,11 +57,17 @@ protected:
|
||||
};
|
||||
|
||||
class BackgroundLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
BackgroundLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~BackgroundLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static BackgroundLayerFactory* get();
|
||||
|
||||
private:
|
||||
static BackgroundLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -105,11 +105,17 @@ protected:
|
||||
};
|
||||
|
||||
class CircleLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
CircleLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~CircleLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static CircleLayerFactory* get();
|
||||
|
||||
private:
|
||||
static CircleLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -85,5 +85,19 @@ public:
|
||||
Mutable<Layer::Impl> mutableBaseImpl() const final;
|
||||
};
|
||||
|
||||
class CustomLayerFactory : public LayerFactory {
|
||||
public:
|
||||
CustomLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~CustomLayerFactory() override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static CustomLayerFactory* get();
|
||||
|
||||
private:
|
||||
static CustomLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -81,11 +81,17 @@ protected:
|
||||
};
|
||||
|
||||
class FillExtrusionLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
FillExtrusionLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~FillExtrusionLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static FillExtrusionLayerFactory* get();
|
||||
|
||||
private:
|
||||
static FillExtrusionLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -81,11 +81,17 @@ protected:
|
||||
};
|
||||
|
||||
class FillLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
FillLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~FillLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static FillLayerFactory* get();
|
||||
|
||||
private:
|
||||
static FillLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -70,11 +70,17 @@ protected:
|
||||
};
|
||||
|
||||
class HeatmapLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
HeatmapLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~HeatmapLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static HeatmapLayerFactory* get();
|
||||
|
||||
private:
|
||||
static HeatmapLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -75,11 +75,17 @@ protected:
|
||||
};
|
||||
|
||||
class HillshadeLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
HillshadeLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~HillshadeLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static HillshadeLayerFactory* get();
|
||||
|
||||
private:
|
||||
static HillshadeLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -73,11 +73,17 @@ protected:
|
||||
};
|
||||
|
||||
class <%- camelize(type) %>LayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
<%- camelize(type) %>LayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~<%- camelize(type) %>LayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static <%- camelize(type) %>LayerFactory* get();
|
||||
|
||||
private:
|
||||
static <%- camelize(type) %>LayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -126,11 +126,17 @@ protected:
|
||||
};
|
||||
|
||||
class LineLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
LineLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~LineLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static LineLayerFactory* get();
|
||||
|
||||
private:
|
||||
static LineLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -87,11 +87,17 @@ protected:
|
||||
};
|
||||
|
||||
class RasterLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
RasterLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~RasterLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static RasterLayerFactory* get();
|
||||
|
||||
private:
|
||||
static RasterLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
@@ -275,11 +275,17 @@ protected:
|
||||
};
|
||||
|
||||
class SymbolLayerFactory : public LayerFactory {
|
||||
protected:
|
||||
public:
|
||||
SymbolLayerFactory();
|
||||
// LayerFactory overrides.
|
||||
~SymbolLayerFactory() override;
|
||||
const char* type() const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) override;
|
||||
bool supportsType(const std::string& type) const final;
|
||||
std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
|
||||
|
||||
static SymbolLayerFactory* get();
|
||||
|
||||
private:
|
||||
static SymbolLayerFactory* instance;
|
||||
};
|
||||
|
||||
} // namespace style
|
||||
|
||||
61
platform/default/layer_manager.cpp
Normal file
61
platform/default/layer_manager.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <mbgl/style/layer.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>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
class LayerManagerBase : public LayerManager {
|
||||
public:
|
||||
LayerManagerBase();
|
||||
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::vector<std::unique_ptr<LayerFactory>> factories;
|
||||
};
|
||||
|
||||
LayerManagerBase::LayerManagerBase() {
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new FillLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new LineLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new CircleLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new SymbolLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new RasterLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new BackgroundLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new HillshadeLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new FillExtrusionLayerFactory));
|
||||
factories.emplace_back(std::unique_ptr<LayerFactory>(new HeatmapLayerFactory));
|
||||
}
|
||||
|
||||
std::unique_ptr<Layer> LayerManagerBase::createLayer(const std::string& type, const std::string& id, const conversion::Convertible& value, conversion::Error& error) {
|
||||
for (const auto& factory: factories) {
|
||||
if (factory->supportsType(type)) {
|
||||
auto layer = factory->createLayer(id, value);
|
||||
if (!layer) {
|
||||
error.message = "Error parsing a layer of type: " + type;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
error.message = "Unsupported layer type: " + type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
LayerManager* LayerManager::get() {
|
||||
static LayerManagerBase impl;
|
||||
return &impl;
|
||||
}
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
@@ -34,6 +34,7 @@ macro(mbgl_platform_core)
|
||||
PRIVATE platform/darwin/src/nsthread.mm
|
||||
PRIVATE platform/darwin/src/string_nsstring.mm
|
||||
PRIVATE platform/default/bidi.cpp
|
||||
PRIVATE platform/default/layer_manager.cpp
|
||||
PRIVATE platform/default/thread_local.cpp
|
||||
PRIVATE platform/default/utf.cpp
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ macro(mbgl_platform_core)
|
||||
PRIVATE platform/default/thread.cpp
|
||||
PRIVATE platform/default/bidi.cpp
|
||||
PRIVATE platform/default/collator.cpp
|
||||
PRIVATE platform/default/layer_manager.cpp
|
||||
PRIVATE platform/default/local_glyph_rasterizer.cpp
|
||||
PRIVATE platform/default/thread_local.cpp
|
||||
PRIVATE platform/default/unaccent.cpp
|
||||
|
||||
@@ -14,6 +14,7 @@ macro(mbgl_platform_core)
|
||||
PRIVATE platform/darwin/src/nsthread.mm
|
||||
PRIVATE platform/darwin/src/string_nsstring.mm
|
||||
PRIVATE platform/default/bidi.cpp
|
||||
PRIVATE platform/default/layer_manager.cpp
|
||||
PRIVATE platform/default/thread_local.cpp
|
||||
PRIVATE platform/default/utf.cpp
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ set(MBGL_QT_CORE_FILES
|
||||
PRIVATE platform/default/collator.cpp
|
||||
PRIVATE platform/default/unaccent.cpp
|
||||
PRIVATE platform/default/unaccent.hpp
|
||||
|
||||
#Layer manager
|
||||
PRIVATE platform/default/layer_manager.cpp
|
||||
)
|
||||
|
||||
set(MBGL_QT_FILESOURCE_FILES
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user