summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-06-28 07:47:28 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-06-28 10:00:40 -0700
commitb2f6acca6161e1547bd99e0fca1ce51ea7e632e9 (patch)
treed37a999213666ba57126a7d6dcbd2c68dad314c4
parentbc771ee02e813e0f05663f108d34d3fd057dbd66 (diff)
downloadqtlocation-mapboxgl-b2f6acca6161e1547bd99e0fca1ce51ea7e632e9.tar.gz
[core] Move non-polymorphic Interpolate methods to base
-rw-r--r--include/mbgl/style/expression/interpolate.hpp33
-rw-r--r--src/mbgl/style/expression/interpolate.cpp3
2 files changed, 17 insertions, 19 deletions
diff --git a/include/mbgl/style/expression/interpolate.hpp b/include/mbgl/style/expression/interpolate.hpp
index 1f73fc14b4..1a98189e29 100644
--- a/include/mbgl/style/expression/interpolate.hpp
+++ b/include/mbgl/style/expression/interpolate.hpp
@@ -55,7 +55,23 @@ public:
);
}
+ bool operator==(const Expression& e) const override {
+ if (auto rhs = dynamic_cast<const InterpolateBase*>(&e)) {
+ if (interpolator != rhs->interpolator ||
+ *input != *(rhs->input) ||
+ stops.size() != rhs->stops.size())
+ {
+ return false;
+ }
+
+ return Expression::childrenEqual(stops, rhs->stops);
+ }
+ return false;
+ }
+
std::vector<optional<Value>> possibleOutputs() const override;
+ mbgl::Value serialize() const override;
+ std::string getOperator() const override { return "interpolate"; }
protected:
const Interpolator interpolator;
@@ -130,23 +146,6 @@ public:
return util::interpolate(lower->get<T>(), upper->get<T>(), t);
}
}
-
- bool operator==(const Expression& e) const override {
- if (auto rhs = dynamic_cast<const Interpolate*>(&e)) {
- if (interpolator != rhs->interpolator ||
- *input != *(rhs->input) ||
- stops.size() != rhs->stops.size())
- {
- return false;
- }
-
- return Expression::childrenEqual(stops, rhs->stops);
- }
- return false;
- }
-
- mbgl::Value serialize() const override;
- std::string getOperator() const override { return "interpolate"; }
};
} // namespace expression
diff --git a/src/mbgl/style/expression/interpolate.cpp b/src/mbgl/style/expression/interpolate.cpp
index 051f2cf9f5..776fe1f177 100644
--- a/src/mbgl/style/expression/interpolate.cpp
+++ b/src/mbgl/style/expression/interpolate.cpp
@@ -189,8 +189,7 @@ std::vector<optional<Value>> InterpolateBase::possibleOutputs() const {
return result;
}
-template <typename T>
-mbgl::Value Interpolate<T>::serialize() const {
+mbgl::Value InterpolateBase::serialize() const {
std::vector<mbgl::Value> serialized;
serialized.emplace_back(getOperator());