MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
color_ramp_property_value.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/util/variant.hpp>
6 
7 namespace mbgl {
8 namespace style {
9 
15 private:
16  std::shared_ptr<expression::Expression> value;
17 
18  friend bool operator==(const ColorRampPropertyValue& lhs, const ColorRampPropertyValue& rhs) {
19  return (lhs.isUndefined() && rhs.isUndefined()) || (lhs.value && rhs.value && *(lhs.value) == *(rhs.value));
20  }
21 
22  friend bool operator!=(const ColorRampPropertyValue& lhs, const ColorRampPropertyValue& rhs) {
23  return !(lhs == rhs);
24  }
25 
26 public:
27  ColorRampPropertyValue() : value(nullptr) {}
28  ColorRampPropertyValue(std::shared_ptr<expression::Expression> value_) : value(std::move(value_)) {}
29 
30  bool isUndefined() const { return value == nullptr; }
31 
32  // noop, needed for batch evaluation of paint property values to compile
33  template <typename Evaluator>
34  Color evaluate(const Evaluator&, TimePoint = {}) const { return {}; }
35 
36  Color evaluate(double rampEvaluationParameter) const {
37  const auto result = value->evaluate(expression::EvaluationContext({}, nullptr, {rampEvaluationParameter}));
38  return *expression::fromExpressionValue<Color>(*result);
39  }
40 
41  bool isDataDriven() const { return false; }
42  bool hasDataDrivenPropertyDifference(const ColorRampPropertyValue&) const { return false; }
43 
44  const expression::Expression& getExpression() const { return *value; }
45 };
46 
47 
48 } // namespace style
49 } // namespace mbgl
ColorRampPropertyValue(std::shared_ptr< expression::Expression > value_)
Color evaluate(const Evaluator &, TimePoint={}) const
bool hasDataDrivenPropertyDifference(const ColorRampPropertyValue &) const
const expression::Expression & getExpression() const
Color evaluate(double rampEvaluationParameter) const
friend bool operator==(const ColorRampPropertyValue &lhs, const ColorRampPropertyValue &rhs)
friend bool operator!=(const ColorRampPropertyValue &lhs, const ColorRampPropertyValue &rhs)
Definition: actor.hpp:15
Clock::time_point TimePoint
Definition: chrono.hpp:17
Definition: tile_id.hpp:256