diff options
Diffstat (limited to 'src/mbgl/style/style_impl.hpp')
-rw-r--r-- | src/mbgl/style/style_impl.hpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/mbgl/style/style_impl.hpp b/src/mbgl/style/style_impl.hpp index ca165e24f..25e278ee8 100644 --- a/src/mbgl/style/style_impl.hpp +++ b/src/mbgl/style/style_impl.hpp @@ -11,6 +11,7 @@ #include <mbgl/style/source.hpp> #include <mbgl/style/layer.hpp> #include <mbgl/style/collection.hpp> +#include <mbgl/annotation/annotation_manager.hpp> #include <mbgl/map/camera.hpp> @@ -22,6 +23,7 @@ #include <string> #include <vector> #include <unordered_map> +#include <set> namespace mbgl { @@ -31,14 +33,14 @@ class SpriteLoader; namespace style { -class Style::Impl : public SpriteLoaderObserver, +class StyleImpl : public SpriteLoaderObserver, public SourceObserver, public LayerObserver, public LightObserver, public util::noncopyable { public: - Impl(std::shared_ptr<FileSource>, float pixelRatio); - ~Impl() override; + StyleImpl(std::shared_ptr<FileSource>, float pixelRatio); + ~StyleImpl() override; void loadJSON(const std::string&); void loadURL(const std::string&); @@ -46,7 +48,8 @@ public: std::string getJSON() const; std::string getURL() const; - void setObserver(Observer*); + void addObserver(Observer* observer); + void removeObserver(Observer* observer); bool isLoaded() const; @@ -90,15 +93,34 @@ public: void dumpDebugLogs() const; - bool mutated = false; - bool loaded = false; - bool spriteLoaded = false; - private: void parse(const std::string&); + // SpriteLoaderObserver implementation. + void onSpriteLoaded(std::vector<std::unique_ptr<Image>>&&) override; + void onSpriteError(std::exception_ptr) override; + + // SourceObserver implementation. + void onSourceLoaded(Source&) override; + void onSourceChanged(Source&) override; + void onSourceError(Source&, std::exception_ptr) override; + void onSourceDescriptionChanged(Source&) override; + + // LayerObserver implementation. + void onLayerChanged(Layer&) override; + + // LightObserver implementation. + void onLightChanged(const Light&) override; + +public: + bool mutated = false; + bool loaded = false; + bool spriteLoaded = false; + AnnotationManager annotationManager; // ToDo: move annotations into an own style, stackable inside the View (=Map), so that + // they can change independently of the rest of the style and be combined with different styles arbitrarily. std::shared_ptr<FileSource> fileSource; +private: std::string url; std::string json; @@ -115,26 +137,7 @@ private: // Defaults std::string name; CameraOptions defaultCamera; - - // SpriteLoaderObserver implementation. - void onSpriteLoaded(std::vector<std::unique_ptr<Image>>&&) override; - void onSpriteError(std::exception_ptr) override; - - // SourceObserver implementation. - void onSourceLoaded(Source&) override; - void onSourceChanged(Source&) override; - void onSourceError(Source&, std::exception_ptr) override; - void onSourceDescriptionChanged(Source&) override; - - // LayerObserver implementation. - void onLayerChanged(Layer&) override; - - // LightObserver implementation. - void onLightChanged(const Light&) override; - - Observer nullObserver; - Observer* observer = &nullObserver; - + std::set<Observer*> observers; std::exception_ptr lastError; }; |