#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class FileSource; class AsyncRequest; class SpriteLoader; namespace style { class Style::Impl : public SpriteLoaderObserver, public SourceObserver, public LayerObserver, public LightObserver, public util::noncopyable { public: Impl(std::shared_ptr, float pixelRatio); ~Impl() override; void loadJSON(const std::string&); void loadURL(const std::string&); std::string getJSON() const; std::string getURL() const; void setObserver(Observer*); bool isLoaded() const; std::exception_ptr getLastError() const { return lastError; } std::vector< Source*> getSources(); std::vector getSources() const; Source* getSource(const std::string& id) const; void addSource(std::unique_ptr); std::unique_ptr removeSource(const std::string& sourceID); std::vector< Layer*> getLayers(); std::vector getLayers() const; Layer* getLayer(const std::string& id) const; Layer* addLayer(std::unique_ptr, const optional& beforeLayerID = {}); std::unique_ptr removeLayer(const std::string& layerID); std::string getName() const; CameraOptions getDefaultCamera() const; TransitionOptions getTransitionOptions() const; void setTransitionOptions(const TransitionOptions&); void setLight(std::unique_ptr); Light* getLight() const; optional> getImage(const std::string&) const; void addImage(std::unique_ptr); void removeImage(const std::string&); const std::string& getGlyphURL() const; using ImageImpls = std::vector>; Immutable getImageImpls() const; Immutable>> getSourceImpls() const; Immutable>> getLayerImpls() const; void dumpDebugLogs() const; bool mutated = false; bool loaded = false; bool spriteLoaded = false; private: void parse(const std::string&); std::shared_ptr fileSource; std::string url; std::string json; std::unique_ptr styleRequest; std::unique_ptr spriteLoader; std::string glyphURL; Immutable images = makeMutable(); CollectionWithPersistentOrder sources; Collection layers; TransitionOptions transitionOptions; std::unique_ptr light; // Defaults std::string name; CameraOptions defaultCamera; // SpriteLoaderObserver implementation. void onSpriteLoaded(std::vector>) 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::exception_ptr lastError; }; } // namespace style } // namespace mbgl