1#pragma once
2
3#include <mbgl/util/variant.hpp>
4#include <mbgl/style/undefined.hpp>
5#include <mbgl/style/property_expression.hpp>
6
7namespace mbgl {
8namespace style {
9
10template <class T>
11class PropertyValue {
12private:
13 using Value = variant<Undefined, T, PropertyExpression<T>>;
14 Value value;
15
16 friend bool operator==(const PropertyValue& lhs, const PropertyValue& rhs) {
17 return lhs.value == rhs.value;
18 }
19
20 friend bool operator!=(const PropertyValue& lhs, const PropertyValue& rhs) {
21 return !(lhs == rhs);
22 }
23
24public:
25 PropertyValue()
26 : value() {}
27
28 PropertyValue(T constant)
29 : value(constant) {}
30
31 PropertyValue(PropertyExpression<T> expression)
32 : value(expression) {
33 assert(expression.isFeatureConstant());
34 }
35
36 bool isUndefined() const { return value.which() == 0; }
37 bool isConstant() const { return value.which() == 1; }
38 bool isExpression() const { return value.which() == 2; }
39 bool isDataDriven() const { return false; }
40
41 const T & asConstant() const { return value.template get< T >(); }
42 const PropertyExpression<T>& asExpression() const { return value.template get<PropertyExpression<T>>(); }
43
44 template <typename Evaluator>
45 auto evaluate(const Evaluator& evaluator, TimePoint = {}) const {
46 return Value::visit(value, evaluator);
47 }
48
49 bool hasDataDrivenPropertyDifference(const PropertyValue<T>&) const {
50 return false;
51 }
52};
53
54} // namespace style
55} // namespace mbgl
56

source code of qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/style/property_value.hpp