throw logic_error("CompoundCondition::dispatch_flatten");
}
-Condition *CompoundCondition::merge_two(Condition *cond1, Condition *cond2, bool del) const
+Condition *CompoundCondition::merge_two(Condition *cond1, Condition *cond2, const CompoundCondition &parent, bool del)
{
vector<const Condition *> parts(2);
parts[0] = cond1;
parts[1] = cond2;
- Condition *result = cond1->merge(parts, *this);
+ Condition *result = cond1->merge(parts, parent);
if(del)
{
return result;
}
-Condition *CompoundCondition::add_merged_to(Condition *cond, CompoundCondition *target, bool del) const
+Condition *CompoundCondition::add_merged_to(Condition *cond, CompoundCondition *target, bool del)
{
bool merged = false;
for(vector<Condition *>::iterator i=target->conditions.begin(); i!=target->conditions.end(); ++i)
if((*i)->can_merge(*cond, *target))
{
- Condition *m = merge_two(cond, *i, false);
+ Condition *m = merge_two(cond, *i, *target, false);
delete *i;
if(del)
delete cond;
return target;
}
-Condition *CompoundCondition::merge_contents_to(CompoundCondition *cond, CompoundCondition *target) const
+Condition *CompoundCondition::merge_contents_to(CompoundCondition *cond, CompoundCondition *target)
{
for(vector<Condition *>::iterator i=cond->conditions.begin(); i!=cond->conditions.end(); ++i)
add_merged_to(*i, target, false);
Condition *AndCondition::flatten(Condition *cond1, Condition *cond2) const
{
if(cond1->can_merge(*cond2, *this))
- return merge_two(cond1, cond2, true);
+ return merge_two(cond1, cond2, *this, true);
AndCondition *result = new AndCondition;
result->add(cond1);
Condition *OrCondition::flatten(Condition *cond1, Condition *cond2) const
{
if(cond1->can_merge(*cond2, *this))
- return merge_two(cond1, cond2, true);
+ return merge_two(cond1, cond2, *this, true);
OrCondition *result = new OrCondition;
result->add(cond1);
virtual Condition *flatten() const;
protected:
Condition *dispatch_flatten(Condition *, Condition *) const;
- Condition *merge_two(Condition *, Condition *, bool) const;
- Condition *add_merged_to(Condition *, CompoundCondition *, bool) const;
- Condition *merge_contents_to(CompoundCondition *, CompoundCondition *) const;
+ static Condition *merge_two(Condition *, Condition *, const CompoundCondition &, bool);
+ static Condition *add_merged_to(Condition *, CompoundCondition *, bool);
+ static Condition *merge_contents_to(CompoundCondition *, CompoundCondition *);
virtual Condition *flatten(Condition *, Condition *) const = 0;
virtual Condition *flatten(AndCondition *, Condition *) const = 0;
virtual Condition *flatten(AndCondition *, AndCondition *) const = 0;