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: DoubleParameter.hpp,v 1.3 2007/06/09 10:37:06 delpinux Exp $ 00019 00020 00021 #ifndef DOUBLE_PARAMETER_HPP 00022 #define DOUBLE_PARAMETER_HPP 00023 00024 #include <Parameter.hpp> 00025 00026 #include <Stringify.hpp> 00027 #include <ErrorHandler.hpp> 00028 00035 class DoubleParameter 00036 : public Parameter 00037 { 00038 private: 00039 const real_t __defaultDoubleValue; 00040 real_t __realValue; 00041 00042 std::ostream& put (std::ostream& os) const 00043 { 00044 os << __realValue; 00045 return os; 00046 } 00047 00048 public: 00050 void get(IdentifierSet& I) 00051 { 00052 ; 00053 } 00054 00055 void set(const real_t d) 00056 { 00057 __realValue = d; 00058 } 00059 00060 void set(const int i) 00061 { 00062 __realValue = (real_t)(i); 00063 } 00064 00065 void set(const char* c) 00066 { 00067 throw ErrorHandler(__FILE__,__LINE__, 00068 "cannot assignate the string '"+stringify(c) 00069 +"' to a real_t parameter\n", 00070 ErrorHandler::normal); 00071 } 00072 00073 operator real_t&() 00074 { 00075 return __realValue; 00076 } 00077 00078 operator real_t() const 00079 { 00080 return __realValue; 00081 } 00082 00083 void reset() 00084 { 00085 __realValue = __defaultDoubleValue; 00086 } 00087 00088 const std::string typeName() const 00089 { 00090 return "real"; 00091 } 00092 00093 DoubleParameter(const DoubleParameter& dp) 00094 : Parameter(dp), 00095 __defaultDoubleValue(dp.__defaultDoubleValue), 00096 __realValue(dp.__realValue) 00097 { 00098 ; 00099 } 00100 00101 DoubleParameter(const real_t d, const char* label) 00102 : Parameter(Parameter::Double, label), 00103 __defaultDoubleValue(d), 00104 __realValue(d) 00105 { 00106 ; 00107 } 00108 00109 ~DoubleParameter() 00110 { 00111 ; 00112 } 00113 }; 00114 00115 #endif // DOUBLE_PARAMETER_HPP
1.5.6