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);
168 template <
typename T>
170 max(
Value<std::vector<T>>* v,
const std::string& alias=
""){
173 if (check_exists<type>(name))
174 return lookup<type>(name);
179 template <
typename T>
181 max(
const std::string& v_name,
const std::string& alias=
""){
182 return max(lookup<std::vector<T>>(v_name), alias);
185 template <
typename T>
187 min(
Value<std::vector<T>>* v,
const std::string& alias=
""){
190 if (check_exists<type>(name))
191 return lookup<type>(name);
196 template <
typename T>
198 min(
const std::string& v_name,
const std::string& alias=
""){
199 return min(lookup<std::vector<T>>(v_name), alias);
202 template <
typename T>
204 range(
Value<std::vector<T>>* v,
const std::string& alias=
""){
207 if (check_exists<type>(name))
208 return lookup<type>(name);
213 template <
typename T>
215 range(
const std::string& v_name,
const std::string& alias=
""){
216 return range(lookup<std::vector<T>>(v_name), alias);
219 template <
typename T>
221 mean(
Value<std::vector<T>>* v,
const std::string& alias=
""){
224 if (check_exists<type>(name))
225 return lookup<type>(name);
230 template <
typename T>
232 mean(
const std::string& v_name,
const std::string& alias=
""){
233 return mean(lookup<std::vector<T>>(v_name), alias);
236 template <
typename T>
238 count(Function<
bool(T)>& selector,
Value<std::vector<T>>* v,
const std::string& alias=
""){
241 if (check_exists<type>(name))
242 return lookup<type>(name);
247 template <
typename T>
249 count(Function<
bool(T)>& selector,
const std::string& v_name,
const std::string& alias=
""){
250 return count<T>(selector, lookup<std::vector<T>>(v_name), alias);
253 template <
typename FST,
typename SND>
255 cart_product(
Value<std::vector<FST>>* val1,
Value<std::vector<SND>>* val2,
const std::string& alias=
""){
256 typedef std::vector<std::tuple<FST,SND>> type;
258 if (check_exists<type>(name))
259 return lookup<type>(name);
264 template <
typename FST,
typename SND>
266 cart_product(
const std::string& val1_name,
const std::string& val2_name,
const std::string& alias=
""){
267 return cart_product<FST,SND>(lookup<std::vector<FST>>(val1_name), lookup<std::vector<SND>>(val2_name), alias);
270 template <
typename T,
int Size>
272 combinations(
Value<std::vector<T>>* val,
const std::string& alias=
""){
273 typedef std::vector<typename HomoTuple<T,Size>::type> type;
275 if (check_exists<type>(name))
276 return lookup<type>(name);
281 template <
typename T,
int Size>
283 combinations(
const std::string& val_name,
const std::string alias =
""){
284 return combinations<T, Size>(lookup<std::vector<T>>(val_name), alias);
287 template <
typename T>
289 filter(Function<
bool(T)>& filter,
Value<std::vector<T>>* val,
const std::string alias=
""){
290 typedef std::vector<T> type;
292 if (check_exists<type>(name))
293 return lookup<type>(name);
298 template <
typename T>
300 filter(Function<
bool(T)>& filter_func,
const std::string& val_name,
const std::string alias=
""){
301 return filter<T>(filter_func, lookup<std::vector<T>>(val_name), alias);
304 template <
typename... ArgTypes>
306 tup_filter(Function<
bool(ArgTypes...)>& filter,
Value<std::vector<std::tuple<ArgTypes...>>>* val,
const std::string alias=
""){
307 typedef std::vector<std::tuple<ArgTypes...>> type;
309 if (check_exists<type>(name))
310 return lookup<type>(name);
315 template <
typename... ArgTypes>
317 tup_filter(Function<
bool(ArgTypes...)>& filter,
const std::string& val_name,
const std::string alias=
""){
318 return tup_filter<ArgTypes...>(filter, lookup<std::vector<std::tuple<ArgTypes...>>>(val_name), alias);
321 ObsFilter* obs_filter(
const std::string& name, std::function<
bool()> filter_function,
const std::string& impl=
""){
322 return new ObsFilter(name, filter_function, impl);
Find and return the maximum value of a vector.
Zips a series of vectors together.
Find combinations of items from an input vector.
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.