#pragma once #include #include #include #include #include namespace mbgl { namespace style { template class DataDrivenPropertyValue { private: using Value = variant< Undefined, T, CameraFunction, SourceFunction, CompositeFunction>; Value value; friend bool operator==(const DataDrivenPropertyValue& lhs, const DataDrivenPropertyValue& rhs) { return lhs.value == rhs.value; } friend bool operator!=(const DataDrivenPropertyValue& lhs, const DataDrivenPropertyValue& rhs) { return !(lhs == rhs); } public: DataDrivenPropertyValue() = default; DataDrivenPropertyValue( T v) : value(std::move(v)) {} DataDrivenPropertyValue( CameraFunction v) : value(std::move(v)) {} DataDrivenPropertyValue( SourceFunction v) : value(std::move(v)) {} DataDrivenPropertyValue(CompositeFunction v) : value(std::move(v)) {} bool isUndefined() const { return value.template is(); } bool isDataDriven() const { return value.template is>() || value.template is>(); } bool isZoomConstant() const { return !value.template is>() && !value.template is>(); } template auto match(Ts&&... ts) const { return value.match(std::forward(ts)...); } template auto evaluate(const Evaluator& evaluator, TimePoint = {}) const { return Value::visit(value, evaluator); } bool hasDataDrivenPropertyDifference(const DataDrivenPropertyValue& other) const { return *this != other && (isDataDriven() || other.isDataDriven()); } }; } // namespace style } // namespace mbgl