summaryrefslogtreecommitdiff
path: root/include/mbgl/style/data_driven_property_value.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-13 18:14:12 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-07-19 12:19:52 -0700
commit2e5530519e6a56dde019618262ea6ce5c10c72f5 (patch)
treed28472a700ccb99249095a1b94153d33c500d801 /include/mbgl/style/data_driven_property_value.hpp
parent5d7e3e24e565afffe2bc9db5029286b167f039ed (diff)
downloadqtlocation-mapboxgl-2e5530519e6a56dde019618262ea6ce5c10c72f5.tar.gz
[core] Replace {Source,Camera,Composite}Function with PropertyExpression
Diffstat (limited to 'include/mbgl/style/data_driven_property_value.hpp')
-rw-r--r--include/mbgl/style/data_driven_property_value.hpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/include/mbgl/style/data_driven_property_value.hpp b/include/mbgl/style/data_driven_property_value.hpp
index 0a1fce29c7..a95eaa4ea8 100644
--- a/include/mbgl/style/data_driven_property_value.hpp
+++ b/include/mbgl/style/data_driven_property_value.hpp
@@ -2,9 +2,7 @@
#include <mbgl/util/variant.hpp>
#include <mbgl/style/undefined.hpp>
-#include <mbgl/style/function/camera_function.hpp>
-#include <mbgl/style/function/source_function.hpp>
-#include <mbgl/style/function/composite_function.hpp>
+#include <mbgl/style/property_expression.hpp>
namespace mbgl {
namespace style {
@@ -15,9 +13,7 @@ private:
using Value = variant<
Undefined,
T,
- CameraFunction<T>,
- SourceFunction<T>,
- CompositeFunction<T>>;
+ PropertyExpression<T>>;
Value value;
@@ -33,32 +29,40 @@ private:
public:
DataDrivenPropertyValue() = default;
- DataDrivenPropertyValue( T v) : value(std::move(v)) {}
- DataDrivenPropertyValue( CameraFunction<T> v) : value(std::move(v)) {}
- DataDrivenPropertyValue( SourceFunction<T> v) : value(std::move(v)) {}
- DataDrivenPropertyValue(CompositeFunction<T> v) : value(std::move(v)) {}
+ DataDrivenPropertyValue( T v) : value(std::move(v)) {}
+ DataDrivenPropertyValue(PropertyExpression<T> v) : value(std::move(v)) {}
bool isUndefined() const {
return value.template is<Undefined>();
}
bool isDataDriven() const {
- return value.template is<SourceFunction<T>>() || value.template is<CompositeFunction<T>>();
+ return value.match(
+ [] (const Undefined&) { return false; },
+ [] (const T&) { return false; },
+ [] (const PropertyExpression<T>& fn) { return !fn.isFeatureConstant(); }
+ );
}
-
+
bool isZoomConstant() const {
- return !value.template is<CameraFunction<T>>() && !value.template is<CompositeFunction<T>>();
+ return value.match(
+ [] (const Undefined&) { return true; },
+ [] (const T&) { return true; },
+ [] (const PropertyExpression<T>& fn) { return fn.isZoomConstant(); }
+ );
}
bool isExpression() const {
return value.match(
- [] (const Undefined&) { return false; },
- [] (const T&) { return false; },
- [] (const CameraFunction<T>& fn) { return fn.isExpression; },
- [] (const SourceFunction<T>& fn) { return fn.isExpression; },
- [] (const CompositeFunction<T>& fn) { return fn.isExpression; });
+ [] (const Undefined&) { return false; },
+ [] (const T&) { return false; },
+ [] (const PropertyExpression<T>& fn) { return fn.isExpression; }
+ );
}
+ const T & asConstant() const { return value.template get< T >(); }
+ const PropertyExpression<T>& asExpression() const { return value.template get<PropertyExpression<T>>(); }
+
template <class... Ts>
auto match(Ts&&... ts) const {
return value.match(std::forward<Ts>(ts)...);