summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-15 17:24:04 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-22 19:21:56 +0300
commiteac6bdff16af09f8b3fc2f6d4a5bb781862b0f18 (patch)
tree80c8d1f31199b3e1be8e9fbc51eb31ca8398fbe6
parent7af1a175a3da717c7171b234d1968e567f5673eb (diff)
downloadqtlocation-mapboxgl-eac6bdff16af09f8b3fc2f6d4a5bb781862b0f18.tar.gz
[core] Add style::Source::setVolatile()/isVolatile() API
-rw-r--r--include/mbgl/style/source.hpp7
-rw-r--r--src/mbgl/style/source.cpp12
-rw-r--r--src/mbgl/style/source_impl.hpp4
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;