diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-22 15:10:24 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-23 12:50:42 -0800 |
commit | 16de579d7cfc2960793cbcb5e95741f22ab73768 (patch) | |
tree | b4c3b7651f605e3d3dd61b469f61036bd2c4dcc3 /src/mbgl/text/glyph_pbf.hpp | |
parent | 7bd4745cf10c504a4899a37016e87bce45e51472 (diff) | |
download | qtlocation-mapboxgl-16de579d7cfc2960793cbcb5e95741f22ab73768.tar.gz |
[core] Rationalize error handling for resource loading
* Standardize on std::exception_ptr as the error representation
(fixes #2854).
* Don't format textual strings at the error source; pass on the
constituent data via observer method parameters instead.
* Use the null object pattern to simplify observer notification code.
* Further refactoring for ResourceLoading tests.
Diffstat (limited to 'src/mbgl/text/glyph_pbf.hpp')
-rw-r--r-- | src/mbgl/text/glyph_pbf.hpp | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/src/mbgl/text/glyph_pbf.hpp b/src/mbgl/text/glyph_pbf.hpp index d595298516..e0f65e7789 100644 --- a/src/mbgl/text/glyph_pbf.hpp +++ b/src/mbgl/text/glyph_pbf.hpp @@ -2,6 +2,7 @@ #define MBGL_TEXT_GLYPH_PBF #include <mbgl/text/glyph.hpp> +#include <mbgl/text/glyph_store.hpp> #include <mbgl/util/noncopyable.hpp> #include <atomic> @@ -11,43 +12,30 @@ namespace mbgl { -class GlyphStore; class FontStack; class FileRequest; 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(); + const GlyphRange&, + GlyphStore::Observer*); + ~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); + void parse(GlyphStore*, const std::string& fontStack, const GlyphRange&); std::shared_ptr<const std::string> data; std::atomic<bool> parsed; std::unique_ptr<FileRequest> req; - Observer* observer = nullptr; + GlyphStore::Observer* observer = nullptr; }; } // namespace mbgl |