diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-13 18:14:12 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2018-07-20 11:56:30 -0700 |
commit | c8edbb0500cbf4baf1d5fdb0e63679539e166585 (patch) | |
tree | 750f3b72b9e3b1c91ddbc0541cfc64d7d80ffe71 /include/mbgl/style/data_driven_property_value.hpp | |
parent | 6d7072162b764c2432c010cd463a5a2c0093d606 (diff) | |
download | qtlocation-mapboxgl-c8edbb0500cbf4baf1d5fdb0e63679539e166585.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.hpp | 40 |
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)...); |