summaryrefslogtreecommitdiff
path: root/include/mbgl/style/sources/raster_source.hpp
blob: e49436b971c0d4f6c6ebf348671019b9a3a58a5b (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <mbgl/style/source.hpp>
#include <mbgl/util/tileset.hpp>
#include <mbgl/util/variant.hpp>

namespace mbgl {

class AsyncRequest;

namespace style {

class RasterSource : public Source {
public:
    RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize);
    ~RasterSource() override;

    const variant<std::string, Tileset>* getURLOrTileset() const final;
    optional<std::string> getURL() const;

    class Impl;
    const Impl& impl() const;

    void loadDescription(FileSource&) final;

    bool supportsLayerType(const mbgl::style::LayerTypeInfo*) const override;

    mapbox::base::WeakPtr<Source> makeWeakPtr() final {
        return weakFactory.makeWeakPtr();
    }

    Value serialize() const override;

protected:
    RasterSource(Immutable<Impl>, variant<std::string, Tileset> urlOrTileset_);

    Mutable<Source::Impl> createMutable() const noexcept override;
    virtual Mutable<Source::Impl> createMutable(Tileset tileset) const noexcept;

private:
    const variant<std::string, Tileset> urlOrTileset;
    std::unique_ptr<AsyncRequest> req;
    mapbox::base::WeakPtrFactory<Source> weakFactory {this};
};

} // namespace style
} // namespace mbgl