[core][android] Introduce mbgl::style::LayerTypeInfo
The `LayerTypeInfo` contains static meta data about certain layer type. Each layer module should have a single immutable `LayerTypeInfo` instance for the represented layer type. Both `LayerImpl` and `LayerFactory` from the module always refer to the same `LayerTypeInfo` instance, so address of this instance can be used as a layer module Id during the process life time.
This commit is contained in:
@@ -107,6 +107,10 @@ optional<conversion::Error> Layer::setVisibility(const conversion::Convertible&
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
const LayerTypeInfo* Layer::getTypeInfo() const noexcept {
|
||||
return baseImpl->getTypeInfo();
|
||||
}
|
||||
|
||||
optional<std::string> LayerFactory::getSource(const conversion::Convertible& value) const noexcept {
|
||||
auto sourceValue = objectMember(value, "source");
|
||||
if (!sourceValue) {
|
||||
|
||||
@@ -41,8 +41,9 @@ public:
|
||||
// Utility function for automatic layer grouping.
|
||||
virtual void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const = 0;
|
||||
|
||||
virtual LayerFactory* getLayerFactory() const noexcept = 0;
|
||||
virtual const LayerTypeInfo* getTypeInfo() const noexcept = 0;
|
||||
|
||||
// Note: LayerType is deprecated, do not use it.
|
||||
const LayerType type;
|
||||
std::string id;
|
||||
std::string source;
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoBackground{ "background", LayerTypeInfo::SourceNotRequired };
|
||||
} // namespace
|
||||
|
||||
BackgroundLayer::BackgroundLayer(const std::string& layerID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Background, layerID, std::string())) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return BackgroundLayerFactory::get();
|
||||
const LayerTypeInfo* BackgroundLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoBackground;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -274,23 +278,12 @@ Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
BackgroundLayerFactory* BackgroundLayerFactory::instance = nullptr;
|
||||
|
||||
BackgroundLayerFactory::BackgroundLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
BackgroundLayerFactory::BackgroundLayerFactory() = default;
|
||||
|
||||
BackgroundLayerFactory::~BackgroundLayerFactory() = default;
|
||||
|
||||
// static
|
||||
BackgroundLayerFactory* BackgroundLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool BackgroundLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "background";
|
||||
const LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoBackground;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
BackgroundPaintProperties::Transitionable paint;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoCircle{ "circle", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
CircleLayer::CircleLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Circle, layerID, sourceID)) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return CircleLayerFactory::get();
|
||||
const LayerTypeInfo* CircleLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoCircle;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -691,23 +695,12 @@ Mutable<Layer::Impl> CircleLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
CircleLayerFactory* CircleLayerFactory::instance = nullptr;
|
||||
|
||||
CircleLayerFactory::CircleLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
CircleLayerFactory::CircleLayerFactory() = default;
|
||||
|
||||
CircleLayerFactory::~CircleLayerFactory() = default;
|
||||
|
||||
// static
|
||||
CircleLayerFactory* CircleLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool CircleLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "circle";
|
||||
const LayerTypeInfo* CircleLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoCircle;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
CirclePaintProperties::Transitionable paint;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoCustom{ "", LayerTypeInfo::SourceNotRequired };
|
||||
} // namespace
|
||||
|
||||
CustomLayer::CustomLayer(const std::string& layerID,
|
||||
std::unique_ptr<CustomLayerHost> host)
|
||||
: Layer(makeMutable<Impl>(layerID, std::move(host))) {
|
||||
@@ -39,23 +43,16 @@ Mutable<Layer::Impl> CustomLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
CustomLayerFactory* CustomLayerFactory::instance = nullptr;
|
||||
|
||||
CustomLayerFactory::CustomLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
const LayerTypeInfo* CustomLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoCustom;
|
||||
}
|
||||
|
||||
CustomLayerFactory::CustomLayerFactory() = default;
|
||||
|
||||
CustomLayerFactory::~CustomLayerFactory() = default;
|
||||
|
||||
// static
|
||||
CustomLayerFactory* CustomLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool CustomLayerFactory::supportsType(const std::string&) const noexcept {
|
||||
return false;
|
||||
const LayerTypeInfo* CustomLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoCustom;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> CustomLayerFactory::createLayer(const std::string&, const conversion::Convertible&) {
|
||||
|
||||
@@ -16,9 +16,5 @@ bool CustomLayer::Impl::hasLayoutDifference(const Layer::Impl&) const {
|
||||
void CustomLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
|
||||
}
|
||||
|
||||
LayerFactory* CustomLayer::Impl::getLayerFactory() const noexcept {
|
||||
return CustomLayerFactory::get();
|
||||
}
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
std::shared_ptr<CustomLayerHost> host;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoFillExtrusion{ "fill-extrusion", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
FillExtrusionLayer::FillExtrusionLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::FillExtrusion, layerID, sourceID)) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return FillExtrusionLayerFactory::get();
|
||||
const LayerTypeInfo* FillExtrusionLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoFillExtrusion;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -493,23 +497,12 @@ Mutable<Layer::Impl> FillExtrusionLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
FillExtrusionLayerFactory* FillExtrusionLayerFactory::instance = nullptr;
|
||||
|
||||
FillExtrusionLayerFactory::FillExtrusionLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
FillExtrusionLayerFactory::FillExtrusionLayerFactory() = default;
|
||||
|
||||
FillExtrusionLayerFactory::~FillExtrusionLayerFactory() = default;
|
||||
|
||||
// static
|
||||
FillExtrusionLayerFactory* FillExtrusionLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool FillExtrusionLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "fill-extrusion";
|
||||
const LayerTypeInfo* FillExtrusionLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoFillExtrusion;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
Properties<>::Unevaluated layout;
|
||||
FillExtrusionPaintProperties::Transitionable paint;
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoFill{ "fill", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
FillLayer::FillLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Fill, layerID, sourceID)) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return FillLayerFactory::get();
|
||||
const LayerTypeInfo* FillLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoFill;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -493,23 +497,12 @@ Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
FillLayerFactory* FillLayerFactory::instance = nullptr;
|
||||
|
||||
FillLayerFactory::FillLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
FillLayerFactory::FillLayerFactory() = default;
|
||||
|
||||
FillLayerFactory::~FillLayerFactory() = default;
|
||||
|
||||
// static
|
||||
FillLayerFactory* FillLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool FillLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "fill";
|
||||
const LayerTypeInfo* FillLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoFill;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
Properties<>::Unevaluated layout;
|
||||
FillPaintProperties::Transitionable paint;
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoHeatmap{ "heatmap", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
HeatmapLayer::HeatmapLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Heatmap, layerID, sourceID)) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return HeatmapLayerFactory::get();
|
||||
const LayerTypeInfo* HeatmapLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoHeatmap;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -378,23 +382,12 @@ Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
HeatmapLayerFactory* HeatmapLayerFactory::instance = nullptr;
|
||||
|
||||
HeatmapLayerFactory::HeatmapLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
HeatmapLayerFactory::HeatmapLayerFactory() = default;
|
||||
|
||||
HeatmapLayerFactory::~HeatmapLayerFactory() = default;
|
||||
|
||||
// static
|
||||
HeatmapLayerFactory* HeatmapLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool HeatmapLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "heatmap";
|
||||
const LayerTypeInfo* HeatmapLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoHeatmap;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> HeatmapLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
HeatmapPaintProperties::Transitionable paint;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoHillshade{ "hillshade", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
HillshadeLayer::HillshadeLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Hillshade, layerID, sourceID)) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return HillshadeLayerFactory::get();
|
||||
const LayerTypeInfo* HillshadeLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoHillshade;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -425,23 +429,12 @@ Mutable<Layer::Impl> HillshadeLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
HillshadeLayerFactory* HillshadeLayerFactory::instance = nullptr;
|
||||
|
||||
HillshadeLayerFactory::HillshadeLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
HillshadeLayerFactory::HillshadeLayerFactory() = default;
|
||||
|
||||
HillshadeLayerFactory::~HillshadeLayerFactory() = default;
|
||||
|
||||
// static
|
||||
HillshadeLayerFactory* HillshadeLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool HillshadeLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "hillshade";
|
||||
const LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoHillshade;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> HillshadeLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
HillshadePaintProperties::Transitionable paint;
|
||||
};
|
||||
|
||||
@@ -19,6 +19,14 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
<% if (type === 'background') { -%>
|
||||
const LayerTypeInfo typeInfo<%- camelize(type) %>{ "<%- type %>", LayerTypeInfo::SourceNotRequired };
|
||||
<% } else { -%>
|
||||
const LayerTypeInfo typeInfo<%- camelize(type) %>{ "<%- type %>", LayerTypeInfo::SourceRequired };
|
||||
<% } -%>
|
||||
} // namespace
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID)
|
||||
: Layer(makeMutable<Impl>(LayerType::<%- camelize(type) %>, layerID, std::string())) {
|
||||
@@ -59,8 +67,8 @@ void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer<rapidjs
|
||||
}
|
||||
<% } -%>
|
||||
|
||||
LayerFactory* <%- camelize(type) %>Layer::Impl::getLayerFactory() const noexcept {
|
||||
return <%- camelize(type) %>LayerFactory::get();
|
||||
const LayerTypeInfo* <%- camelize(type) %>Layer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfo<%- camelize(type) %>;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -264,23 +272,12 @@ 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;
|
||||
|
||||
<%- camelize(type) %>LayerFactory::~<%- camelize(type) %>LayerFactory() = default;
|
||||
|
||||
// static
|
||||
<%- camelize(type) %>LayerFactory* <%- camelize(type) %>LayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool <%- camelize(type) %>LayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "<%- type %>";
|
||||
const LayerTypeInfo* <%- camelize(type) %>LayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfo<%- camelize(type) %>;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> <%- camelize(type) %>LayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoLine{ "line", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
LineLayer::LineLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Line, layerID, sourceID)) {
|
||||
}
|
||||
@@ -43,8 +47,8 @@ void LineLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>
|
||||
layout.stringify(writer);
|
||||
}
|
||||
|
||||
LayerFactory* LineLayer::Impl::getLayerFactory() const noexcept {
|
||||
return LineLayerFactory::get();
|
||||
const LayerTypeInfo* LineLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoLine;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -832,23 +836,12 @@ Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
LineLayerFactory* LineLayerFactory::instance = nullptr;
|
||||
|
||||
LineLayerFactory::LineLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
LineLayerFactory::LineLayerFactory() = default;
|
||||
|
||||
LineLayerFactory::~LineLayerFactory() = default;
|
||||
|
||||
// static
|
||||
LineLayerFactory* LineLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool LineLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "line";
|
||||
const LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoLine;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
LineLayoutProperties::Unevaluated layout;
|
||||
LinePaintProperties::Transitionable paint;
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoRaster{ "raster", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
RasterLayer::RasterLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Raster, layerID, sourceID)) {
|
||||
}
|
||||
@@ -42,8 +46,8 @@ 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 noexcept {
|
||||
return RasterLayerFactory::get();
|
||||
const LayerTypeInfo* RasterLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoRaster;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -514,23 +518,12 @@ Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
RasterLayerFactory* RasterLayerFactory::instance = nullptr;
|
||||
|
||||
RasterLayerFactory::RasterLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
RasterLayerFactory::RasterLayerFactory() = default;
|
||||
|
||||
RasterLayerFactory::~RasterLayerFactory() = default;
|
||||
|
||||
// static
|
||||
RasterLayerFactory* RasterLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool RasterLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "raster";
|
||||
const LayerTypeInfo* RasterLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoRaster;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> RasterLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
RasterPaintProperties::Transitionable paint;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
namespace {
|
||||
const LayerTypeInfo typeInfoSymbol{ "symbol", LayerTypeInfo::SourceRequired };
|
||||
} // namespace
|
||||
|
||||
SymbolLayer::SymbolLayer(const std::string& layerID, const std::string& sourceID)
|
||||
: Layer(makeMutable<Impl>(LayerType::Symbol, layerID, sourceID)) {
|
||||
}
|
||||
@@ -43,8 +47,8 @@ void SymbolLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffe
|
||||
layout.stringify(writer);
|
||||
}
|
||||
|
||||
LayerFactory* SymbolLayer::Impl::getLayerFactory() const noexcept {
|
||||
return SymbolLayerFactory::get();
|
||||
const LayerTypeInfo* SymbolLayer::Impl::getTypeInfo() const noexcept {
|
||||
return &typeInfoSymbol;
|
||||
}
|
||||
|
||||
// Layout properties
|
||||
@@ -1982,23 +1986,12 @@ Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
SymbolLayerFactory* SymbolLayerFactory::instance = nullptr;
|
||||
|
||||
SymbolLayerFactory::SymbolLayerFactory() {
|
||||
assert(!instance);
|
||||
instance = this;
|
||||
}
|
||||
SymbolLayerFactory::SymbolLayerFactory() = default;
|
||||
|
||||
SymbolLayerFactory::~SymbolLayerFactory() = default;
|
||||
|
||||
// static
|
||||
SymbolLayerFactory* SymbolLayerFactory::get() noexcept {
|
||||
assert(instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool SymbolLayerFactory::supportsType(const std::string& type) const noexcept {
|
||||
return type == "symbol";
|
||||
const LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept {
|
||||
return &typeInfoSymbol;
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override;
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
|
||||
LayerFactory* getLayerFactory() const noexcept final;
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final;
|
||||
|
||||
SymbolLayoutProperties::Unevaluated layout;
|
||||
SymbolPaintProperties::Transitionable paint;
|
||||
|
||||
Reference in New Issue
Block a user