summaryrefslogtreecommitdiff
path: root/include/mbgl/util/filesource.hpp
blob: 18c63ddfeb9a94bd7d0da734eef3d11d6c84533e (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
#ifndef MBGL_UTIL_FILESOURCE
#define MBGL_UTIL_FILESOURCE

#include <mbgl/util/uv.hpp>

#include <string>
#include <memory>
#include <functional>

namespace mbgl {

namespace platform {
struct Response;
}

enum class ResourceType : uint8_t {
    Unknown,
    Tile,
    Glyphs,
    Image,
    JSON
};

class FileSource {
public:
    FileSource();

    void setBase(const std::string &value);
    const std::string &getBase() const;

    void load(ResourceType type, const std::string &url, std::function<void(platform::Response *)> callback, const std::shared_ptr<uv::loop> loop = nullptr);

private:
    // Stores a URL that is used as a base for loading resources with relative path.
    std::string base;

    // Stores the absolute path to the cache directory.
    const std::string cache;
};

}

#endif