TTTT Analysis  0.1
api.hpp
Go to the documentation of this file.
1 
33 #ifndef API_HPP
34 #define API_HPP
35 #include <string>
36 #include <vector>
37 #include "filval/value.hpp"
38 namespace fv{
39 
40  template<typename T>
41  Value<T>* lookup(const std::string& name){
42  GenValue* gv = GenValue::get_value(name);
43  Value<T>* tv = dynamic_cast<Value<T>*>(gv);
44  if(tv == nullptr){
45  CRITICAL("Value: \""+gv->get_name() + "\" has improper type.",-1);
46  }
47  return tv;
48  }
49 
50  ObsFilter* lookup_obs_filter(const std::string& name){
51  ObsFilter* f = dynamic_cast<ObsFilter*>(GenValue::get_value(name));
52  if(f == nullptr){
53  CRITICAL("ObsFilter: "+f->get_name() + "has improper type.",-1);
54  }
55  return f;
56  }
57 
58  template <typename... ArgTypes>
59  Value<std::vector<std::tuple<ArgTypes...>>>*
60  zip(Value<std::vector<ArgTypes>>*... args, const std::string& alias=""){
61  return new Zip<ArgTypes...>(args..., alias);
62  }
63 
64  template <typename Ret, typename... ArgTypes>
66  map(Function<Ret(ArgTypes...)>& fn,
67  Value<std::vector<std::tuple<ArgTypes...>>>* arg, const std::string& alias=""){
68  return new Map<Ret(ArgTypes...)>(fn, arg, alias);
69  }
70 
71  template <typename... ArgTypes>
72  Value<std::tuple<ArgTypes...>>*
73  tuple(Value<ArgTypes>*... args){
74  return new Tuple<ArgTypes...>(args..., "");
75  }
76 
77  template <size_t N, typename... ArgTypes>
78  Value<typename std::tuple_element<N, std::tuple<ArgTypes...>>::type>*
79  detup(Value<std::tuple<ArgTypes...>>* tup, const std::string& alias=""){
80  return new DeTup<N, ArgTypes...>(tup, alias);
81  }
82 
83  template <size_t N, typename... ArgTypes>
84  Value<std::vector<typename std::tuple_element<N, std::tuple<ArgTypes...>>::type>>*
85  detup_vec(Value<std::vector<std::tuple<ArgTypes...>>>* tup, const std::string& alias=""){
86  return new DeTupVector<N, ArgTypes...>(tup, alias);
87  }
88 
89  template <typename Ret, typename... ArgTypes>
90  Value<Ret>*
91  apply(Function<Ret(ArgTypes...)>& fn,
92  Value<std::tuple<ArgTypes...>>* arg, const std::string& alias=""){
93  return new Apply<Ret(ArgTypes...)>(fn, arg, alias);
94  }
95 
96  template <typename T1, typename T2>
98  pair(Value<T1>* val1, Value<T2>* val2, const std::string& alias=""){
99  return new Pair<T1,T2>(val1, val2, alias);
100  }
101 
102  template <typename T1, typename T2>
104  pair(const std::string& name1, const std::string& name2, const std::string& alias=""){
105  return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
106  }
107 
108 
109  template <typename T>
110  Value<T>*
111  max(Value<std::vector<T>>* v, const std::string& alias=""){
112  return new Max<T>(v, alias);
113  }
114 
115  template <typename T>
116  Value<T>*
117  max(const std::string& v_name, const std::string& alias=""){
118  return max(lookup<std::vector<T>>(v_name), alias);
119  }
120 
121  template <typename T>
122  Value<T>*
123  min(Value<std::vector<T>>* v, const std::string& alias=""){
124  return new Min<T>(v, alias);
125  }
126 
127  template <typename T>
128  Value<T>*
129  min(const std::string& v_name, const std::string& alias=""){
130  return min(lookup<std::vector<T>>(v_name), alias);
131  }
132 
133  template <typename T>
134  Value<T>*
135  range(Value<std::vector<T>>* v, const std::string& alias=""){
136  return new Range<T>(v, alias);
137  }
138 
139  template <typename T>
140  Value<T>*
141  range(const std::string& v_name, const std::string& alias=""){
142  return range(lookup<std::vector<T>>(v_name), alias);
143  }
144 
145  template <typename T>
146  Value<T>*
147  mean(Value<std::vector<T>>* v, const std::string& alias=""){
148  return new Mean<T>(v, alias);
149  }
150 
151  template <typename T>
152  Value<T>*
153  mean(const std::string& v_name, const std::string& alias=""){
154  return mean(lookup<std::vector<T>>(v_name), alias);
155  }
156 
157  template <typename T>
158  Value<int>*
159  count(Function<bool(T)>& selector, Value<std::vector<T>>* v, const std::string& alias=""){
160  return new Count<T>(selector, v, alias);
161  }
162 
163  template <typename T>
164  Value<int>*
165  count(Function<bool(T)>& selector, const std::string& v_name, const std::string& alias=""){
166  return count<T>(selector, lookup<std::vector<T>>(v_name), alias);
167  }
168 
169  template <typename FST, typename SND>
171  cart_product(Value<std::vector<FST>>* val1, Value<std::vector<SND>>* val2, const std::string& alias=""){
172  return new CartProduct<FST, SND>(val1, val2, alias);
173  }
174 
175  template <typename FST, typename SND>
177  cart_product(const std::string& val1_name, const std::string& val2_name, const std::string& alias=""){
178  return cart_product<FST,SND>(lookup<std::vector<FST>>(val1_name), lookup<std::vector<SND>>(val2_name), alias);
179  }
180 
181  template <typename T, int Size>
183  combinations(Value<std::vector<T>>* val, const std::string& alias=""){
184  return new Combinations<T, Size>(val, alias);
185  }
186 
187  template <typename T, int Size>
189  combinations(const std::string& val_name, const std::string alias = ""){
190  return combinations<T, Size>(lookup<std::vector<T>>(val_name), alias);
191  }
192 
193  template <typename T>
195  filter(Function<bool(T)>& filter, Value<std::vector<T>>* val, const std::string alias=""){
196  return new Filter<T>(filter, val, alias);
197  }
198 
199  template <typename T>
201  filter(Function<bool(T)>& filter_func, const std::string& val_name, const std::string alias=""){
202  return filter<T>(filter_func, lookup<std::vector<T>>(val_name), alias);
203  }
204 
205  template <typename... ArgTypes>
206  Value<std::vector<std::tuple<ArgTypes...>>>*
207  tup_filter(Function<bool(ArgTypes...)>& filter, Value<std::vector<std::tuple<ArgTypes...>>>* val, const std::string alias=""){
208  return new TupFilter<ArgTypes...>(filter, val, alias);
209  }
210 
211  template <typename... ArgTypes>
212  Value<std::vector<std::tuple<ArgTypes...>>>*
213  tup_filter(Function<bool(ArgTypes...)>& filter, const std::string& val_name, const std::string alias=""){
214  return tup_filter<ArgTypes...>(filter, lookup<std::vector<std::tuple<ArgTypes...>>>(val_name), alias);
215  }
216 
217  ObsFilter* obs_filter(const std::string& name, std::function<bool()> filter_function, const std::string& impl=""){
218  return new ObsFilter(name, filter_function, impl);
219  }
220 }
221 #endif // API_HPP
Find and return the maximum value of a vector.
Definition: value.hpp:918
Zips a series of vectors together.
Definition: value.hpp:639
Find combinations of items from an input vector.
Definition: value.hpp:1034
Calculate the range of the values in a vector.
Definition: value.hpp:959
Takes a series of Value objects and bundles them together into a std::tuple object.
Definition: value.hpp:738
Returns the count of elements in the input vector passing a test function.
Definition: value.hpp:822
Returns the elements in a vector that pass a test function.
Definition: value.hpp:845
Gets the Nth element from a tuple value.
Definition: value.hpp:761
Find and return the minimum value of a vector.
Definition: value.hpp:931
Creates a vector of extracting the Nth value from each entry in a vector of tuples.
Definition: value.hpp:779
Creates a std::pair type from a two other Value objects.
Definition: value.hpp:560
The namespace containing all filval classes and functions.
Definition: api.hpp:38
Returns the elements in a vector that pass a test function.
Definition: value.hpp:870
Calculate the mean value of a vector.
Definition: value.hpp:944
A generic value.
Definition: value.hpp:415
Calculate the cartesian product of two input vectors.
Definition: value.hpp:1077