// File: Constraint.cpp #include "Constraint.h" using namespace std; Constraint::Constraint(Exp *e) : exp(e) { vars=new StringSet(); exp->getVariables(vars); } Constraint::Constraint(const Constraint& c) { exp=c.exp->clone(); vars=new StringSet(*c.vars); } Constraint& Constraint::operator=(const Constraint& c) { delete exp; delete vars; exp=c.exp->clone(); vars=new StringSet(*c.vars); return *this; } string Constraint::toString() const { return exp->toString(); } bool Constraint::isSatisfied(const Environment *env) const throw (VarException) { Exp *res=exp->eval(env); bool b=((BoolExp*)res)->getValue(); delete res; return b; } Constraint::~Constraint() { delete exp; delete vars; }