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 VectorValue.hpp 00036 \brief Header of ... 00037 00038 \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr> 00039 */ 00040 00041 00042 #ifndef __VECTORVALUE_HPP___ 00043 #define __VECTORVALUE_HPP___ 00044 00045 #include <openfluid/core/CompoundValue.hpp> 00046 #include <openfluid/core/Vector.hpp> 00047 #include <openfluid/dllexport.hpp> 00048 00049 00050 namespace openfluid { namespace core { 00051 00052 /** 00053 VectorValue is a container for a 1D vector of signed double precision floating point values.\n 00054 00055 \see Value 00056 \see Vector 00057 00058 \n 00059 00060 <I>Example : declaration</I> 00061 @code 00062 // declaration of a VectorValue, empty by default 00063 openfluid::core::VectorValue Val1; 00064 00065 // declaration of a VectorValue of 7 elements, with values initialized to 0.0 00066 openfluid::core::VectorValue Val2(7); 00067 00068 // declaration of a VectorValue of 7 elements, with values initialized to 1.99 00069 openfluid::core::VectorValue Val3(7,1.99); 00070 @endcode 00071 00072 00073 <I>Example : getting the contained values</I> 00074 @code 00075 double Tmp1; 00076 00077 // using the get method 00078 Tmp1 = Val1.get(2); 00079 00080 // or using the [] operator 00081 Tmp1 = Val1[2]; 00082 @endcode 00083 00084 00085 <I>Example : getting all values as a c-style array of double</I> 00086 @code 00087 double DblArrayVal[]; 00088 00089 DblArrayVal = Val1.getData(); 00090 @endcode 00091 00092 00093 <I>Example : setting the contained values</I> 00094 @code 00095 // using the set method 00096 Val1.set(0,101.99); 00097 00098 // or using the [] operator 00099 Val1[0] = 101.99; 00100 @endcode 00101 00102 00103 <I>Example : conversion from string</I> 00104 @code 00105 openfluid::core::StringValue StringVal; 00106 openfluid::core::VectorValue Val2; 00107 00108 // to VectorValue, using a string values separator 00109 StringVal.set("3;5;2.8;6;17.999923;1;1;1;1;1;2.11;2.12;2.13;2.14;2.15"); 00110 StringVal.toVectorValue(";",Val2); 00111 @endcode 00112 00113 00114 <I>Example : conversion to string</I> 00115 @code 00116 std::string StdStrVal = Val1.toString(); 00117 @endcode 00118 */ 00119 class DLLEXPORT VectorValue : public CompoundValue, public Vector<double> 00120 { 00121 00122 public: 00123 00124 /** 00125 Default constructor 00126 */ 00127 VectorValue() : CompoundValue(), Vector<double>() {}; 00128 00129 /** 00130 Copy constructor 00131 */ 00132 VectorValue(const VectorValue& Val) : CompoundValue(static_cast<const CompoundValue&>(Val)), Vector<double>(static_cast<const Vector<double>& >(Val)) {}; 00133 00134 /** 00135 Constructor, creates a vector containing Size elements 00136 */ 00137 VectorValue(unsigned long Size) : CompoundValue(), Vector<double>(Size) {}; 00138 00139 /** 00140 Constructor, creates a vector containing Size elements, initialized with value InitValue 00141 */ 00142 VectorValue(unsigned long Size, double InitValue) : CompoundValue(), Vector<double>(Size,InitValue) {}; 00143 00144 /** 00145 Constructor, creates a vector of size Size, containing Data 00146 */ 00147 VectorValue(double* Data, unsigned long Size) : CompoundValue(), Vector<double>(Data,Size) {}; 00148 00149 Value& operator =(const Value& Other); 00150 00151 virtual ~VectorValue() {}; 00152 00153 inline Type getType() const { return Value::VECTOR; }; 00154 00155 Value* clone() const { return new VectorValue(*this); }; 00156 00157 void writeToStream(std::ostream& OutStm) const; 00158 00159 }; 00160 00161 00162 } } // namespaces 00163 00164 00165 00166 #endif /* __VECTORVALUE_HPP___ */