diff options
author | Martin Braun <martin.braun@ettus.com> | 2016-08-01 18:17:41 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-08-09 12:42:52 -0700 |
commit | 3bf4b000f7d9a7f4af82c21753556ede7e8df6e3 (patch) | |
tree | 2228d7eb58c4d83d91192cb9b6a908e4e49f6317 /host/lib/rfnoc/nocscript/function_table.hpp | |
parent | c5b076173e2d866f3ee99c113a37183c5ec20f0b (diff) | |
download | uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.tar.gz uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.tar.bz2 uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.zip |
Merging RFNoC support for X310
Diffstat (limited to 'host/lib/rfnoc/nocscript/function_table.hpp')
-rw-r--r-- | host/lib/rfnoc/nocscript/function_table.hpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/host/lib/rfnoc/nocscript/function_table.hpp b/host/lib/rfnoc/nocscript/function_table.hpp new file mode 100644 index 000000000..6c715308e --- /dev/null +++ b/host/lib/rfnoc/nocscript/function_table.hpp @@ -0,0 +1,93 @@ +// +// Copyright 2015 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#include "expression.hpp" +#include <boost/shared_ptr.hpp> +#include <boost/function.hpp> +#include <vector> + +#ifndef INCLUDED_LIBUHD_RFNOC_NOCSCRIPT_FUNCTABLE_HPP +#define INCLUDED_LIBUHD_RFNOC_NOCSCRIPT_FUNCTABLE_HPP + +namespace uhd { namespace rfnoc { namespace nocscript { + +class function_table +{ + public: + typedef boost::shared_ptr<function_table> sptr; + typedef boost::function<expression_literal(expression_container::expr_list_type&)> function_ptr; + + static sptr make(); + virtual ~function_table() {}; + + /*! Check if any function with a given name exists + * + * \returns True, if any function with name \p name is registered. + */ + virtual bool function_exists(const std::string &name) const = 0; + + /*! Check if a function with a given name and list of argument types exists + * + * \returns True, if such a function is registered. + */ + virtual bool function_exists( + const std::string &name, + const expression_function::argtype_list_type &arg_types + ) const = 0; + + /*! Get the return type of a function with given name and argument type list + * + * \returns The function's return type + * \throws uhd::syntax_error if no such function is registered + */ + virtual expression::type_t get_type( + const std::string &name, + const expression_function::argtype_list_type &arg_types + ) const = 0; + + /*! Calls the function \p name with the argument list \p arguments + * + * \param arg_types A list of types for each argument + * \param arguments An expression list of the arguments + * \returns The return value of the called function + * \throws uhd::syntax_error if no such function is found + */ + virtual expression_literal eval( + const std::string &name, + const expression_function::argtype_list_type &arg_types, + expression_container::expr_list_type &arguments + ) = 0; + + /*! Register a new function + * + * \param name Name of the function (e.g. 'ADD') + * \param ptr Function object + * \param return_type The function's return value + * \param sig The function signature (list of argument types) + */ + virtual void register_function( + const std::string &name, + const function_ptr &ptr, + const expression::type_t return_type, + const expression_function::argtype_list_type &sig + ) = 0; +}; + +}}} /* namespace uhd::rfnoc::nocscript */ + +#endif /* INCLUDED_LIBUHD_RFNOC_NOCSCRIPT_FUNCTABLE_HPP */ +// vim: sw=4 et: |