Documentation for OpenFLUID 2.2.0
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  <I>Example : declaration</I>
58  @snippet misc/values.cpp vector_decl
59 
60  <I>Example : getting the contained values</I>
61  @snippet misc/values.cpp vector_get
62 
63  <I>Example : getting all values as a c-style array of double</I>
64  @snippet misc/values.cpp vector_get_carray
65 
66  <I>Example : setting the contained values</I>
67  @snippet misc/values.cpp vector_set
68 
69  <I>Example : conversion from string</I>
70  @snippet misc/values.cpp vector_fromstr
71 
72  <I>Example : conversion to string</I>
73  @snippet misc/values.cpp vector_tostr
74 
75  @cond OpenFLUID:completion
76  {
77  "contexts" : ["ANYWARE"],
78  "menupath" : ["Types", "Values"],
79  "title" : "VectorValue",
80  "text" : "openfluid::core::VectorValue %%SEL_START%%Val%%SEL_END%%"
81  }
82  @endcond
83 */
84 class OPENFLUID_API VectorValue : public CompoundValue, public Vector<double>
85 {
86 
87  public:
88 
89  /**
90  Default constructor
91  */
92  VectorValue() : CompoundValue(), Vector<double>()
93  { }
94 
95  /**
96  Copy constructor
97  */
98  VectorValue(const VectorValue& Val) :
99  CompoundValue(),
100  Vector<double>(static_cast<const Vector<double>&>(Val))
101  { }
102 
103  /**
104  Move constructor
105  */
107  CompoundValue(),
108  Vector<double>(std::move(static_cast<const Vector<double>&>(Val)))
109  { }
110 
111  /**
112  Constructor, creates a vector containing Size elements
113  */
114  VectorValue(unsigned long Size) : CompoundValue(), Vector<double>(Size)
115  { }
116 
117  /**
118  Constructor, creates a vector containing Size elements, initialized with value InitValue
119  */
120  VectorValue(unsigned long Size, double InitValue) : CompoundValue(), Vector<double>(Size,InitValue)
121  { }
122 
123  /**
124  Constructor, creates a vector of size Size, containing Data
125  */
126  VectorValue(double* Data, unsigned long Size) : CompoundValue(), Vector<double>(Data,Size)
127  { }
128 
129  VectorValue& operator=(const Value& Other) override;
130 
131  VectorValue& operator=(Value&& Other) override;
132 
134 
136 
137  virtual ~VectorValue() = default;
138 
139  inline Type getType() const override
140  {
141  return Value::VECTOR;
142  }
143 
144  Value* clone() const override
145  {
146  return new VectorValue(*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_VECTORVALUE_HPP__ */
Definition: CompoundValue.hpp:52
Definition: Value.hpp:63
Type
Definition: Value.hpp:66
@ VECTOR
Definition: Value.hpp:66
Definition: VectorValue.hpp:85
VectorValue & operator=(Value &&Other) override
Type getType() const override
Definition: VectorValue.hpp:139
VectorValue()
Definition: VectorValue.hpp:92
VectorValue(unsigned long Size, double InitValue)
Definition: VectorValue.hpp:120
VectorValue(unsigned long Size)
Definition: VectorValue.hpp:114
VectorValue & operator=(VectorValue &&Other)
VectorValue & operator=(const Value &Other) override
Value * clone() const override
Definition: VectorValue.hpp:144
VectorValue & operator=(const VectorValue &Other)
virtual ~VectorValue()=default
void writeQuotedToStream(std::ostream &OutStm) const override
Definition: VectorValue.hpp:151
VectorValue(const VectorValue &Val)
Definition: VectorValue.hpp:98
VectorValue(VectorValue &&Val)
Definition: VectorValue.hpp:106
VectorValue(double *Data, unsigned long Size)
Definition: VectorValue.hpp:126
void writeToStream(std::ostream &OutStm) const override
Definition: Vector.hpp:59
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: ApplicationException.hpp:47