00001 /* 00002 00003 This file is part of OpenFLUID software 00004 Copyright(c) 2007, INRA - Montpellier SupAgro 00005 00006 00007 == GNU General Public License Usage == 00008 00009 OpenFLUID is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 OpenFLUID is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>. 00021 00022 00023 == Other Usage == 00024 00025 Other Usage means a use of OpenFLUID that is inconsistent with the GPL 00026 license, and requires a written agreement between You and INRA. 00027 Licensees for Other Usage of OpenFLUID may use this file in accordance 00028 with the terms contained in the written agreement between You and INRA. 00029 00030 */ 00031 00032 00033 00034 /** 00035 \file DoubleValue.hpp 00036 \brief Header of ... 00037 00038 \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr> 00039 */ 00040 00041 00042 #ifndef __DOUBLEVALUE_HPP___ 00043 #define __DOUBLEVALUE_HPP___ 00044 00045 #include <openfluid/core/SimpleValue.hpp> 00046 #include <openfluid/dllexport.hpp> 00047 00048 00049 namespace openfluid { namespace core { 00050 /** 00051 DoubleValue is a container for a signed double precision floating point value.\n 00052 00053 \see Value 00054 00055 \n 00056 00057 <I>Example : declaration</I> 00058 @code 00059 // declaration of a DoubleValue, initialized to 0.0 by default 00060 openfluid::core::DoubleValue Val1; 00061 00062 // declaration of a DoubleValue, initialized to 1.357 00063 openfluid::core::DoubleValue Val2(1.357); 00064 @endcode 00065 00066 00067 <I>Example : getting the contained value</I> 00068 @code 00069 double Tmp1; 00070 00071 // using the get method 00072 Tmp1 = Val1.get(); 00073 00074 // or using the cast operator 00075 Tmp1 = Val1; 00076 @endcode 00077 00078 00079 <I>Example : setting the contained value</I> 00080 @code 00081 // using the set method 00082 Val1.set(101.99); 00083 @endcode 00084 00085 00086 <I>Example : conversion from string</I> 00087 @code 00088 openfluid::core::StringValue StringVal("57.33"); 00089 00090 // to DoubleValue 00091 Val1 = StringVal.toDoubleValue(); 00092 00093 // to double 00094 double DblVal = StringVal.toDouble(); 00095 @endcode 00096 00097 00098 <I>Example : conversion to string</I> 00099 @code 00100 std::string StdStrVal = Val1.toString(); 00101 @endcode 00102 */ 00103 class DLLEXPORT DoubleValue : public SimpleValue 00104 { 00105 private: 00106 00107 double m_Value; 00108 00109 public: 00110 00111 /** 00112 Default constructor 00113 */ 00114 DoubleValue() : m_Value(0.0) {}; 00115 00116 /** 00117 Copy constructor 00118 */ 00119 DoubleValue(const DoubleValue& Val) : SimpleValue(Val), m_Value(Val.m_Value) {}; 00120 00121 00122 /** 00123 Constructor from plain old type 00124 */ 00125 DoubleValue(const double& POD) : SimpleValue(), m_Value(POD) {}; 00126 00127 Value& operator =(const Value& Other); 00128 00129 /** 00130 Cast operator 00131 */ 00132 operator double() const { return m_Value; }; 00133 00134 virtual ~DoubleValue() {}; 00135 00136 inline Type getType() const { return Value::DOUBLE; }; 00137 00138 Value* clone() const { return new DoubleValue(*this); }; 00139 00140 /** 00141 Returns the double value as plain old type 00142 @return the double value 00143 */ 00144 inline double& get() { return m_Value; }; 00145 00146 /** 00147 Returns the double value as a const plain old type 00148 @return the double value 00149 */ 00150 inline const double& get() const { return m_Value; }; 00151 00152 /** 00153 Sets the plain old type double value 00154 @param[in] Val the double value 00155 */ 00156 inline void set(const double& Val) { m_Value = Val; }; 00157 00158 void writeToStream(std::ostream& OutStm) const; 00159 00160 }; 00161 00162 00163 } } // namespaces 00164 00165 00166 #endif /* __DOUBLEVALUE_HPP___ */