49 Value<T>* lookup(
const std::string& name){
50 Value<T>* tv = GenValue::get_value<T>(name);
52 CRITICAL(
"Could not find alias or value \"" << name <<
"\"." 53 <<
" I'll tell you the ones I know about." << std::endl
54 << GenValue::summary(), -1);
60 bool check_exists(
const std::string name){
61 Value<T>* tv = GenValue::get_value<T>(name);
65 ObsFilter* lookup_obs_filter(
const std::string& name){
66 ObsFilter* f =
dynamic_cast<ObsFilter*
>(GenValue::get_value<bool>(name));
68 CRITICAL(
"ObsFilter: "+f->get_name() +
"has improper type.",-1);
76 typedef std::vector<T> type;
78 if (check_exists<type>(name))
79 return lookup<type>(name);
84 template <
typename... ArgTypes>
86 zip(
Value<std::vector<ArgTypes>>*... args,
const std::string& alias=
""){
87 typedef std::vector<std::tuple<ArgTypes...>> type;
89 if (check_exists<type>(name))
90 return lookup<type>(name);
95 template <
typename Ret,
typename... ArgTypes>
97 map(Function<Ret(ArgTypes...)>& fn,
Value<std::vector<std::tuple<ArgTypes...>>>* arg,
const std::string& alias=
""){
98 typedef std::vector<Ret> type;
99 const std::string& name = Map<Ret(ArgTypes...)>::fmt_name(fn, arg);
100 if (check_exists<type>(name))
101 return lookup<type>(name);
103 return (
Value<type>*)
new Map<Ret(ArgTypes...)>(fn, arg, alias);
106 template <
typename... ArgTypes>
109 typedef std::tuple<ArgTypes...> type;
111 if (check_exists<type>(name))
112 return lookup<type>(name);
117 template <
size_t N,
typename... ArgTypes>
119 detup(
Value<std::tuple<ArgTypes...>>* tup,
const std::string& alias=
""){
120 typedef typename std::tuple_element<N, std::tuple<ArgTypes...>>::type type;
122 if (check_exists<type>(name))
123 return lookup<type>(name);
128 template <
size_t N,
typename... ArgTypes>
130 detup_vec(
Value<std::vector<std::tuple<ArgTypes...>>>* tup,
const std::string& alias=
""){
131 typedef std::vector<
typename std::tuple_element<N, std::tuple<ArgTypes...>>::type> type;
133 if (check_exists<type>(name))
134 return lookup<type>(name);
139 template <
typename Ret,
typename... ArgTypes>
141 apply(Function<Ret(ArgTypes...)>& fn,
Value<std::tuple<ArgTypes...>>* arg,
const std::string& alias=
""){
143 const std::string& name = Apply<Ret(ArgTypes...)>::fmt_name(fn, arg);
144 if (check_exists<type>(name))
145 return lookup<type>(name);
147 return (
Value<type>*)
new Apply<Ret(ArgTypes...)>(fn, arg, alias);
150 template <
typename T1,
typename T2>
153 typedef std::pair<T1,T2> type;
155 if (check_exists<type>(name))
156 return lookup<type>(name);
161 template <
typename T1,
typename T2>
163 pair(
const std::string& name1,
const std::string& name2,
const std::string& alias=
""){
164 return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
167 template <
typename T>
169 reduce(Function<T(std::vector<T>)>& fn,
Value<std::vector<T>>* v,
const std::string& alias=
""){
172 if (check_exists<type>(name))
173 return lookup<type>(name);
178 template <
typename T>
180 max(
Value<std::vector<T>>* v,
const std::string& alias=
""){
183 if (check_exists<type>(name))
184 return lookup<type>(name);
189 template <
typename T>
191 max(
const std::string& v_name,
const std::string& alias=
""){
192 return max(lookup<std::vector<T>>(v_name), alias);
195 template <
typename T>
197 min(
Value<std::vector<T>>* v,
const std::string& alias=
""){
200 if (check_exists<type>(name))
201 return lookup<type>(name);
206 template <
typename T>
208 min(
const std::string& v_name,
const std::string& alias=
""){
209 return min(lookup<std::vector<T>>(v_name), alias);
212 template <
typename T>
214 range(
Value<std::vector<T>>* v,
const std::string& alias=
""){
217 if (check_exists<type>(name))
218 return lookup<type>(name);
223 template <
typename T>
225 range(
const std::string& v_name,
const std::string& alias=
""){
226 return range(lookup<std::vector<T>>(v_name), alias);
229 template <
typename T>
231 mean(
Value<std::vector<T>>* v,
const std::string& alias=
""){
234 if (check_exists<type>(name))
235 return lookup<type>(name);
240 template <
typename T>
242 mean(
const std::string& v_name,
const std::string& alias=
""){
243 return mean(lookup<std::vector<T>>(v_name), alias);
246 template <
typename T>
248 count(Function<
bool(T)>& selector,
Value<std::vector<T>>* v,
const std::string& alias=
""){
251 if (check_exists<type>(name))
252 return lookup<type>(name);
257 template <
typename T>
259 count(Function<
bool(T)>& selector,
const std::string& v_name,
const std::string& alias=
""){
260 return count<T>(selector, lookup<std::vector<T>>(v_name), alias);
263 template <
typename FST,
typename SND>
265 cart_product(
Value<std::vector<FST>>* val1,
Value<std::vector<SND>>* val2,
const std::string& alias=
""){
266 typedef std::vector<std::tuple<FST,SND>> type;
268 if (check_exists<type>(name))
269 return lookup<type>(name);
274 template <
typename FST,
typename SND>
276 cart_product(
const std::string& val1_name,
const std::string& val2_name,
const std::string& alias=
""){
277 return cart_product<FST,SND>(lookup<std::vector<FST>>(val1_name), lookup<std::vector<SND>>(val2_name), alias);
280 template <
typename T,
int Size>
282 combinations(
Value<std::vector<T>>* val,
const std::string& alias=
""){
283 typedef std::vector<typename HomoTuple<T,Size>::type> type;
285 if (check_exists<type>(name))
286 return lookup<type>(name);
291 template <
typename T,
int Size>
293 combinations(
const std::string& val_name,
const std::string alias =
""){
294 return combinations<T, Size>(lookup<std::vector<T>>(val_name), alias);
297 template <
typename T>
299 constant(
const std::string name, T const_value,
const std::string alias=
""){
302 if (check_exists<type>(val_name))
303 return lookup<type>(val_name);
308 template <
typename T>
310 bound(Function<T()>& f,
const std::string alias=
""){
313 if (check_exists<type>(name))
314 return lookup<type>(name);
319 template <
typename T>
321 filter(Function<
bool(T)>& filter,
Value<std::vector<T>>* val,
const std::string alias=
""){
322 typedef std::vector<T> type;
324 if (check_exists<type>(name))
325 return lookup<type>(name);
330 template <
typename T>
332 filter(Function<
bool(T)>& filter_func,
const std::string& val_name,
const std::string alias=
""){
333 return filter<T>(filter_func, lookup<std::vector<T>>(val_name), alias);
336 template <
typename... ArgTypes>
338 tup_filter(Function<
bool(ArgTypes...)>& filter,
Value<std::vector<std::tuple<ArgTypes...>>>* val,
const std::string alias=
""){
339 typedef std::vector<std::tuple<ArgTypes...>> type;
341 if (check_exists<type>(name))
342 return lookup<type>(name);
347 template <
typename... ArgTypes>
349 tup_filter(Function<
bool(ArgTypes...)>& filter,
const std::string& val_name,
const std::string alias=
""){
350 return tup_filter<ArgTypes...>(filter, lookup<std::vector<std::tuple<ArgTypes...>>>(val_name), alias);
353 ObsFilter* obs_filter(
const std::string& name, std::function<
bool()> filter_function,
const std::string& impl=
""){
354 return new ObsFilter(name, filter_function, impl);
Find and return the maximum value of a vector.
Zips a series of vectors together.
Reduce a Value of type vector<T> to just a T.
Find combinations of items from an input vector.
A generic value owning only a function object.
Calculate the range of the values in a vector.
Takes a series of Value objects and bundles them together into a std::tuple object.
A std::vector wrapper around a C-style array.
Returns the count of elements in the input vector passing a test function.
Returns the elements in a vector that pass a test function.
Gets the Nth element from a tuple value.
Find and return the minimum value of a vector.
Creates a vector of extracting the Nth value from each entry in a vector of tuples.
Creates a std::pair type from a two other Value objects.
The namespace containing all filval classes and functions.
Returns the elements in a vector that pass a test function.
Calculate the mean value of a vector.
Calculate the cartesian product of two input vectors.
A Value which always returns the same value, supplied in the constructor.