41 Value<T>* lookup(
const std::string& name){
42 GenValue* gv = GenValue::get_value(name);
44 CRITICAL(
"Could not find alias or value \"" << name <<
"\"." 45 <<
" I'll tell you the ones I know about." << std::endl
46 << GenValue::summary(), -1);
50 CRITICAL(
"Value: \""+gv->get_name() +
"\" has improper type.",-1);
56 bool check_exists(
const std::string name){
57 GenValue* gv = GenValue::get_value(name);
62 ObsFilter* lookup_obs_filter(
const std::string& name){
63 ObsFilter* f =
dynamic_cast<ObsFilter*
>(GenValue::get_value(name));
65 CRITICAL(
"ObsFilter: "+f->get_name() +
"has improper type.",-1);
73 typedef std::vector<T> type;
75 if (check_exists<type>(name))
76 return lookup<type>(name);
81 template <
typename... ArgTypes>
83 zip(
Value<std::vector<ArgTypes>>*... args,
const std::string& alias=
""){
84 typedef std::vector<std::tuple<ArgTypes...>> type;
86 if (check_exists<type>(name))
87 return lookup<type>(name);
92 template <
typename Ret,
typename... ArgTypes>
94 map(Function<Ret(ArgTypes...)>& fn,
Value<std::vector<std::tuple<ArgTypes...>>>* arg,
const std::string& alias=
""){
95 typedef std::vector<Ret> type;
96 const std::string& name = Map<Ret(ArgTypes...)>::fmt_name(fn, arg);
97 if (check_exists<type>(name))
98 return lookup<type>(name);
100 return (
Value<type>*)
new Map<Ret(ArgTypes...)>(fn, arg, alias);
103 template <
typename... ArgTypes>
106 typedef std::tuple<ArgTypes...> type;
108 if (check_exists<type>(name))
109 return lookup<type>(name);
114 template <
size_t N,
typename... ArgTypes>
116 detup(
Value<std::tuple<ArgTypes...>>* tup,
const std::string& alias=
""){
117 typedef typename std::tuple_element<N, std::tuple<ArgTypes...>>::type type;
119 if (check_exists<type>(name))
120 return lookup<type>(name);
125 template <
size_t N,
typename... ArgTypes>
127 detup_vec(
Value<std::vector<std::tuple<ArgTypes...>>>* tup,
const std::string& alias=
""){
128 typedef std::vector<
typename std::tuple_element<N, std::tuple<ArgTypes...>>::type> type;
130 if (check_exists<type>(name))
131 return lookup<type>(name);
136 template <
typename Ret,
typename... ArgTypes>
138 apply(Function<Ret(ArgTypes...)>& fn,
Value<std::tuple<ArgTypes...>>* arg,
const std::string& alias=
""){
140 const std::string& name = Apply<Ret(ArgTypes...)>::fmt_name(fn, arg);
141 if (check_exists<type>(name))
142 return lookup<type>(name);
144 return (
Value<type>*)
new Apply<Ret(ArgTypes...)>(fn, arg, alias);
147 template <
typename T1,
typename T2>
150 typedef std::pair<T1,T2> type;
152 if (check_exists<type>(name))
153 return lookup<type>(name);
158 template <
typename T1,
typename T2>
160 pair(
const std::string& name1,
const std::string& name2,
const std::string& alias=
""){
161 return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
165 template <
typename T>
167 max(
Value<std::vector<T>>* v,
const std::string& alias=
""){
170 if (check_exists<type>(name))
171 return lookup<type>(name);
176 template <
typename T>
178 max(
const std::string& v_name,
const std::string& alias=
""){
179 return max(lookup<std::vector<T>>(v_name), alias);
182 template <
typename T>
184 min(
Value<std::vector<T>>* v,
const std::string& alias=
""){
187 if (check_exists<type>(name))
188 return lookup<type>(name);
193 template <
typename T>
195 min(
const std::string& v_name,
const std::string& alias=
""){
196 return min(lookup<std::vector<T>>(v_name), alias);
199 template <
typename T>
201 range(
Value<std::vector<T>>* v,
const std::string& alias=
""){
204 if (check_exists<type>(name))
205 return lookup<type>(name);
210 template <
typename T>
212 range(
const std::string& v_name,
const std::string& alias=
""){
213 return range(lookup<std::vector<T>>(v_name), alias);
216 template <
typename T>
218 mean(
Value<std::vector<T>>* v,
const std::string& alias=
""){
221 if (check_exists<type>(name))
222 return lookup<type>(name);
227 template <
typename T>
229 mean(
const std::string& v_name,
const std::string& alias=
""){
230 return mean(lookup<std::vector<T>>(v_name), alias);
233 template <
typename T>
235 count(Function<
bool(T)>& selector,
Value<std::vector<T>>* v,
const std::string& alias=
""){
238 if (check_exists<type>(name))
239 return lookup<type>(name);
244 template <
typename T>
246 count(Function<
bool(T)>& selector,
const std::string& v_name,
const std::string& alias=
""){
247 return count<T>(selector, lookup<std::vector<T>>(v_name), alias);
250 template <
typename FST,
typename SND>
252 cart_product(
Value<std::vector<FST>>* val1,
Value<std::vector<SND>>* val2,
const std::string& alias=
""){
253 typedef std::vector<std::tuple<FST,SND>> type;
255 if (check_exists<type>(name))
256 return lookup<type>(name);
261 template <
typename FST,
typename SND>
263 cart_product(
const std::string& val1_name,
const std::string& val2_name,
const std::string& alias=
""){
264 return cart_product<FST,SND>(lookup<std::vector<FST>>(val1_name), lookup<std::vector<SND>>(val2_name), alias);
267 template <
typename T,
int Size>
269 combinations(
Value<std::vector<T>>* val,
const std::string& alias=
""){
270 typedef std::vector<typename HomoTuple<T,Size>::type> type;
272 if (check_exists<type>(name))
273 return lookup<type>(name);
278 template <
typename T,
int Size>
280 combinations(
const std::string& val_name,
const std::string alias =
""){
281 return combinations<T, Size>(lookup<std::vector<T>>(val_name), alias);
284 template <
typename T>
286 filter(Function<
bool(T)>& filter,
Value<std::vector<T>>* val,
const std::string alias=
""){
287 typedef std::vector<T> type;
289 if (check_exists<type>(name))
290 return lookup<type>(name);
295 template <
typename T>
297 filter(Function<
bool(T)>& filter_func,
const std::string& val_name,
const std::string alias=
""){
298 return filter<T>(filter_func, lookup<std::vector<T>>(val_name), alias);
301 template <
typename... ArgTypes>
303 tup_filter(Function<
bool(ArgTypes...)>& filter,
Value<std::vector<std::tuple<ArgTypes...>>>* val,
const std::string alias=
""){
304 typedef std::vector<std::tuple<ArgTypes...>> type;
306 if (check_exists<type>(name))
307 return lookup<type>(name);
312 template <
typename... ArgTypes>
314 tup_filter(Function<
bool(ArgTypes...)>& filter,
const std::string& val_name,
const std::string alias=
""){
315 return tup_filter<ArgTypes...>(filter, lookup<std::vector<std::tuple<ArgTypes...>>>(val_name), alias);
318 ObsFilter* obs_filter(
const std::string& name, std::function<
bool()> filter_function,
const std::string& impl=
""){
319 return new ObsFilter(name, filter_function, impl);
Find and return the maximum value of a vector.
Definition: value.hpp:976
Zips a series of vectors together.
Definition: value.hpp:666
Find combinations of items from an input vector.
Definition: value.hpp:1108
Calculate the range of the values in a vector.
Definition: value.hpp:1029
Takes a series of Value objects and bundles them together into a std::tuple object.
Definition: value.hpp:774
A std::vector wrapper around a C-style array.
Definition: value.hpp:543
Returns the count of elements in the input vector passing a test function.
Definition: value.hpp:868
Returns the elements in a vector that pass a test function.
Definition: value.hpp:895
Gets the Nth element from a tuple value.
Definition: value.hpp:795
Find and return the minimum value of a vector.
Definition: value.hpp:993
Creates a vector of extracting the Nth value from each entry in a vector of tuples.
Definition: value.hpp:817
Creates a std::pair type from a two other Value objects.
Definition: value.hpp:568
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:924
Calculate the mean value of a vector.
Definition: value.hpp:1010
A templated value.
Definition: value.hpp:415
Calculate the cartesian product of two input vectors.
Definition: value.hpp:1151