Skip to content
Snippets Groups Projects
Commit 1677fd4c authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Helper static method Predicate::evaluate

parent df485eda
Branches
No related merge requests found
......@@ -29,10 +29,7 @@ protected:
virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
boost::shared_ptr<T> set1 = this->set1_expr_->apply(context);
boost::shared_ptr<T> set2 = this->set2_expr_->apply(context);
if(set1->is_subset_of(*set2)) {
return Predicate::True(context);
}
return Predicate::False(context);
return Predicate::evaluate(set1->intersects(*set2), context);
}
};
......
......@@ -42,10 +42,7 @@ protected:
*/
virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context);
if(pos->is_inside(context.sentence_context())) {
return Predicate::True(context);
}
return Predicate::False(context);
return Predicate::evaluate(pos->is_inside(context.sentence_context()), context);
}
};
......
......@@ -42,10 +42,7 @@ protected:
*/
virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context);
if(pos->is_outside(context.sentence_context())) {
return Predicate::True(context);
}
return Predicate::False(context);
return Predicate::evaluate(pos->is_outside(context.sentence_context()), context);
}
};
......
......@@ -32,11 +32,10 @@ protected:
*/
virtual BaseRetValPtr apply_internal(const FunExecContext& context) const {
boost::shared_ptr<T> possible_subset = this->set1_expr_->apply(context);
if(!possible_subset->empty()) {
if(!possible_subset->empty())
{
boost::shared_ptr<T> set_compared_to = this->set2_expr_->apply(context);
if(possible_subset->is_subset_of(*set_compared_to)) {
return Predicate::True(context);
}
return Predicate::evaluate(possible_subset->is_subset_of(*set_compared_to), context);
}
return Predicate::False(context);
}
......
......@@ -14,4 +14,9 @@ Predicate::RetValPtr Predicate::False(const FunExecContext& context)
return false_constant.apply(context);
}
Predicate::RetValPtr Predicate::evaluate(bool condition, const FunExecContext &context)
{
return condition ? True(context) : False(context);
}
} /* end ns Wccl */
......@@ -21,6 +21,10 @@ public:
* Helper function returing False, to use by predicates when returning value
*/
static RetValPtr False(const FunExecContext& context);
/**
* Helper function returing True or False depending on condition
*/
static RetValPtr evaluate(bool condition, const FunExecContext& context);
};
} /* end ns Wccl */
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment