/** * @file * @author Caleb Fangmeier * @version 0.1 * * @section LICENSE * * * MIT License * * Copyright (c) 2017 Caleb Fangmeier * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * @section DESCRIPTION */ #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 Value>>* zip(Value>*... args, const std::string& alias=""){ return new Zip(args..., alias); } template Value>* map(Function& fn, Value>>* arg, const std::string& alias=""){ return new Map(fn, arg, alias); } template Value>* tuple(Value*... args, const std::string& alias=""){ return new Tuple(args..., alias); } template Value>::type>* detup(Value>* tup, const std::string& alias=""){ return new DeTup(tup, alias); } template Value>::type>>* detup_vec(Value>>* tup, const std::string& alias=""){ return new DeTupVector(tup, alias); } template Value* apply(Function& fn, Value>* arg, const std::string& alias=""){ return new Apply(fn, arg, alias); } template Value>* pair(Value* val1, Value* val2, const std::string& alias=""){ return new Pair(val1, val2, alias); } template Value>* pair(const std::string& name1, const std::string& name2, const std::string& alias=""){ return pair(lookup(name1), lookup(name2), alias); } template Value* max(Value>* v, const std::string& alias=""){ return new Max(v, alias); } template Value* max(const std::string& v_name, const std::string& alias=""){ return max(lookup>(v_name), alias); } template Value* min(Value>* v, const std::string& alias=""){ return new Min(v, alias); } template Value* min(const std::string& v_name, const std::string& alias=""){ return min(lookup>(v_name), alias); } template Value* range(Value>* v, const std::string& alias=""){ return new Range(v, alias); } template Value* range(const std::string& v_name, const std::string& alias=""){ return range(lookup>(v_name), alias); } template Value* mean(Value>* v, const std::string& alias=""){ return new Mean(v, alias); } template Value* mean(const std::string& v_name, const std::string& alias=""){ return mean(lookup>(v_name), alias); } template Value* count(Function& selector, Value>* v, const std::string& alias=""){ return new Count(selector, v, alias); } template Value* count(Function& selector, const std::string& v_name, const std::string& alias=""){ return count(selector, lookup>(v_name), alias); } template Value>>* cart_product(Value>* val1, Value>* val2, const std::string& alias=""){ return new CartProduct(val1, val2, alias); } template Value>>* cart_product(const std::string& val1_name, const std::string& val2_name, const std::string& alias=""){ return cart_product(lookup>(val1_name), lookup>(val2_name), alias); } template Value::type>>* combinations(Value>* val, const std::string& alias=""){ return new Combinations(val, alias); } template Value::type>>* combinations(const std::string& val_name, const std::string alias = ""){ return combinations(lookup>(val_name), alias); } template Value>* filter(Function& filter, Value>* val, const std::string alias=""){ return new Filter(filter, val, alias); } template Value>* filter(Function& filter_func, const std::string& val_name, const std::string alias=""){ return filter(filter_func, lookup>(val_name), alias); } template Value>>* tup_filter(Function& filter, Value>>* val, const std::string alias=""){ return new TupFilter(filter, val, alias); } template Value>>* tup_filter(Function& filter, const std::string& val_name, const std::string alias=""){ return tup_filter(filter, lookup>>(val_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