summaryrefslogtreecommitdiff
path: root/src/mbgl/style/property_evaluator.hpp
blob: 81d2c9334216236ccb044e33ec92758f3b711b28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef MBGL_PROPERTY_EVALUATOR
#define MBGL_PROPERTY_EVALUATOR

#include <mbgl/style/zoom_history.hpp>
#include <mbgl/style/function.hpp>
#include <mbgl/style/style_calculation_parameters.hpp>

namespace mbgl {

struct ZoomHistory;

template <typename T>
class PropertyEvaluator {
public:
    typedef T result_type;

    PropertyEvaluator(const StyleCalculationParameters& parameters_)
        : parameters(parameters_) {}

    template <typename P, typename std::enable_if<std::is_convertible<P, T>::value, int>::type = 0>
    T operator()(const P &value) const {
        return value;
    }

    T operator()(const Function<T>& value) const {
        return value.evaluate(parameters);
    }

    template <typename P, typename std::enable_if<!std::is_convertible<P, T>::value, int>::type = 0>
    T operator()(const P &) const {
        return T();
    }

private:
    StyleCalculationParameters parameters;
};

}

#endif