TTTT Analysis  0.1
api.hpp
1 #ifndef API_HPP
2 #define API_HPP
3 #include <string>
4 #include <vector>
5 #include "filval/value.hpp"
6 namespace fv{
7 
8  template<typename T>
9  Value<T>* lookup(const std::string& name){
10  GenValue* gv = GenValue::get_value(name);
11  Value<T>* tv = dynamic_cast<Value<T>*>(gv);
12  if(tv == nullptr){
13  CRITICAL("Value: "+gv->get_name() + "has improper type.",-1);
14  }
15  return tv;
16  }
17 
18  Filter* lookup_filter(const std::string& name){
19  Filter* f = dynamic_cast<Filter*>(GenValue::get_value(name));
20  if(f == nullptr){
21  CRITICAL("Filter: "+f->get_name() + "has improper type.",-1);
22  }
23  return f;
24  }
25 
26  template <typename... ArgTypes>
27  Zip<ArgTypes...>* zip(Value<std::vector<ArgTypes>>*... args, const std::string& alias=""){
28  return new Zip<ArgTypes...>(args..., alias);
29  }
30 
31  template <typename Ret, typename... ArgTypes>
32  Map<Ret(ArgTypes...)>* map(Function<Ret(ArgTypes...)>& fn,
33  Zip<ArgTypes...>* arg, const std::string& alias=""){
34  return new Map<Ret(ArgTypes...)>(fn, arg, alias);
35  }
36 
37 
38  template <typename... ArgTypes>
39  Tuple<ArgTypes...>* tuple(Value<ArgTypes>*... args, const std::string& alias=""){
40  return new Tuple<ArgTypes...>(args..., alias);
41  }
42 
43  template <typename Ret, typename... ArgTypes>
44  Apply<Ret(ArgTypes...)>* apply(Function<Ret(ArgTypes...)>& fn,
45  Tuple<ArgTypes...>* arg, const std::string& alias=""){
46  return new Apply<Ret(ArgTypes...)>(fn, arg, alias);
47  }
48 
49 
50 
51  template <typename T1, typename T2>
52  Pair<T1, T2>* pair(Value<T1>* val1, Value<T2>* val2, const std::string& alias=""){
53  return new Pair<T1,T2>(val1, val2, alias);
54  }
55 
56  template <typename T1, typename T2>
57  Pair<T1, T2>* pair(const std::string& name1, const std::string& name2, const std::string& alias=""){
58  return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
59  }
60 
61 
62  template <typename T>
63  Max<T>* max(Value<std::vector<T>>* v, const std::string alias){
64  return new Max<T>(v, alias);
65  }
66 
67  template <typename T>
68  Max<T>* max(const std::string& v_name, const std::string alias){
69  return max(lookup<std::vector<T>>(v_name), alias);
70  }
71 
72  template <typename T>
73  Min<T>* min(Value<std::vector<T>>* v, const std::string alias){
74  return new Min<T>(v, alias);
75  }
76 
77  template <typename T>
78  Min<T>* min(const std::string& v_name, const std::string alias){
79  return min(lookup<std::vector<T>>(v_name), alias);
80  }
81 
82  template <typename T>
83  Range<T>* range(Value<std::vector<T>>* v, const std::string alias){
84  return new Range<T>(v, alias);
85  }
86 
87  template <typename T>
88  Range<T>* range(const std::string& v_name, const std::string alias){
89  return range(lookup<std::vector<T>>(v_name), alias);
90  }
91 
92  template <typename T>
93  Mean<T>* mean(Value<std::vector<T>>* v, const std::string alias){
94  return new Mean<T>(v, alias);
95  }
96 
97  template <typename T>
98  Mean<T>* mean(const std::string& v_name, const std::string alias){
99  return mean(lookup<std::vector<T>>(v_name), alias);
100  }
101 
102  template <typename T>
103  Count<T>* count(Function<bool(T)>& selector, Value<std::vector<T>>* v, const std::string alias){
104  return new Count<T>(selector, v, alias);
105  }
106 
107  template <typename T>
108  Count<T>* count(Function<bool(T)>& selector, const std::string& v_name, const std::string alias){
109  return count<T>(selector, lookup<std::vector<T>>(v_name), alias);
110  }
111 
112  Filter* filter(const std::string& name, std::function<bool()> filter_function, const std::string& impl=""){
113  return new Filter(name, filter_function, impl);
114  }
115 }
116 #endif // API_HPP
Find and return the maximum value of a vector.
Definition: value.hpp:726
Zips a series of vectors together.
Definition: value.hpp:533
Calculate the range of the values in a vector.
Definition: value.hpp:767
Takes a series of Value objects and bundles them together into a std::tuple object.
Definition: value.hpp:631
Returns the count of elements in the input vector passing a test function.
Definition: value.hpp:678
Find and return the minimum value of a vector.
Definition: value.hpp:739
Creates a std::pair type from a two other Value objects.
Definition: value.hpp:454
The namespace containing all filval classes and functions.
Definition: api.hpp:6
Calculate the mean value of a vector.
Definition: value.hpp:752
A generic value.
Definition: value.hpp:339