#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { class Scheduler; class FileSource; class AsyncRequest; class SpriteLoader; namespace style { class Style::Impl : public SpriteLoaderObserver, public SourceObserver, public LayerObserver, public LightObserver, public util::noncopyable { public: Impl(Scheduler&, FileSource&, 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, optional beforeLayerID = {}); std::unique_ptr removeLayer(const std::string& layerID); std::string getName() const; LatLng getDefaultLatLng() const; double getDefaultZoom() const; double getDefaultBearing() const; double getDefaultPitch() const; TransitionOptions getTransitionOptions() const; void setTransitionOptions(const TransitionOptions&); void setLight(std::unique_ptr); Light* getLight() const; const style::Image* getImage(const std::string&) const; void addImage(std::unique_ptr); void removeImage(const std::string&); const std::string& getGlyphURL() const; 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&); Scheduler& scheduler; FileSource& fileSource; std::string url; std::string json; std::unique_ptr styleRequest; std::unique_ptr spriteLoader; std::string glyphURL; Collection images; Collection sources; Collection layers; TransitionOptions transitionOptions; std::unique_ptr light; // Defaults std::string name; LatLng defaultLatLng; double defaultZoom = 0; double defaultBearing = 0; double defaultPitch = 0; // 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