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