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" : ["Compute code", "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  Constructor, creates a Matrix containing ColsNbr x RowsNbr elements
104  */
105  MatrixValue(unsigned long ColsNbr,unsigned long RowsNbr) : CompoundValue(), Matrix<double>(ColsNbr,RowsNbr)
106  {
107 
108  }
109 
110  /**
111  Constructor, creates a Matrix containing ColsNbr x RowsNbr elements, initialized with value InitValue
112  */
113  MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr, double InitValue) :
114  CompoundValue(), Matrix<double>(ColsNbr,RowsNbr,InitValue)
115  {
116 
117  }
118 
119  virtual ~MatrixValue()
120  {
121 
122  }
123 
124  Value& operator =(const Value& Other);
125 
126  inline Type getType() const
127  {
128  return Value::MATRIX;
129  };
130 
131  Value* clone() const
132  {
133  return new MatrixValue(*this);
134  }
135 
136  void writeToStream(std::ostream& OutStm) const;
137 
138  void writeQuotedToStream(std::ostream& OutStm) const
139  {
140  writeToStream(OutStm);
141  }
142 
143 };
144 
145 
146 } } // namespaces
147 
148 
149 #endif /* __OPENFLUID_CORE_MATRIXVALUE_HPP__ */
void writeQuotedToStream(std::ostream &OutStm) const
Definition: MatrixValue.hpp:138
Type getType() const
Definition: MatrixValue.hpp:126
Definition: Value.hpp:64
Definition: CompoundValue.hpp:51
Definition: Matrix.hpp:55
Definition: Value.hpp:68
MatrixValue()
Definition: MatrixValue.hpp:92
Definition: ApplicationException.hpp:47
Type
Definition: Value.hpp:68
MatrixValue(const MatrixValue &Val)
Definition: MatrixValue.hpp:98
Definition: MatrixValue.hpp:84
MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr, double InitValue)
Definition: MatrixValue.hpp:113
MatrixValue(unsigned long ColsNbr, unsigned long RowsNbr)
Definition: MatrixValue.hpp:105
#define OPENFLUID_API
Definition: dllexport.hpp:86
Value * clone() const
Definition: MatrixValue.hpp:131
virtual ~MatrixValue()
Definition: MatrixValue.hpp:119