[core] Add style::Source::setVolatile()/isVolatile() API
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user