10 #include "boost/lexical_cast.hpp"
40 if(m_expression.size()>0) {
41 o << m_expression << std::endl;
42 o << std::string(m_expression.size(),
'-') << std::endl;
61 m_count = sm[2].length()>0 ? boost::lexical_cast<unsigned int,std::string>(sm[2]) : 1;
67 auto stateForThisLeaf = elementsState.find(m_content);
68 if( stateForThisLeaf == elementsState.end() ) {
69 throw LogicParsingException(std::string(
"Can't evaluate logic ") + m_content +
" as it is missing in the state map");
71 return negate() ? !stateForThisLeaf->second : stateForThisLeaf->second;
77 auto stateForThisLeaf = elementsCount.find(m_name);
78 if( stateForThisLeaf == elementsCount.end() ) {
79 throw LogicParsingException(std::string(
"Can't evaluate logic ") + m_content +
" as " + m_name +
" is missing in the counts map");
81 bool pass = stateForThisLeaf->second >= m_count;
82 return negate() ? !pass : pass;
85 std::map<std::string, bool>
87 return {{m_name,
true}};
91 std::map<std::string, unsigned int>
93 return {{m_name, m_count}};
99 o << std::string(indSize*indLevel,
' ');
100 if( negate() ) { o <<
"NOT "; }
101 o << m_content << std::endl;
112 m_subs.push_back(std::move(left));
118 m_subs.push_back(std::move(right));
121 const std::vector<std::unique_ptr<TrigConf::Logic>> &
126 std::vector<std::unique_ptr<TrigConf::Logic>>
128 auto tmp = std::move(m_subs);
135 o << std::string(indSize*indLevel,
' ');
136 if( negate() ) { o <<
"NOT "; }
137 o << (nodeType()==
Logic::AND ?
"AND (" :
"OR (") << std::endl;
138 for(
auto & subLogic : m_subs ) {
139 subLogic->print(o,indSize, indLevel+1);
141 o << std::string(indSize*indLevel,
' ') <<
")" << std::endl;
157 for(
auto & subLogic : subLogics() ) {
158 if(! subLogic->evaluate(elementsState) ) {
159 return negate() ? true :
false;
162 return negate() ? false :
true;
167 for(
auto & subLogic : subLogics() ) {
168 if(! subLogic->evaluate(elementsCount) ) {
169 return negate() ? true :
false;
172 return negate() ? false :
true;
175 std::map<std::string, bool>
177 std::map<std::string, bool> elements;
178 for(
auto & subLogic : subLogics() ) {
179 for (
const auto&
el : subLogic->elements() ) {
186 std::map<std::string, unsigned int>
188 std::map<std::string, unsigned int> elementsCount;
189 for(
auto & subLogic : subLogics() ) {
190 for (
const auto&
el : subLogic->elementsCount() ) {
191 elementsCount.insert(
el);
194 return elementsCount;
207 for(
auto & subLogic : subLogics() ) {
208 if( subLogic->evaluate(elementsState) ) {
209 return negate() ? false :
true;
212 return negate() ? true :
false;
217 for(
auto & subLogic : subLogics() ) {
218 if( subLogic->evaluate(elementsCount) ) {
219 return negate() ? false :
true;
222 return negate() ? true :
false;
225 std::map<std::string, bool>
227 std::map<std::string, bool> elements;
228 for(
auto & subLogic : subLogics() ) {
229 for (
const auto&
el : subLogic->elements() ) {
236 std::map<std::string, unsigned int>
238 std::map<std::string, unsigned int> elementsCount;
239 for(
auto & subLogic : subLogics() ) {
240 for (
const auto&
el : subLogic->elementsCount() ) {
241 elementsCount.insert(
el);
244 return elementsCount;