summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-07-03 20:36:25 +0200
committer couriersud <couriersud@gmx.org>2020-07-03 20:36:59 +0200
commitf6e93867452d78eca4ba42e4837f0a36d7822340 (patch)
treea4b89289f4b922779686342285cb1f8026079741
parent0718a20df23aa377663ce6e90d98b35ae33f1225 (diff)
netlist: add more constructors and () operator to pfunction.
-rw-r--r--src/lib/netlist/plib/pfunction.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/lib/netlist/plib/pfunction.h b/src/lib/netlist/plib/pfunction.h
index 00206afe677..6b5e94b2900 100644
--- a/src/lib/netlist/plib/pfunction.h
+++ b/src/lib/netlist/plib/pfunction.h
@@ -70,27 +70,45 @@ namespace plib {
{
}
+ /// \brief Constructor with compile
+ ///
+ pfunction(const pstring &expr, const inputs_container &inputs = inputs_container())
+ : m_lfsr(0xace1U) // NOLINT
+ {
+ compile(expr, inputs);
+ }
+
+ /// \brief Evaluate the expression
+ ///
+ /// \param values for input variables, e.g. {1.1, 2.2}
+ /// \return value of expression
+ ///
+ value_type operator()(const values_container &values = values_container()) noexcept
+ {
+ return evaluate(values);
+ }
+
/// \brief Compile an expression
///
/// \param expr infix or postfix expression. default is infix, postrix
/// to be prefixed with rpn, e.g. "rpn:A B + 1.3 /"
/// \param inputs Vector of input variables, e.g. {"A","B"}
///
- void compile(const pstring &expr, const inputs_container &inputs) noexcept(false);
+ void compile(const pstring &expr, const inputs_container &inputs = inputs_container()) noexcept(false);
/// \brief Compile a rpn expression
///
/// \param expr Reverse polish notation expression, e.g. "A B + 1.3 /"
/// \param inputs Vector of input variables, e.g. {"A","B"}
///
- void compile_postfix(const pstring &expr, const inputs_container &inputs) noexcept(false);
+ void compile_postfix(const pstring &expr, const inputs_container &inputs = inputs_container()) noexcept(false);
/// \brief Compile an infix expression
///
/// \param expr Infix expression, e.g. "(A+B)/1.3"
/// \param inputs Vector of input variables, e.g. {"A","B"}
///
- void compile_infix(const pstring &expr, const inputs_container &inputs) noexcept(false);
+ void compile_infix(const pstring &expr, const inputs_container &inputs = inputs_container()) noexcept(false);
/// \brief Evaluate the expression
///