diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-06-27 16:19:43 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-06-27 16:19:43 +0200 |
commit | ad4497c90994e75dd918e09a201a87ef85d6504c (patch) | |
tree | 43a4991928e918c380e8300443ab0f4a497dae5f /include/llmr/style/function_properties.hpp | |
parent | 38d9cd0d4f044090d417be35bf1771380472537c (diff) | |
download | qtlocation-mapboxgl-ad4497c90994e75dd918e09a201a87ef85d6504c.tar.gz |
reorganize properties
Diffstat (limited to 'include/llmr/style/function_properties.hpp')
-rw-r--r-- | include/llmr/style/function_properties.hpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/llmr/style/function_properties.hpp b/include/llmr/style/function_properties.hpp new file mode 100644 index 0000000000..970d617d02 --- /dev/null +++ b/include/llmr/style/function_properties.hpp @@ -0,0 +1,45 @@ +#ifndef LLMR_STYLE_FUNCTION_PROPERTIES +#define LLMR_STYLE_FUNCTION_PROPERTIES + +#include <vector> + +namespace llmr { + +namespace functions { + +float null(float z, const std::vector<float>&); +float constant(float z, const std::vector<float>& values); +float min(float z, const std::vector<float>& values); +float max(float z, const std::vector<float>& values); +float stops(float z, const std::vector<float>& values); +float linear(float z, const std::vector<float>& values); +float exponential(float z, const std::vector<float>& values); + +} + +struct FunctionProperty { + typedef float (*fn)(float z, const std::vector<float>& values); + + fn function; + std::vector<float> values; + + inline FunctionProperty() : function(&functions::null) {} + + inline FunctionProperty(const FunctionProperty &property) + : function(property.function), values(property.values) {} + inline FunctionProperty(FunctionProperty &&property) + : function(property.function), values(std::move(property.values)) {} + + + inline void operator=(const FunctionProperty &rhs) { + function = rhs.function; + values = rhs.values; + } + + inline FunctionProperty(float value) : function(&functions::constant), values(1, value) {} + template <typename T> inline T evaluate(float z) const { return function(z, values); } +}; + +} + +#endif |