diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-08-29 12:00:08 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-06 14:29:22 -0700 |
commit | fe2a26225f3746381b36ad8b6c6a3ce7727bf655 (patch) | |
tree | 62507ffd6a28654a377469d35e21719ff7a12fdc /include | |
parent | 3a48c60813b18c092c8d8d75c80a318bdd8859bb (diff) | |
download | qtlocation-mapboxgl-fe2a26225f3746381b36ad8b6c6a3ce7727bf655.tar.gz |
[core, ios, android, qt] Observe style layer mutations rather than requiring SDKs to use Map::update
This paves the way for updates to filter and layout properties to trigger a source reload, without each SDK having to participate in the implementation.
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/style/function.hpp | 12 | ||||
-rw-r--r-- | include/mbgl/style/property_value.hpp | 15 |
2 files changed, 27 insertions, 0 deletions
diff --git a/include/mbgl/style/function.hpp b/include/mbgl/style/function.hpp index 44ffa31079..97e880b280 100644 --- a/include/mbgl/style/function.hpp +++ b/include/mbgl/style/function.hpp @@ -21,7 +21,19 @@ public: private: float base = 1; std::vector<std::pair<float, T>> stops; + + template <class S> friend bool operator==(const Function<S>&, const Function<S>&); }; +template <class T> +bool operator==(const Function<T>& lhs, const Function<T>& rhs) { + return lhs.base == rhs.base && lhs.stops == rhs.stops; +} + +template <class T> +bool operator!=(const Function<T>& lhs, const Function<T>& rhs) { + return !(lhs == rhs); +} + } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp index d8f83a0fb3..d7e160fdca 100644 --- a/include/mbgl/style/property_value.hpp +++ b/include/mbgl/style/property_value.hpp @@ -8,12 +8,17 @@ namespace style { class Undefined {}; +inline bool operator==(const Undefined&, const Undefined&) { return true; } +inline bool operator!=(const Undefined&, const Undefined&) { return false; } + template <class T> class PropertyValue { private: using Value = variant<Undefined, T, Function<T>>; Value value; + template <class S> friend bool operator==(const PropertyValue<S>&, const PropertyValue<S>&); + public: PropertyValue() : value() {} PropertyValue( T constant) : value(constant) {} @@ -34,5 +39,15 @@ public: } }; +template <class T> +bool operator==(const PropertyValue<T>& lhs, const PropertyValue<T>& rhs) { + return lhs.value == rhs.value; +} + +template <class T> +bool operator!=(const PropertyValue<T>& lhs, const PropertyValue<T>& rhs) { + return !(lhs == rhs); +} + } // namespace style } // namespace mbgl |