[core] Simplify Function

This commit is contained in:
John Firebaugh
2015-11-03 13:51:27 -08:00
parent 5ef5d08867
commit 7de4ce5bcb
9 changed files with 81 additions and 103 deletions

View File

@@ -0,0 +1,31 @@
#ifndef MBGL_STYLE_FUNCTION
#define MBGL_STYLE_FUNCTION
#include <vector>
#include <utility>
namespace mbgl {
template <typename T>
class Function {
public:
using Stop = std::pair<float, T>;
using Stops = std::vector<Stop>;
// TODO: make explicit
/* explicit */ Function(const T& constant)
: stops({{ 0, constant }}) {}
explicit Function(const Stops& stops_, float base_)
: base(base_), stops(stops_) {}
T evaluate(float z) const;
private:
const float base = 1;
const std::vector<std::pair<float, T>> stops;
};
}
#endif