#pragma once #include #include #include namespace mln { class LatLng; class AsyncRequest; namespace style { // NOTE: Any derived class must invalidate `weakFactory` in the destructor class ImageSource final : public Source { public: ImageSource(std::string id, std::array); ~ImageSource() override; std::optional getURL() const; void setURL(const std::string& url); void setImage(PremultipliedImage&&); void setCoordinates(const std::array&); std::array getCoordinates() const; class Impl; const Impl& impl() const; void loadDescription(FileSource&) final; bool supportsLayerType(const mln::style::LayerTypeInfo*) const override; mapbox::base::WeakPtr makeWeakPtr() override { return weakFactory.makeWeakPtr(); } protected: Mutable createMutable() const noexcept final; private: std::optional url; std::unique_ptr req; mapbox::base::WeakPtrFactory weakFactory{this}; // Do not add members here, see `WeakPtrFactory` }; template <> inline bool Source::is() const { return getType() == SourceType::Image; } } // namespace style } // namespace mln