[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.
This commit is contained in:
John Firebaugh
2016-08-29 12:00:08 -07:00
parent 3a48c60813
commit fe2a26225f
33 changed files with 426 additions and 148 deletions

View File

@@ -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

View File

@@ -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