1#ifndef IV_SRC_LOGIC_LOGICEXPRESSION_HPP_
2#define IV_SRC_LOGIC_LOGICEXPRESSION_HPP_
6#include "third_party/exprtk.hpp"
18 const std::map<std::string, std::weak_ptr<iv::channels::AbstractChannel>> &variables);
32 std::set<std::string> &variables);
33 bool compile(std::string &errorMessage);
34 [[nodiscard]] std::optional<iv::types::channelValue>
evaluate();
37 [[nodiscard]] std::map<std::string, std::weak_ptr<iv::channels::AbstractChannel>>
getVariables()
const;
40 const std::weak_ptr<iv::channels::AbstractChannel> &channel);
44 std::map<std::string, std::weak_ptr<iv::channels::AbstractChannel>>
m_variables;
48 typedef exprtk::parser<iv::types::channelValue>
parser_t;
55 static constexpr std::string_view
expression {
"Expression"};
62 static constexpr std::string_view
variables {
"Variables"};
63 static constexpr std::string_view
variable {
"Variable"};
68 static constexpr std::string
string {};
Definition xmlFile.hpp:15
Definition LogicExpression.hpp:14
std::string strExpression
Definition LogicExpression.hpp:43
bool operator==(const LogicExpression &) const
Definition LogicExpression.cpp:120
expression_t expression
Definition LogicExpression.hpp:50
bool compile(std::string &errorMessage)
Definition LogicExpression.cpp:130
LogicExpression & operator=(const LogicExpression &other)
Definition LogicExpression.cpp:98
std::string getStrExpression() const
Definition LogicExpression.cpp:205
std::map< std::string, std::weak_ptr< iv::channels::AbstractChannel > > m_variables
Definition LogicExpression.hpp:44
LogicExpression()=default
exprtk::expression< iv::types::channelValue > expression_t
Definition LogicExpression.hpp:47
~LogicExpression()=default
static bool getErrorAndVariables(const std::string &expr, std::string &errorMessage, std::set< std::string > &variables)
Definition LogicExpression.cpp:182
exprtk::parser< iv::types::channelValue > parser_t
Definition LogicExpression.hpp:48
bool setVariableChannel(const std::string &variableName, const std::weak_ptr< iv::channels::AbstractChannel > &channel)
Definition LogicExpression.cpp:216
bool save(iv::file::xml::node &nodeLogicExpression) const
Definition LogicExpression.cpp:66
std::optional< iv::types::channelValue > evaluate()
Definition LogicExpression.cpp:164
bool load(const iv::file::xml::node &nodeLogicExpression)
Definition LogicExpression.cpp:33
symbol_table_t symbolTable
Definition LogicExpression.hpp:51
exprtk::symbol_table< iv::types::channelValue > symbol_table_t
Definition LogicExpression.hpp:46
std::map< std::string, std::weak_ptr< iv::channels::AbstractChannel > > getVariables() const
Definition LogicExpression.cpp:211
Definition LogicExpression.cpp:6
Definition LogicExpression.hpp:67
Definition LogicExpression.hpp:54
static constexpr std::string_view variableChannelId
Definition LogicExpression.hpp:57
static constexpr std::string_view variableName
Definition LogicExpression.hpp:56
static constexpr std::string_view expression
Definition LogicExpression.hpp:55
Definition LogicExpression.hpp:61
static constexpr std::string_view variables
Definition LogicExpression.hpp:62
static constexpr std::string_view variable
Definition LogicExpression.hpp:63