00001 /* $Id: CouenneExprClone.hpp 645 2011-06-14 10:04:49Z pbelotti $ 00002 * 00003 * Name: exprClone.hpp 00004 * Author: Pietro Belotti 00005 * Purpose: definition of the clone class (different from exprCopy in 00006 * that evaluation is propagated) 00007 * 00008 * (C) Carnegie-Mellon University, 2006. 00009 * This file is licensed under the Eclipse Public License (EPL) 00010 */ 00011 00012 #ifndef COUENNE_EXPRCLONE_HPP 00013 #define COUENNE_EXPRCLONE_HPP 00014 00015 #include <iostream> 00016 00017 #include "CouenneTypes.hpp" 00018 #include "CouenneExprCopy.hpp" 00019 00020 namespace Couenne { 00021 00023 00024 class exprClone: public exprCopy { 00025 00026 public: 00027 00029 exprClone (expression *copy): 00030 exprCopy (getOriginal (copy)) {} 00031 00033 exprClone (const exprClone &e, Domain *d = NULL): 00034 //{copy_ = e.copy_;}// d = e.domain_;} 00035 exprCopy (e, d) {} 00036 00038 expression *clone (Domain *d = NULL) const 00039 {return new exprClone (*this, d);} 00040 /*{ 00041 if (copy_ != Original ()) return copy_ -> clone (d); 00042 else return new exprClone (*this, d); 00043 }*/ 00044 //{return copy_ -> Original () -> clone (d);} 00045 00047 virtual ~exprClone () { 00048 //if (copy_ != Original ()) 00049 //delete copy_; 00050 copy_ = NULL; // unlink pointer so that ~exprCopy does nothing 00051 } 00052 00054 virtual void print (std::ostream &out = std::cout, 00055 bool descend = false) const; 00056 00058 inline CouNumber Value () const 00059 {return copy_ -> Value ();} 00060 00062 inline CouNumber operator () () 00063 {return ((*copy_) ());} 00064 }; 00065 00066 } 00067 00068 #endif