1 /* $Id$ 2 * 3 * Name: exprStore.hpp 4 * Author: Pietro Belotti 5 * Purpose: definition of a storage class for expressions 6 * 7 * (C) Carnegie-Mellon University, 2007. 8 * This file is licensed under the Eclipse Public License (EPL) 9 */ 10 11 #ifndef COUENNE_EXPRSTORE_HPP 12 #define COUENNE_EXPRSTORE_HPP 13 14 #include <iostream> 15 16 #include "CouenneTypes.hpp" 17 #include "CouenneExprCopy.hpp" 18 19 namespace Couenne { 20 21 /// storage class for previously evaluated expressions 22 23 class exprStore: public exprCopy { 24 25 protected: 26 27 /// Value of the (previously evaluated) expression 28 CouNumber value_; 29 30 public: 31 32 /// Constructor exprStore(expression * copy)33 exprStore (expression *copy): 34 exprCopy (copy) {} 35 36 /// Store constructor -- Must go exprStore(const exprStore & e,Domain * d=NULL)37 exprStore (const exprStore &e, Domain *d = NULL): 38 exprCopy (e, d) { 39 //copy_ = e.Original () -> clone (); 40 } 41 42 /// Destructor ~exprStore()43 virtual ~exprStore () 44 {copy_ = NULL;} 45 46 /// Printing 47 virtual void print (std::ostream &out = std::cout, 48 bool descend = false) const; 49 50 /// Cloning method clone(Domain * d=NULL) const51 virtual inline expression *clone (Domain *d = NULL) const 52 {return new exprStore (*this, d);} 53 54 /// function for evaluating the expression -- returns value of 55 /// exprCopy pointed to, which returns a value stored from a 56 /// previous evaluation operator ()()57 virtual inline CouNumber operator () () 58 {return (copy_ -> Value ());} 59 }; 60 61 } 62 63 #endif 64