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 IntegerValue.hpp 00036 \brief Header of ... 00037 00038 \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr> 00039 */ 00040 00041 00042 #ifndef __INTEGERVALUE_HPP___ 00043 #define __INTEGERVALUE_HPP___ 00044 00045 00046 00047 #include <openfluid/core/SimpleValue.hpp> 00048 #include <openfluid/dllexport.hpp> 00049 00050 00051 namespace openfluid { namespace core { 00052 00053 /** 00054 IntegerValue is a container for a signed long integer value.\n 00055 00056 \see Value 00057 00058 \n 00059 00060 <I>Example : declaration</I> 00061 @code 00062 // declaration of an IntegerValue, initialized to 0 by default 00063 openfluid::core::IntegerValue Val1; 00064 00065 // declaration of an IntegerValue, initialized to 35 00066 openfluid::core::IntegerValue Val2(35); 00067 @endcode 00068 00069 00070 <I>Example : getting the contained value</I> 00071 @code 00072 long Tmp1; 00073 00074 // using the get method 00075 Tmp1 = Val1.get(); 00076 00077 // or using the cast operator 00078 Tmp1 = Val1; 00079 @endcode 00080 00081 00082 <I>Example : setting the contained value</I> 00083 @code 00084 // using the set method 00085 Val1.set(-10199); 00086 @endcode 00087 00088 00089 <I>Example : conversion from string</I> 00090 @code 00091 openfluid::core::StringValue StringVal("57"); 00092 00093 // to IntegerValue 00094 Val1 = StringVal.toIntegerValue(); 00095 00096 // to long 00097 long LongVal = StringVal.toInteger(); 00098 @endcode 00099 00100 00101 <I>Example : conversion to string</I> 00102 @code 00103 std::string StdStrVal = Val1.toString(); 00104 @endcode 00105 */ 00106 class DLLEXPORT IntegerValue : public SimpleValue 00107 { 00108 private: 00109 00110 long m_Value; 00111 00112 public: 00113 00114 /** 00115 Default constructor 00116 */ 00117 IntegerValue() : m_Value(0) {}; 00118 00119 /** 00120 Copy constructor 00121 */ 00122 IntegerValue(const IntegerValue& Val) : SimpleValue(Val), m_Value(Val.m_Value) {}; 00123 00124 /** 00125 Constructor from plain old type 00126 */ 00127 IntegerValue(const long& POD) : SimpleValue(), m_Value(POD) {}; 00128 00129 Value& operator =(const Value& Other); 00130 00131 /** 00132 * Cast operator 00133 */ 00134 operator long() const { return m_Value; }; 00135 00136 virtual ~IntegerValue() {}; 00137 00138 inline Type getType() const { return Value::INTEGER; }; 00139 00140 Value* clone() const { return new IntegerValue(*this); }; 00141 00142 /** 00143 Returns the integer value as plain old type 00144 @return the integer value 00145 */ 00146 inline long& get() { return m_Value; }; 00147 00148 /** 00149 Returns the integer value as a const plain old type 00150 @return the integer value 00151 */ 00152 inline const long& get() const { return m_Value; }; 00153 00154 /** 00155 Sets the plain old type long integer value 00156 @param[in] Val the long integer value 00157 */ 00158 inline void set(const long& Val) { m_Value = Val; }; 00159 00160 void writeToStream(std::ostream& OutStm) const; 00161 00162 }; 00163 00164 00165 } } // namespaces 00166 00167 00168 #endif /* __INTEGERVALUE_HPP___ */