Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <mln/style/source.hpp>
|
|
#include <mln/util/image.hpp>
|
|
|
|
#include <optional>
|
|
|
|
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<LatLng, 4>);
|
|
~ImageSource() override;
|
|
|
|
std::optional<std::string> getURL() const;
|
|
void setURL(const std::string& url);
|
|
|
|
void setImage(PremultipliedImage&&);
|
|
|
|
void setCoordinates(const std::array<LatLng, 4>&);
|
|
std::array<LatLng, 4> getCoordinates() const;
|
|
|
|
class Impl;
|
|
const Impl& impl() const;
|
|
|
|
void loadDescription(FileSource&) final;
|
|
|
|
bool supportsLayerType(const mln::style::LayerTypeInfo*) const override;
|
|
|
|
mapbox::base::WeakPtr<Source> makeWeakPtr() override { return weakFactory.makeWeakPtr(); }
|
|
|
|
protected:
|
|
Mutable<Source::Impl> createMutable() const noexcept final;
|
|
|
|
private:
|
|
std::optional<std::string> url;
|
|
std::unique_ptr<AsyncRequest> req;
|
|
mapbox::base::WeakPtrFactory<Source> weakFactory{this};
|
|
// Do not add members here, see `WeakPtrFactory`
|
|
};
|
|
|
|
template <>
|
|
inline bool Source::is<ImageSource>() const {
|
|
return getType() == SourceType::Image;
|
|
}
|
|
|
|
} // namespace style
|
|
} // namespace mln
|