diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-15 15:47:25 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-15 18:32:31 +0200 |
commit | 33818233cf49ffa7238a3d1b2bbf9fc126cbc253 (patch) | |
tree | 86833d95d8bf7abbcb8e6965aaba65d666ffff52 /src/mbgl/style/layers/symbol_layer.cpp | |
parent | 73dcfe2d0d3475ad9584969c7908ba681a3f5bfa (diff) | |
download | qtlocation-mapboxgl-33818233cf49ffa7238a3d1b2bbf9fc126cbc253.tar.gz |
[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.
Diffstat (limited to 'src/mbgl/style/layers/symbol_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 5380194534..0c37396637 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -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) { |