1 | #pragma once |
---|---|
2 | |
3 | #include <mbgl/style/expression/expression.hpp> |
4 | #include <mbgl/style/expression/parsing_context.hpp> |
5 | #include <mbgl/style/conversion.hpp> |
6 | |
7 | #include <mbgl/util/range.hpp> |
8 | |
9 | #include <memory> |
10 | #include <map> |
11 | |
12 | namespace mbgl { |
13 | namespace style { |
14 | namespace expression { |
15 | |
16 | class Step : public Expression { |
17 | public: |
18 | Step(const type::Type& type_, |
19 | std::unique_ptr<Expression> input_, |
20 | std::map<double, std::unique_ptr<Expression>> stops_); |
21 | |
22 | EvaluationResult evaluate(const EvaluationContext& params) const override; |
23 | void eachChild(const std::function<void(const Expression&)>& visit) const override; |
24 | void eachStop(const std::function<void(double, const Expression&)>& visit) const; |
25 | |
26 | const std::unique_ptr<Expression>& getInput() const { return input; } |
27 | Range<float> getCoveringStops(const double lower, const double upper) const; |
28 | |
29 | bool operator==(const Expression& e) const override; |
30 | |
31 | std::vector<optional<Value>> possibleOutputs() const override; |
32 | |
33 | static ParseResult parse(const mbgl::style::conversion::Convertible& value, ParsingContext& ctx); |
34 | |
35 | mbgl::Value serialize() const override; |
36 | std::string getOperator() const override { return "step"; } |
37 | |
38 | private: |
39 | const std::unique_ptr<Expression> input; |
40 | const std::map<double, std::unique_ptr<Expression>> stops; |
41 | }; |
42 | |
43 | } // namespace expression |
44 | } // namespace style |
45 | } // namespace mbgl |
46 |