summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/property_evaluator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/renderer/property_evaluator.hpp')
-rw-r--r--src/mbgl/renderer/property_evaluator.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mbgl/renderer/property_evaluator.hpp b/src/mbgl/renderer/property_evaluator.hpp
new file mode 100644
index 0000000000..3ac0573920
--- /dev/null
+++ b/src/mbgl/renderer/property_evaluator.hpp
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <mbgl/style/property_value.hpp>
+#include <mbgl/renderer/property_evaluation_parameters.hpp>
+
+namespace mbgl {
+
+template <typename T>
+class PropertyEvaluator {
+public:
+ using ResultType = T;
+
+ PropertyEvaluator(const PropertyEvaluationParameters& parameters_, T defaultValue_)
+ : parameters(parameters_),
+ defaultValue(std::move(defaultValue_)) {}
+
+ T operator()(const style::Undefined&) const { return defaultValue; }
+ T operator()(const T& constant) const { return constant; }
+ T operator()(const style::CameraFunction<T>& fn) const { return fn.evaluate(parameters.z); }
+
+private:
+ const PropertyEvaluationParameters& parameters;
+ T defaultValue;
+};
+
+} // namespace mbgl