summaryrefslogtreecommitdiff
path: root/src/mbgl/text/glyph_pbf.hpp
blob: bf8567dbec6817f21920548910e7dae29cb18b48 (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
48
49
50
51
52
53
54
55
#ifndef MBGL_TEXT_GLYPH_PBF
#define MBGL_TEXT_GLYPH_PBF

#include <mbgl/text/glyph.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/storage/request_holder.hpp>

#include <atomic>
#include <functional>
#include <string>

namespace mbgl {

class GlyphStore;
class FontStack;
class Request;

class GlyphPBF : private util::noncopyable {
public:
    class Observer {
    public:
        virtual ~Observer() = default;

        virtual void onGlyphPBFLoaded() = 0;
        virtual void onGlyphPBFLoadingFailed(std::exception_ptr error) = 0;
    };

    GlyphPBF(GlyphStore* store,
             const std::string& fontStack,
             const GlyphRange& glyphRange);
    virtual ~GlyphPBF();

    bool isParsed() const {
        return parsed;
    };

    void setObserver(Observer* observer);

private:
    void emitGlyphPBFLoaded();
    void emitGlyphPBFLoadingFailed(const std::string& message);

    void parse(GlyphStore* store, const std::string& fontStack, const std::string& url);

    std::shared_ptr<const std::string> data;
    std::atomic<bool> parsed;

    RequestHolder req;

    Observer* observer = nullptr;
};

}

#endif