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