10const std::regex
re(
"([-\\w.]+)(?:\\[x(\\d+)\\])?$" );
57 std::regex_match(content, sm,
re);
59 m_count = sm[2].length() > 0 ?
static_cast<unsigned int>(std::stoul(sm[2])) : 1;
65 auto stateForThisLeaf = elementsState.find(
m_content);
66 if( stateForThisLeaf == elementsState.end() ) {
69 return negate() ? !stateForThisLeaf->second : stateForThisLeaf->second;
79 bool pass = stateForThisLeaf->second >=
m_count;
80 return negate() ? !pass : pass;
83std::map<std::string, bool>
89std::map<std::string, unsigned int>
97 o << std::string(indSize*indLevel,
' ');
98 if(
negate() ) { o <<
"NOT "; }
110 m_subs.push_back(std::move(left));
116 m_subs.push_back(std::move(right));
119const std::vector<std::unique_ptr<TrigConf::Logic>> &
124std::vector<std::unique_ptr<TrigConf::Logic>>
126 auto tmp = std::move(
m_subs);
133 o << std::string(indSize*indLevel,
' ');
134 if(
negate() ) { o <<
"NOT "; }
136 for(
auto & subLogic :
m_subs ) {
137 subLogic->print(o,indSize, indLevel+1);
139 o << std::string(indSize*indLevel,
' ') <<
")" << std::endl;
156 if(! subLogic->evaluate(elementsState) ) {
157 return negate() ? true :
false;
160 return negate() ? false :
true;
167 return negate() ? true :
false;
170 return negate() ? false :
true;
173std::map<std::string, bool>
175 std::map<std::string, bool>
elements;
177 for (
const auto& el : subLogic->elements() ) {
184std::map<std::string, unsigned int>
188 for (
const auto& el : subLogic->elementsCount() ) {
206 if( subLogic->evaluate(elementsState) ) {
207 return negate() ? false :
true;
210 return negate() ? true :
false;
217 return negate() ? false :
true;
220 return negate() ? true :
false;
223std::map<std::string, bool>
225 std::map<std::string, bool>
elements;
227 for (
const auto& el : subLogic->elements() ) {
234std::map<std::string, unsigned int>
238 for (
const auto& el : subLogic->elementsCount() ) {
const boost::regex re(r_e)
const std::regex re("([-\\w.]+)(?:\\[x(\\d+)\\])?$")
void print(char *figname, TCanvas *c1)
std::map< std::string, bool > elements() const override
bool evaluate(const std::map< std::string, bool > &elementsState) const override
std::map< std::string, unsigned int > elementsCount() const override
bool evaluate(const std::map< std::string, bool > &elements) const override
std::map< std::string, unsigned int > elementsCount() const override
virtual void print(std::ostream &, size_t indSize, size_t indLevel) const override
std::map< std::string, bool > elements() const override
void setContent(const std::string &content)
void addSubLogic(std::unique_ptr< Logic > &&right)
LogicOPS(NodeType nodeType)
std::vector< std::unique_ptr< Logic > > takeSubLogics()
virtual void print(std::ostream &, size_t indSize, size_t indLevel) const override
std::vector< std::unique_ptr< Logic > > m_subs
const std::vector< std::unique_ptr< Logic > > & subLogics() const
std::map< std::string, bool > elements() const override
std::map< std::string, unsigned int > elementsCount() const override
bool evaluate(const std::map< std::string, bool > &elementsState) const override
Class to hold the logic structure representing a logical expression and evaluate it for a given state...
NodeType nodeType() const
void setNegate(bool negate=true)
void setExpression(const std::string &)
const std::string & expression() const
void print(std::ostream &=std::cout) const