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