From ff09c94d0825f5dbe7dddce52b64e74d61978976 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 15 Nov 2018 15:47:25 +0200 Subject: [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. --- src/mbgl/style/layers/symbol_layer.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/mbgl/style/layers/symbol_layer.cpp') 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(LayerType::Symbol, layerID, sourceID)) { } @@ -43,8 +47,8 @@ void SymbolLayer::Impl::stringifyLayout(rapidjson::Writer SymbolLayer::mutableBaseImpl() const { return staticMutableCast(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 SymbolLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) { -- cgit v1.2.1