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 
37  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __OPENFLUID_CORE_VECTORVALUE_HPP__
42 #define __OPENFLUID_CORE_VECTORVALUE_HPP__
43 
46 #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  Constructor, creates a vector containing Size elements, initialized with value InitValue
145  */
146  VectorValue(unsigned long Size, double InitValue) : CompoundValue(), Vector<double>(Size,InitValue)
147  { }
148 
149  /**
150  Constructor, creates a vector of size Size, containing Data
151  */
152  VectorValue(double* Data, unsigned long Size) : CompoundValue(), Vector<double>(Data,Size)
153  { }
154 
155  virtual ~VectorValue()
156  { }
157 
158  Value& operator =(const Value& Other);
159 
160  inline Type getType() const
161  { return Value::VECTOR; }
162 
163  Value* clone() const
164  { return new VectorValue(*this); };
165 
166  void writeToStream(std::ostream& OutStm) const;
167 
168  void writeQuotedToStream(std::ostream& OutStm) const
169  { writeToStream(OutStm); }
170 
171 };
172 
173 
174 } } // namespaces
175 
176 
177 
178 #endif /* __OPENFLUID_CORE_VECTORVALUE_HPP__ */
Definition: Value.hpp:64
VectorValue(double *Data, unsigned long Size)
Definition: VectorValue.hpp:152
Definition: VectorValue.hpp:118
VectorValue(unsigned long Size, double InitValue)
Definition: VectorValue.hpp:146
void writeQuotedToStream(std::ostream &OutStm) const
Definition: VectorValue.hpp:168
VectorValue(unsigned long Size)
Definition: VectorValue.hpp:140
Type getType() const
Definition: VectorValue.hpp:160
Definition: CompoundValue.hpp:50
Value * clone() const
Definition: VectorValue.hpp:163
Type
Definition: Value.hpp:68
virtual ~VectorValue()
Definition: VectorValue.hpp:155
Definition: ApplicationException.hpp:47
Definition: Value.hpp:68
#define OPENFLUID_API
Definition: dllexport.hpp:87
VectorValue(const VectorValue &Val)
Definition: VectorValue.hpp:132
VectorValue()
Definition: VectorValue.hpp:126
Definition: Vector.hpp:56