00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2001, 2002, 2003 Stéphane Del Pino 00003 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 // $Id: SolutionExpression.hpp,v 1.2 2003/05/04 18:09:01 delpinux Exp $ 00019 00020 #ifndef _SOLUTION_EXPRESSION_HPP_ 00021 #define _SOLUTION_EXPRESSION_HPP_ 00022 00023 #include <Expression.hpp> 00024 #include <Variable.hpp> 00025 00033 class SolutionExpression 00034 : public Expression 00035 { 00036 protected: 00037 ReferenceCounting<FunctionExpression> __solution; 00038 00039 public: 00040 enum SolutionType { 00041 undefined, 00042 value, 00043 variable 00044 }; 00045 00046 ReferenceCounting<FunctionExpression> 00047 operator=(ReferenceCounting<FunctionExpression> u); 00048 00049 private: 00050 SolutionExpression::SolutionType __solutionType; 00051 00052 public: 00053 ReferenceCounting<FunctionExpression> solution(); 00054 00055 const SolutionExpression::SolutionType& solutionType() const 00056 { 00057 return __solutionType; 00058 } 00059 00060 SolutionExpression(const SolutionExpression& u); 00061 00062 SolutionExpression(const SolutionExpression::SolutionType& t); 00063 00064 virtual ~SolutionExpression(); 00065 }; 00066 00067 class SolutionExpressionVariable 00068 : public SolutionExpression 00069 { 00070 private: 00071 ReferenceCounting<SolutionVariable> __solutionVariable; 00072 00073 std::ostream& put(std::ostream& os) const 00074 { 00075 os << (*__solutionVariable).name() << ": " << (*(*__solutionVariable).expression()); 00076 return os; 00077 } 00078 00079 public: 00080 void execute() 00081 { 00082 ; 00083 } 00084 00085 ReferenceCounting<SolutionVariable> variable() const 00086 { 00087 return __solutionVariable; 00088 } 00089 00090 SolutionExpressionVariable(ReferenceCounting<SolutionVariable> r); 00091 00092 SolutionExpressionVariable(const SolutionExpressionVariable& e); 00093 00094 ~SolutionExpressionVariable(); 00095 }; 00096 00097 class SolutionExpressionUndefined 00098 : public SolutionExpression 00099 { 00100 private: 00101 std::ostream& put(std::ostream& os) const 00102 { 00103 os << "undefined solution"; 00104 return os; 00105 } 00106 00107 public: 00108 void execute(); 00109 00110 SolutionExpressionUndefined(); 00111 00112 SolutionExpressionUndefined(const SolutionExpressionUndefined& u); 00113 00114 ~SolutionExpressionUndefined(); 00115 }; 00116 00117 #endif // _SOLUTION_EXPRESSION_HPP_ 00118
1.5.6