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