diff options
-rw-r--r-- | include/mbgl/style/source.hpp | 7 | ||||
-rw-r--r-- | src/mbgl/style/source.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/style/source_impl.hpp | 4 |
3 files changed, 20 insertions, 3 deletions
diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp index a1650ad06a..e6208294ca 100644 --- a/include/mbgl/style/source.hpp +++ b/include/mbgl/style/source.hpp @@ -66,12 +66,14 @@ public: std::string getID() const; optional<std::string> getAttribution() const; + // The data from the volatile sources are not stored in a persistent storage. + bool isVolatile() const noexcept; + void setVolatile(bool) noexcept; + // Private implementation class Impl; Immutable<Impl> baseImpl; - Source(Immutable<Impl>); - void setObserver(SourceObserver*); SourceObserver* observer = nullptr; @@ -114,6 +116,7 @@ public: virtual mapbox::base::WeakPtr<Source> makeWeakPtr() = 0; protected: + explicit Source(Immutable<Impl>); virtual Mutable<Impl> createMutable() const noexcept = 0; }; diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp index 42ad367d66..b2a9473fe6 100644 --- a/src/mbgl/style/source.cpp +++ b/src/mbgl/style/source.cpp @@ -27,6 +27,18 @@ optional<std::string> Source::getAttribution() const { return baseImpl->getAttribution(); } +bool Source::isVolatile() const noexcept { + return baseImpl->isVolatile(); +} + +void Source::setVolatile(bool set) noexcept { + if (isVolatile() == set) return; + auto newImpl = createMutable(); + newImpl->setVolatile(set); + baseImpl = std::move(newImpl); + observer->onSourceChanged(*this); +} + void Source::setObserver(SourceObserver* observer_) { observer = observer_ ? observer_ : &nullObserver; } diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp index b16b763766..87a30dcf95 100644 --- a/src/mbgl/style/source_impl.hpp +++ b/src/mbgl/style/source_impl.hpp @@ -1,7 +1,6 @@ #pragma once #include <mbgl/style/source.hpp> -#include <mbgl/util/noncopyable.hpp> #include <string> @@ -27,6 +26,8 @@ public: void setMaxOverscaleFactorForParentTiles(optional<uint8_t> overscaleFactor) noexcept; optional<uint8_t> getMaxOverscaleFactorForParentTiles() const noexcept; + bool isVolatile() const { return volatileFlag; } + void setVolatile(bool set) { volatileFlag = set; } const SourceType type; const std::string id; @@ -34,6 +35,7 @@ protected: optional<uint8_t> prefetchZoomDelta; optional<uint8_t> maxOverscaleFactor; Duration minimumTileUpdateInterval{Duration::zero()}; + bool volatileFlag = false; Impl(SourceType, std::string); Impl(const Impl&) = default; |