22 #ifndef __M2ETIS_PUBSUB_FILTER_VARIABLEASSIGNMENTVISITOR_H__
23 #define __M2ETIS_PUBSUB_FILTER_VARIABLEASSIGNMENTVISITOR_H__
33 template <
typename EventType>
37 explicit VariableAssignmentVisitor(
unsigned long predicate_assignment) : predicate_assignment_(predicate_assignment), predicate_number_(0) {}
42 bool operand1 = operand_stack_.top();
44 bool operand2 = operand_stack_.top();
46 operand_stack_.push(operand1 && operand2);
51 bool operand1 = operand_stack_.top();
53 bool operand2 = operand_stack_.top();
55 operand_stack_.push(operand1 || operand2);
59 operand_stack_.push((predicate_assignment_ & (1UL << predicate_number_)) != 0);
60 predicate_index_[predicate_number_] = current_predicate;
65 if (!operand_stack_.empty()) {
68 predicate_number_ = 0;
72 return operand_stack_.empty() ? 0 : operand_stack_.top();
76 return predicate_number_;
80 return predicate_index_;
84 predicate_assignment_ = predicate_assignment;
88 std::stack<bool> operand_stack_;
89 unsigned long predicate_assignment_;
93 int predicate_number_;
94 std::map<int, const Predicate<EventType> *> predicate_index_;
void set_predicate_assignment(unsigned long predicate_assignment)
virtual void Visit(const AndExp< EventType > *) override
int get_predicate_number() const
virtual void Visit(const Predicate< EventType > *current_predicate) override
VariableAssignmentVisitor(unsigned long predicate_assignment)
std::map< int, const Predicate< EventType > * > get_predicate_index() const
virtual void Visit(const OrExp< EventType > *) override
virtual void Visit(const FilterExp< EventType > *) override
VariableAssignmentVisitor()