diff options
Diffstat (limited to 'src/mbgl/text/glyph_pbf.hpp')
-rw-r--r-- | src/mbgl/text/glyph_pbf.hpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp index cc083e7f10..2aa2134d16 100644 --- a/src/mbgl/text/glyph_pbf.hpp +++ b/src/mbgl/text/glyph_pbf.hpp @@ -2,48 +2,53 @@ #define MBGL_TEXT_GLYPH_PBF #include <mbgl/text/glyph.hpp> +#include <mbgl/util/noncopyable.hpp> -#include <functional> #include <atomic> +#include <functional> #include <string> namespace mbgl { +class GlyphStore; class FontStack; class Request; -class GlyphPBF { +class GlyphPBF : private util::noncopyable { public: - using GlyphLoadedCallback = std::function<void(GlyphPBF*)>; - using GlyphLoadingFailedCallback = std::function<void(const std::string&)>; + class Observer { + public: + virtual ~Observer() = default; + + virtual void onGlyphPBFLoaded() = 0; + virtual void onGlyphPBFLoadingFailed(std::exception_ptr error) = 0; + }; - GlyphPBF(const std::string &glyphURL, - const std::string &fontStack, - GlyphRange glyphRange, - const GlyphLoadedCallback& successCallback, - const GlyphLoadingFailedCallback& failureCallback); - ~GlyphPBF(); + GlyphPBF(GlyphStore* store, + const std::string& fontStack, + const GlyphRange& glyphRange); + virtual ~GlyphPBF(); - void parse(FontStack &stack); - bool isParsed() const; + bool isParsed() const { + return parsed; + }; - std::string getURL() const { - return url; - } + void setObserver(Observer* observer); private: - GlyphPBF(const GlyphPBF &) = delete; - GlyphPBF(GlyphPBF &&) = delete; - GlyphPBF &operator=(const GlyphPBF &) = delete; - GlyphPBF &operator=(GlyphPBF &&) = delete; + void emitGlyphPBFLoaded(); + void emitGlyphPBFLoadingFailed(const std::string& message); + + void parse(GlyphStore* store, const std::string& fontStack, const std::string& url); std::string data; - std::string url; std::atomic<bool> parsed; Request* req = nullptr; + + Observer* observer = nullptr; }; -} // end namespace mbgl +} #endif |