summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-11-05 19:49:40 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-11-07 16:34:20 +0200
commitffdeef3a26306e447f1cc52a8e14d42fb035611d (patch)
tree7e3217d761581161d39b2552072d1b3cef8df67a /include
parentf560b4f9efebb4d448181724304f63b683a26b67 (diff)
downloadqtlocation-mapboxgl-ffdeef3a26306e447f1cc52a8e14d42fb035611d.tar.gz
Refer corresponding LayerFactory instance from the Layer::Impl
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/style/layer.hpp11
-rw-r--r--include/mbgl/style/layers/background_layer.hpp12
-rw-r--r--include/mbgl/style/layers/circle_layer.hpp12
-rw-r--r--include/mbgl/style/layers/custom_layer.hpp14
-rw-r--r--include/mbgl/style/layers/fill_extrusion_layer.hpp12
-rw-r--r--include/mbgl/style/layers/fill_layer.hpp12
-rw-r--r--include/mbgl/style/layers/heatmap_layer.hpp12
-rw-r--r--include/mbgl/style/layers/hillshade_layer.hpp12
-rw-r--r--include/mbgl/style/layers/layer.hpp.ejs12
-rw-r--r--include/mbgl/style/layers/line_layer.hpp12
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp12
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp12
12 files changed, 110 insertions, 35 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp
index fd0824c03f..c2aaaa6f48 100644
--- a/include/mbgl/style/layer.hpp
+++ b/include/mbgl/style/layer.hpp
@@ -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;
diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp
index 989ef54b21..61e95d2273 100644
--- a/include/mbgl/style/layers/background_layer.hpp
+++ b/include/mbgl/style/layers/background_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp
index dd22275b85..92a6bbd92e 100644
--- a/include/mbgl/style/layers/circle_layer.hpp
+++ b/include/mbgl/style/layers/circle_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/custom_layer.hpp b/include/mbgl/style/layers/custom_layer.hpp
index 4ae59dfae3..f58e41adf5 100644
--- a/include/mbgl/style/layers/custom_layer.hpp
+++ b/include/mbgl/style/layers/custom_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp
index fcc66e782b..bc761f2bec 100644
--- a/include/mbgl/style/layers/fill_extrusion_layer.hpp
+++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp
index 0c36435ffc..7ef6727691 100644
--- a/include/mbgl/style/layers/fill_layer.hpp
+++ b/include/mbgl/style/layers/fill_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp
index 3f53877523..e38c6ab6e1 100644
--- a/include/mbgl/style/layers/heatmap_layer.hpp
+++ b/include/mbgl/style/layers/heatmap_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp
index 3227505f5d..e1e9a4d0a1 100644
--- a/include/mbgl/style/layers/hillshade_layer.hpp
+++ b/include/mbgl/style/layers/hillshade_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs
index b19b501713..6006352eee 100644
--- a/include/mbgl/style/layers/layer.hpp.ejs
+++ b/include/mbgl/style/layers/layer.hpp.ejs
@@ -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
diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp
index 62cca8215d..de1ed8eef1 100644
--- a/include/mbgl/style/layers/line_layer.hpp
+++ b/include/mbgl/style/layers/line_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index 27057c6af7..5cf06a7d98 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -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
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index 6c0ec6ca6e..5dac5925dd 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -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