All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VectorValue.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 /**
35  \file VectorValue.hpp
36  \brief Header of ...
37 
38  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
39  */
40 
41 
42 #ifndef __VECTORVALUE_HPP___
43 #define __VECTORVALUE_HPP___
44 
47 #include <openfluid/dllexport.hpp>
48 
49 
50 namespace openfluid { namespace core {
51 
52 /**
53  VectorValue is a container for a 1D vector of signed double precision floating point values.\n
54 
55 \see Value
56 \see Vector
57 
58 \n
59 
60 <I>Example : declaration</I>
61 @code
62  // declaration of a VectorValue, empty by default
63  openfluid::core::VectorValue Val1;
64 
65  // declaration of a VectorValue of 7 elements, with values initialized to 0.0
66  openfluid::core::VectorValue Val2(7);
67 
68  // declaration of a VectorValue of 7 elements, with values initialized to 1.99
69  openfluid::core::VectorValue Val3(7,1.99);
70 @endcode
71 
72 
73 <I>Example : getting the contained values</I>
74 @code
75  double Tmp1;
76 
77  // using the get method
78  Tmp1 = Val1.get(2);
79 
80  // or using the [] operator
81  Tmp1 = Val1[2];
82 @endcode
83 
84 
85 <I>Example : getting all values as a c-style array of double</I>
86 @code
87  double DblArrayVal[];
88 
89  DblArrayVal = Val1.getData();
90 @endcode
91 
92 
93 <I>Example : setting the contained values</I>
94 @code
95  // using the set method
96  Val1.set(0,101.99);
97 
98  // or using the [] operator
99  Val1[0] = 101.99;
100 @endcode
101 
102 
103 <I>Example : conversion from string</I>
104 @code
105  openfluid::core::StringValue StringVal;
106  openfluid::core::VectorValue Val2;
107 
108  // to VectorValue, using a string values separator
109  StringVal.set("3;5;2.8;6;17.999923;1;1;1;1;1;2.11;2.12;2.13;2.14;2.15");
110  StringVal.toVectorValue(";",Val2);
111 @endcode
112 
113 
114 <I>Example : conversion to string</I>
115 @code
116  std::string StdStrVal = Val1.toString();
117 @endcode
118 */
119 class DLLEXPORT VectorValue : public CompoundValue, public Vector<double>
120 {
121 
122  public:
123 
124  /**
125  Default constructor
126  */
127  VectorValue() : CompoundValue(), Vector<double>() {};
128 
129  /**
130  Copy constructor
131  */
132  VectorValue(const VectorValue& Val) : CompoundValue(static_cast<const CompoundValue&>(Val)), Vector<double>(static_cast<const Vector<double>& >(Val)) {};
133 
134  /**
135  Constructor, creates a vector containing Size elements
136  */
137  VectorValue(unsigned long Size) : CompoundValue(), Vector<double>(Size) {};
138 
139  /**
140  Constructor, creates a vector containing Size elements, initialized with value InitValue
141  */
142  VectorValue(unsigned long Size, double InitValue) : CompoundValue(), Vector<double>(Size,InitValue) {};
143 
144  /**
145  Constructor, creates a vector of size Size, containing Data
146  */
147  VectorValue(double* Data, unsigned long Size) : CompoundValue(), Vector<double>(Data,Size) {};
148 
149  Value& operator =(const Value& Other);
150 
151  virtual ~VectorValue() {};
152 
153  inline Type getType() const { return Value::VECTOR; };
154 
155  Value* clone() const { return new VectorValue(*this); };
156 
157  void writeToStream(std::ostream& OutStm) const;
158 
159 };
160 
161 
162 } } // namespaces
163 
164 
165 
166 #endif /* __VECTORVALUE_HPP___ */
Definition: CompoundValue.hpp:53
Definition: Value.hpp:68
Type getType() const
Definition: VectorValue.hpp:153
virtual ~VectorValue()
Definition: VectorValue.hpp:151
VectorValue(double *Data, unsigned long Size)
Definition: VectorValue.hpp:147
VectorValue(unsigned long Size, double InitValue)
Definition: VectorValue.hpp:142
VectorValue(unsigned long Size)
Definition: VectorValue.hpp:137
Type
Definition: Value.hpp:68
Header of ...
Definition: Value.hpp:64
VectorValue()
Definition: VectorValue.hpp:127
Value * clone() const
Definition: VectorValue.hpp:155
Definition: VectorValue.hpp:119
Definition: Vector.hpp:50
VectorValue(const VectorValue &Val)
Definition: VectorValue.hpp:132
#define DLLEXPORT
Definition: dllexport.hpp:51