[core] Extract Function::evaluation to a separate class (#4811)
This allows the Function<Faded<T>> partial specialization to be eliminated, giving all property functions a consistent storage type.
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
#ifndef MBGL_STYLE_FUNCTION
|
||||
#define MBGL_STYLE_FUNCTION
|
||||
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class StyleCalculationParameters;
|
||||
|
||||
template <typename T>
|
||||
class Function {
|
||||
public:
|
||||
@@ -24,8 +18,6 @@ public:
|
||||
explicit Function(const Stops& stops_, float base_)
|
||||
: base(base_), stops(stops_) {}
|
||||
|
||||
T evaluate(const StyleCalculationParameters&) const;
|
||||
|
||||
float getBase() const { return base; }
|
||||
const std::vector<std::pair<float, T>>& getStops() const { return stops; }
|
||||
|
||||
@@ -34,25 +26,6 @@ private:
|
||||
std::vector<std::pair<float, T>> stops;
|
||||
};
|
||||
|
||||
// Partial specialization for cross-faded properties (*-pattern, line-dasharray).
|
||||
template <typename T>
|
||||
class Function<Faded<T>> {
|
||||
public:
|
||||
using Stop = std::pair<float, T>;
|
||||
using Stops = std::vector<Stop>;
|
||||
|
||||
explicit Function(const T& constant)
|
||||
: stops({{ 0, constant }}) {}
|
||||
|
||||
explicit Function(const Stops& stops_)
|
||||
: stops(stops_) {}
|
||||
|
||||
Faded<T> evaluate(const StyleCalculationParameters&) const;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<float, T>> stops;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user