/** * @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 Map* map(Function& fn, Value>>* 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); } 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); } 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