All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MatrixValue.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  \file MatrixValue.hpp
35  \brief Header of ...
36 
37  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __MATRIXVALUE_HPP__
42 #define __MATRIXVALUE_HPP__
43 
46 #include <openfluid/dllexport.hpp>
47 
48 
49 namespace openfluid { namespace core {
50 
51 /**
52  MatrixValue is a container for a 2D matrix of signed double precision floating point values.\n
53 
54 \see Value
55 \see Matrix
56 
57 \n
58 
59 <I>Example : declaration</I>
60 @code
61  // declaration of a MatrixValue, empty by default
62  openfluid::core::MatrixValue Val1;
63 
64  // declaration of a MatrixValue, of 3 columns by 7 rows, with values initialized to 0.0
65  openfluid::core::MatrixValue Val2(3,7);
66 
67  // declaration of a MatrixValue, of 3 columns by 7 rows, with values initialized to 1.99
68  openfluid::core::MatrixValue Val3(3,7,1.99);
69 @endcode
70 
71 
72 <I>Example : getting the contained values</I>
73 @code
74  double Tmp1;
75 
76  Tmp1 = Val1.get(2,3);
77 @endcode
78 
79 
80 <I>Example : getting all values as a c-style array of double, rows-first indexed</I>
81 @code
82  double DblArrayVal[];
83 
84  DblArrayVal = Val1.getData();
85 @endcode
86 
87 
88 <I>Example : setting the contained values</I>
89 @code
90  // using the set method
91  Val1.set(0,0,101.99);
92 @endcode
93 
94 
95 <I>Example : conversion from string</I>
96 @code
97  openfluid::core::StringValue StringVal;
98  openfluid::core::MatrixValue Val2;
99 
100  // to MatrixValue, using two string values separators
101  StringVal.set("3;5;2.8;6;17.999923|1;1;1;1;1|2.11;2.12;2.13;2.14;2.15");
102  StringVal.toMatrixValue(";","|",Val2);
103 
104  // to MatrixValue, using a single string values separator and row length
105  StringVal.set("3;5;2.8;6;17.999923;1;1;1;1;1;2.11;2.12;2.13;2.14;2.15");
106  StringVal.toMatrixValue(";",5,Val2);
107 @endcode
108 
109 
110 <I>Example : conversion to string</I>
111 @code
112  std::string StdStrVal = Val1.toString();
113 @endcode
114 */
115 class DLLEXPORT MatrixValue : public CompoundValue, public Matrix<double>
116 {
117 
118  public:
119 
120  /**
121  Default constructor
122  */
123  MatrixValue() : CompoundValue(), Matrix<double>() {};
124 
125  /**
126  Copy constructor
127  */
128  MatrixValue(const MatrixValue& Val) : CompoundValue(static_cast<const CompoundValue&>(Val)), Matrix<double>(static_cast<const Matrix<double>& >(Val)) {};
129 
130  /**
131  Constructor, creates a Matrix containing ColsNbr x RowsNbr elements
132  */
133  MatrixValue(unsigned long ColsNbr,unsigned long RowsNbr) : CompoundValue(), Matrix<double>(ColsNbr,RowsNbr) {};
134 
135  /**
136  Constructor, creates a Matrix containing ColsNbr x RowsNbr elements, initialized with value InitValue
137  */
138  MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr, double InitValue) : CompoundValue(), Matrix<double>(ColsNbr,RowsNbr,InitValue) {};
139 
140  Value& operator =(const Value& Other);
141 
142  virtual ~MatrixValue() {};
143 
144  inline Type getType() const { return Value::MATRIX; };
145 
146  Value* clone() const { return new MatrixValue(*this); };
147 
148  void writeToStream(std::ostream& OutStm) const;
149 
150 };
151 
152 
153 } } // namespaces
154 
155 
156 
157 #endif /* __MATRIXVALUE_HPP__ */
Definition: Matrix.hpp:59
Definition: Value.hpp:68
Definition: CompoundValue.hpp:53
MatrixValue(const MatrixValue &Val)
Definition: MatrixValue.hpp:128
MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr)
Definition: MatrixValue.hpp:133
Header of ...
virtual ~MatrixValue()
Definition: MatrixValue.hpp:142
MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr, double InitValue)
Definition: MatrixValue.hpp:138
Value * clone() const
Definition: MatrixValue.hpp:146
MatrixValue()
Definition: MatrixValue.hpp:123
Type
Definition: Value.hpp:68
Header of ...
Definition: MatrixValue.hpp:115
Definition: Value.hpp:64
Type getType() const
Definition: MatrixValue.hpp:144
#define DLLEXPORT
Definition: dllexport.hpp:51