summaryrefslogtreecommitdiff
path: root/src/mbgl/style/tile_source_impl.hpp
blob: 0e5a53add79f25886af74d140bbc26354e6c516c (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_impl.hpp>
#include <mbgl/util/tileset.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/optional.hpp>

namespace mbgl {

class AsyncRequest;

namespace style {

/*
   Shared implementation for VectorSource and RasterSource. Should eventually
   be refactored to use composition rather than inheritance.
*/
class TileSourceImpl : public Source::Impl {
public:
    TileSourceImpl(SourceType, std::string id, Source&,
                   variant<std::string, Tileset> urlOrTileset,
                   uint16_t tileSize);
    ~TileSourceImpl() override;

    void loadDescription(FileSource&) final;

    uint16_t getTileSize() const {
        return tileSize;
    }

    const variant<std::string, Tileset>& getURLOrTileset() const {
        return urlOrTileset;
    }

    optional<std::string> getAttribution() const override;
    optional<Tileset> getTileset() const;

protected:
    const variant<std::string, Tileset> urlOrTileset;
    const uint16_t tileSize;

    Tileset tileset;
    std::unique_ptr<AsyncRequest> req;
};

} // namespace style
} // namespace mbgl