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>
65  Map<Ret(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 
72  template <typename... ArgTypes>
73  Tuple<ArgTypes...>*
74  tuple(Value<ArgTypes>*... args, const std::string& alias=""){
75  return new Tuple<ArgTypes...>(args..., alias);
76  }
77 
78  template <typename Ret, typename... ArgTypes>
79  Apply<Ret(ArgTypes...)>*
80  apply(Function<Ret(ArgTypes...)>& fn,
81  Tuple<ArgTypes...>* arg, const std::string& alias=""){
82  return new Apply<Ret(ArgTypes...)>(fn, arg, alias);
83  }
84 
85  template <typename T1, typename T2>
87  pair(Value<T1>* val1, Value<T2>* val2, const std::string& alias=""){
88  return new Pair<T1,T2>(val1, val2, alias);
89  }
90 
91  template <typename T1, typename T2>
93  pair(const std::string& name1, const std::string& name2, const std::string& alias=""){
94  return pair<T1,T2>(lookup<T1>(name1), lookup<T2>(name2), alias);
95  }
96 
97 
98  template <typename T>
99  Max<T>*
100  max(Value<std::vector<T>>* v, const std::string alias){
101  return new Max<T>(v, alias);
102  }
103 
104  template <typename T>
105  Max<T>*
106  max(const std::string& v_name, const std::string alias){
107  return max(lookup<std::vector<T>>(v_name), alias);
108  }
109 
110  template <typename T>
111  Min<T>*
112  min(Value<std::vector<T>>* v, const std::string alias){
113  return new Min<T>(v, alias);
114  }
115 
116  template <typename T>
117  Min<T>*
118  min(const std::string& v_name, const std::string alias){
119  return min(lookup<std::vector<T>>(v_name), alias);
120  }
121 
122  template <typename T>
123  Range<T>*
124  range(Value<std::vector<T>>* v, const std::string alias){
125  return new Range<T>(v, alias);
126  }
127 
128  template <typename T>
129  Range<T>*
130  range(const std::string& v_name, const std::string alias){
131  return range(lookup<std::vector<T>>(v_name), alias);
132  }
133 
134  template <typename T>
135  Mean<T>*
136  mean(Value<std::vector<T>>* v, const std::string alias){
137  return new Mean<T>(v, alias);
138  }
139 
140  template <typename T>
141  Mean<T>*
142  mean(const std::string& v_name, const std::string alias){
143  return mean(lookup<std::vector<T>>(v_name), alias);
144  }
145 
146  template <typename T>
147  Count<T>*
148  count(Function<bool(T)>& selector, Value<std::vector<T>>* v, const std::string alias){
149  return new Count<T>(selector, v, alias);
150  }
151 
152  template <typename T>
153  Count<T>*
154  count(Function<bool(T)>& selector, const std::string& v_name, const std::string alias){
155  return count<T>(selector, lookup<std::vector<T>>(v_name), alias);
156  }
157 
158  template <typename FST, typename SND>
160  cart_product(Value<std::vector<FST>>* val1, Value<std::vector<SND>>* val2, const std::string alias){
161  return new CartProduct<FST, SND>(val1, val2, alias);
162  }
163 
164  template <typename FST, typename SND>
166  cart_product(const std::string& val1_name, const std::string& val2_name, const std::string alias = ""){
167  return cart_product<FST,SND>(lookup<std::vector<FST>>(val1_name), lookup<std::vector<SND>>(val2_name), alias);
168  }
169 
170  ObsFilter* obs_filter(const std::string& name, std::function<bool()> filter_function, const std::string& impl=""){
171  return new ObsFilter(name, filter_function, impl);
172  }
173 }
174 #endif // API_HPP
Find and return the maximum value of a vector.
Definition: value.hpp:788
Zips a series of vectors together.
Definition: value.hpp:546
Calculate the range of the values in a vector.
Definition: value.hpp:829
Takes a series of Value objects and bundles them together into a std::tuple object.
Definition: value.hpp:670
Returns the count of elements in the input vector passing a test function.
Definition: value.hpp:717
Find and return the minimum value of a vector.
Definition: value.hpp:801
Creates a std::pair type from a two other Value objects.
Definition: value.hpp:467
The namespace containing all filval classes and functions.
Definition: api.hpp:38
Calculate the mean value of a vector.
Definition: value.hpp:814
A generic value.
Definition: value.hpp:352
Find and return the minimum value of a vector and its index.
Definition: value.hpp:904