Documentation for OpenFLUID 2.2.0
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 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_CORE_MATRIXVALUE_HPP__
41 #define __OPENFLUID_CORE_MATRIXVALUE_HPP__
42 
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  <I>Example : declaration</I>
58  @snippet misc/values.cpp matrix_decl
59 
60  <I>Example : getting the contained values</I>
61  @snippet misc/values.cpp matrix_get
62 
63  <I>Example : getting all values as a c-style array of double, rows-first indexed</I>
64  @snippet misc/values.cpp matrix_get_carray
65 
66  <I>Example : setting the contained values</I>
67  @snippet misc/values.cpp matrix_set
68 
69  <I>Example : conversion from string</I>
70  @snippet misc/values.cpp matrix_fromstr
71 
72  <I>Example : conversion to string</I>
73  @snippet misc/values.cpp matrix_tostr
74 
75  @cond OpenFLUID:completion
76  {
77  "contexts" : ["ANYWARE"],
78  "menupath" : ["Types", "Values"],
79  "title" : "MatrixValue",
80  "text" : "openfluid::core::MatrixValue %%SEL_START%%Val%%SEL_END%%"
81  }
82  @endcond
83 */
84 class OPENFLUID_API MatrixValue : public CompoundValue, public Matrix<double>
85 {
86 
87  public:
88 
89  /**
90  Default constructor
91  */
92  MatrixValue() : CompoundValue(), Matrix<double>()
93  { }
94 
95  /**
96  Copy constructor
97  */
99  Matrix<double>(static_cast<const Matrix<double>&>(Val))
100  { }
101 
102  /**
103  Move constructor
104  */
106  Matrix<double>(std::move(static_cast<Matrix<double>&&>(Val)))
107  { }
108 
109  /**
110  Constructor, creates a Matrix containing ColsNbr x RowsNbr elements
111  */
112  MatrixValue(unsigned long ColsNbr,unsigned long RowsNbr) : CompoundValue(), Matrix<double>(ColsNbr,RowsNbr)
113  {
114 
115  }
116 
117  /**
118  Constructor, creates a Matrix containing ColsNbr x RowsNbr elements, initialized with value InitValue
119  */
120  MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr, double InitValue) :
121  CompoundValue(), Matrix<double>(ColsNbr,RowsNbr,InitValue)
122  {
123 
124  }
125 
126  MatrixValue& operator=(const Value& Other) override;
127 
128  MatrixValue& operator=(Value&& Other) override;
129 
131 
133 
134  virtual ~MatrixValue()
135  {
136 
137  }
138 
139  inline Type getType() const override
140  {
141  return Value::MATRIX;
142  };
143 
144  Value* clone() const override
145  {
146  return new MatrixValue(*this);
147  }
148 
149  void writeToStream(std::ostream& OutStm) const override;
150 
151  void writeQuotedToStream(std::ostream& OutStm) const override
152  {
153  writeToStream(OutStm);
154  }
155 
156 };
157 
158 
159 } } // namespaces
160 
161 
162 #endif /* __OPENFLUID_CORE_MATRIXVALUE_HPP__ */
Definition: CompoundValue.hpp:52
Definition: MatrixValue.hpp:85
virtual ~MatrixValue()
Definition: MatrixValue.hpp:134
MatrixValue & operator=(MatrixValue &&Other)
MatrixValue(MatrixValue &&Val)
Definition: MatrixValue.hpp:105
void writeToStream(std::ostream &OutStm) const override
Value * clone() const override
Definition: MatrixValue.hpp:144
MatrixValue & operator=(const MatrixValue &Other)
void writeQuotedToStream(std::ostream &OutStm) const override
Definition: MatrixValue.hpp:151
MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr)
Definition: MatrixValue.hpp:112
MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr, double InitValue)
Definition: MatrixValue.hpp:120
MatrixValue & operator=(const Value &Other) override
MatrixValue(const MatrixValue &Val)
Definition: MatrixValue.hpp:98
MatrixValue & operator=(Value &&Other) override
MatrixValue()
Definition: MatrixValue.hpp:92
Type getType() const override
Definition: MatrixValue.hpp:139
Definition: Matrix.hpp:58
Definition: Value.hpp:63
Type
Definition: Value.hpp:66
@ MATRIX
Definition: Value.hpp:66
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: ApplicationException.hpp:47