Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
DoubleValue.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of OpenFLUID software
4 Copyright(c) 2021-2026, INRAE
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 DoubleValue.hpp
35
36 @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37*/
38
39
40#ifndef __OPENFLUID_CORE_DOUBLEVALUE_HPP__
41#define __OPENFLUID_CORE_DOUBLEVALUE_HPP__
42
43
46
47
48namespace openfluid { namespace core {
49
50
51/**
52 DoubleValue is a container for a signed double precision floating point value.\n
53
54 @see Value
55
56 <I>Example : declaration</I>
57 @snippet misc/values.cpp double_decl
58
59 <I>Example : getting the contained value</I>
60 @snippet misc/values.cpp double_get
61
62 <I>Example : setting the contained value</I>
63 @snippet misc/values.cpp double_set
64
65 <I>Example : conversion from string</I>
66 @snippet misc/values.cpp double_fromstr
67
68 <I>Example : conversion to string</I>
69 @snippet misc/values.cpp double_tostr
70
71 @cond OpenFLUID:completion
72 {
73 "contexts" : ["ANYWARE"],
74 "menupath" : ["Types", "Values"],
75 "title" : "DoubleValue",
76 "text" : "openfluid::core::DoubleValue %%SEL_START%%Val%%SEL_END%%"
77 }
78 @endcond
79*/
81{
82 private:
83
84 double m_Value;
85
86
87 public:
88
89 /**
90 Default constructor
91 */
92 DoubleValue() noexcept : SimpleValue(), m_Value(0.0)
93 { }
94
95 /**
96 Copy constructor
97 */
98 DoubleValue(const DoubleValue& Val) noexcept : SimpleValue(), m_Value(Val.m_Value)
99 { }
100
101 /**
102 Move constructor
103 */
104 DoubleValue(DoubleValue&& Val) noexcept : SimpleValue(), m_Value(std::move(Val.m_Value))
105 { }
106
107 /**
108 Constructor from plain old type
109 */
110 DoubleValue(const double& POD) noexcept : SimpleValue(), m_Value(POD)
111 { }
112
113 DoubleValue& operator=(const Value& Other) override;
114
115 DoubleValue& operator=(Value&& Other) override;
116
118
120
121 virtual ~DoubleValue() = default;
122
123 /**
124 Cast operator
125 */
126 operator double() const
127 {
128 return m_Value;
129 }
130
131 inline Type getType() const override
132 {
133 return Value::DOUBLE;
134 }
135
136 Value* clone() const override
137 {
138 return new DoubleValue(*this);
139 }
140
141 bool convert(Value& Val) const override;
142
143 /**
144 Returns the double value as plain old type
145 @return the double value
146 */
147 inline double get() const
148 {
149 return m_Value;
150 }
151
152 /**
153 Sets the plain old type double value
154 @param[in] Val the double value
155 */
156 inline void set(const double& Val)
157 {
158 m_Value = Val;
159 }
160
161 void writeToStream(std::ostream& OutStm) const override;
162
163 void writeQuotedToStream(std::ostream& OutStm) const override
164 {
165 writeToStream(OutStm);
166 }
167
168 std::string toString() const
169 {
170 return Value::toString();
171 }
172
173 std::string toString(int Precision) const;
174
175};
176
177
178} } // namespaces
179
180
181#endif /* __OPENFLUID_CORE_DOUBLEVALUE_HPP__ */
Definition DoubleValue.hpp:81
bool convert(Value &Val) const override
DoubleValue() noexcept
Definition DoubleValue.hpp:92
DoubleValue & operator=(Value &&Other) override
DoubleValue(DoubleValue &&Val) noexcept
Definition DoubleValue.hpp:104
void writeToStream(std::ostream &OutStm) const override
DoubleValue(const double &POD) noexcept
Definition DoubleValue.hpp:110
void set(const double &Val)
Definition DoubleValue.hpp:156
double get() const
Definition DoubleValue.hpp:147
virtual ~DoubleValue()=default
Value * clone() const override
Definition DoubleValue.hpp:136
void writeQuotedToStream(std::ostream &OutStm) const override
Definition DoubleValue.hpp:163
std::string toString() const
Definition DoubleValue.hpp:168
Type getType() const override
Definition DoubleValue.hpp:131
DoubleValue(const DoubleValue &Val) noexcept
Definition DoubleValue.hpp:98
DoubleValue & operator=(DoubleValue &&)=default
DoubleValue & operator=(const DoubleValue &)=default
DoubleValue & operator=(const Value &Other) override
std::string toString(int Precision) const
Definition SimpleValue.hpp:52
Definition Value.hpp:63
Type
Definition Value.hpp:66
#define OPENFLUID_API
Definition dllexport.hpp:86
Definition ApplicationException.hpp:47