#ifndef API_HPP #define API_HPP #include #include #include "filval/value.hpp" namespace fv{ template Value* lookup(const std::string& name){ GenValue* gv = GenValue::get_value(name); Value* tv = dynamic_cast*>(gv); if(tv == nullptr){ CRITICAL("Value: "+gv->get_name() + "has improper type.",-1); } return tv; } ObsFilter* lookup_obs_filter(const std::string& name){ ObsFilter* f = dynamic_cast(GenValue::get_value(name)); if(f == nullptr){ CRITICAL("ObsFilter: "+f->get_name() + "has improper type.",-1); } return f; } template Zip* zip(Value>*... args, const std::string& alias=""){ return new Zip(args..., alias); } template Map* map(Function& fn, Zip* arg, const std::string& alias=""){ return new Map(fn, arg, alias); } template Tuple* tuple(Value*... args, const std::string& alias=""){ return new Tuple(args..., alias); } template Apply* apply(Function& fn, Tuple* arg, const std::string& alias=""){ return new Apply(fn, arg, alias); } template Pair* pair(Value* val1, Value* val2, const std::string& alias=""){ return new Pair(val1, val2, alias); } template Pair* pair(const std::string& name1, const std::string& name2, const std::string& alias=""){ return pair(lookup(name1), lookup(name2), alias); } template Max* max(Value>* v, const std::string alias){ return new Max(v, alias); } template Max* max(const std::string& v_name, const std::string alias){ return max(lookup>(v_name), alias); } template Min* min(Value>* v, const std::string alias){ return new Min(v, alias); } template Min* min(const std::string& v_name, const std::string alias){ return min(lookup>(v_name), alias); } template Range* range(Value>* v, const std::string alias){ return new Range(v, alias); } template Range* range(const std::string& v_name, const std::string alias){ return range(lookup>(v_name), alias); } template Mean* mean(Value>* v, const std::string alias){ return new Mean(v, alias); } template Mean* mean(const std::string& v_name, const std::string alias){ return mean(lookup>(v_name), alias); } template Count* count(Function& selector, Value>* v, const std::string alias){ return new Count(selector, v, alias); } template Count* count(Function& selector, const std::string& v_name, const std::string alias){ return count(selector, lookup>(v_name), alias); } ObsFilter* obs_filter(const std::string& name, std::function filter_function, const std::string& impl=""){ return new ObsFilter(name, filter_function, impl); } } #endif // API_HPP