summaryrefslogtreecommitdiff
path: root/include/mbgl/layermanager/layer_factory.hpp
blob: 3e2b2c3ddd959bd83e5e3f21cf965327684af48d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include <mbgl/style/layer.hpp>

namespace mbgl {

class RenderLayer;

/**
 * @brief The LayerFactory abstract class
 * 
 * This class is responsible for creation of the layer objects that belong to a concrete layer type.
 */
class LayerFactory {
public:
    virtual ~LayerFactory() = default;
    /// Returns the layer type data.
    virtual const style::LayerTypeInfo* getTypeInfo() const noexcept = 0;
    /// Returns a new Layer instance on success call; returns `nulltptr` otherwise. 
    virtual std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept = 0;
    /// Returns a new RenderLayer instance on success call; returns `nulltptr` otherwise.
    virtual std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept = 0;

protected:
    optional<std::string> getSource(const style::conversion::Convertible& value) const noexcept;
    bool initSourceLayerAndFilter(style::Layer*, const style::conversion::Convertible& value) const noexcept;
};

} // namespace mbgl