DoubleValue.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 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 
45 #include <openfluid/dllexport.hpp>
46 
47 
48 namespace 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" : ["Compute code", "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  public:
87 
88  /**
89  Default constructor
90  */
91  DoubleValue() : SimpleValue(), m_Value(0.0)
92  { }
93 
94  /**
95  Copy constructor
96  */
97  DoubleValue(const DoubleValue& Val) : SimpleValue(), m_Value(Val.m_Value)
98  { }
99 
100  /**
101  Constructor from plain old type
102  */
103  DoubleValue(const double& POD) : SimpleValue(), m_Value(POD)
104  { }
105 
106  virtual ~DoubleValue()
107  { }
108 
109  Value& operator =(const Value& Other);
110 
111  /**
112  Cast operator
113  */
114  operator double() const
115  {
116  return m_Value;
117  }
118 
119  inline Type getType() const
120  {
121  return Value::DOUBLE;
122  }
123 
124  Value* clone() const
125  {
126  return new DoubleValue(*this);
127  }
128 
129  bool convert(Value& Val) const;
130 
131  /**
132  Returns the double value as plain old type
133  @return the double value
134  */
135  inline double get() const
136  {
137  return m_Value;
138  }
139 
140  /**
141  Sets the plain old type double value
142  @param[in] Val the double value
143  */
144  inline void set(const double& Val)
145  {
146  m_Value = Val;
147  }
148 
149  void writeToStream(std::ostream& OutStm) const;
150 
151  void writeQuotedToStream(std::ostream& OutStm) const
152  {
153  writeToStream(OutStm);
154  }
155 
156 };
157 
158 
159 } } // namespaces
160 
161 
162 #endif /* __OPENFLUID_CORE_DOUBLEVALUE_HPP__ */
DoubleValue(const DoubleValue &Val)
Definition: DoubleValue.hpp:97
Type getType() const
Definition: DoubleValue.hpp:119
Value * clone() const
Definition: DoubleValue.hpp:124
Definition: Value.hpp:68
Definition: SimpleValue.hpp:51
Definition: Value.hpp:64
void writeQuotedToStream(std::ostream &OutStm) const
Definition: DoubleValue.hpp:151
DoubleValue(const double &POD)
Definition: DoubleValue.hpp:103
Definition: DoubleValue.hpp:80
Definition: ApplicationException.hpp:47
Type
Definition: Value.hpp:68
virtual ~DoubleValue()
Definition: DoubleValue.hpp:106
DoubleValue()
Definition: DoubleValue.hpp:91
#define OPENFLUID_API
Definition: dllexport.hpp:86