All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 /**
35  \file DoubleValue.hpp
36  \brief Header of ...
37 
38  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
39  */
40 
41 
42 #ifndef __DOUBLEVALUE_HPP___
43 #define __DOUBLEVALUE_HPP___
44 
46 #include <openfluid/dllexport.hpp>
47 
48 
49 namespace openfluid { namespace core {
50 /**
51 DoubleValue is a container for a signed double precision floating point value.\n
52 
53 \see Value
54 
55 \n
56 
57 <I>Example : declaration</I>
58 @code
59  // declaration of a DoubleValue, initialized to 0.0 by default
60  openfluid::core::DoubleValue Val1;
61 
62  // declaration of a DoubleValue, initialized to 1.357
63  openfluid::core::DoubleValue Val2(1.357);
64 @endcode
65 
66 
67 <I>Example : getting the contained value</I>
68 @code
69  double Tmp1;
70 
71  // using the get method
72  Tmp1 = Val1.get();
73 
74  // or using the cast operator
75  Tmp1 = Val1;
76 @endcode
77 
78 
79 <I>Example : setting the contained value</I>
80 @code
81  // using the set method
82  Val1.set(101.99);
83 @endcode
84 
85 
86 <I>Example : conversion from string</I>
87 @code
88  openfluid::core::StringValue StringVal("57.33");
89 
90  // to DoubleValue
91  Val1 = StringVal.toDoubleValue();
92 
93  // to double
94  double DblVal = StringVal.toDouble();
95 @endcode
96 
97 
98 <I>Example : conversion to string</I>
99 @code
100  std::string StdStrVal = Val1.toString();
101 @endcode
102 */
104 {
105  private:
106 
107  double m_Value;
108 
109  public:
110 
111  /**
112  Default constructor
113  */
114  DoubleValue() : m_Value(0.0) {};
115 
116  /**
117  Copy constructor
118  */
119  DoubleValue(const DoubleValue& Val) : SimpleValue(Val), m_Value(Val.m_Value) {};
120 
121 
122  /**
123  Constructor from plain old type
124  */
125  DoubleValue(const double& POD) : SimpleValue(), m_Value(POD) {};
126 
127  Value& operator =(const Value& Other);
128 
129  /**
130  Cast operator
131  */
132  operator double() const { return m_Value; };
133 
134  virtual ~DoubleValue() {};
135 
136  inline Type getType() const { return Value::DOUBLE; };
137 
138  Value* clone() const { return new DoubleValue(*this); };
139 
140  /**
141  Returns the double value as plain old type
142  @return the double value
143  */
144  inline double& get() { return m_Value; };
145 
146  /**
147  Returns the double value as a const plain old type
148  @return the double value
149  */
150  inline const double& get() const { return m_Value; };
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) { m_Value = Val; };
157 
158  void writeToStream(std::ostream& OutStm) const;
159 
160 };
161 
162 
163 } } // namespaces
164 
165 
166 #endif /* __DOUBLEVALUE_HPP___ */
DoubleValue(const DoubleValue &Val)
Definition: DoubleValue.hpp:119
Definition: Value.hpp:68
Definition: DoubleValue.hpp:103
Header of ...
Value * clone() const
Definition: DoubleValue.hpp:138
Type getType() const
Definition: DoubleValue.hpp:136
Type
Definition: Value.hpp:68
DoubleValue(const double &POD)
Definition: DoubleValue.hpp:125
Definition: SimpleValue.hpp:50
virtual ~DoubleValue()
Definition: DoubleValue.hpp:134
DoubleValue()
Definition: DoubleValue.hpp:114
Definition: Value.hpp:64
void set(const double &Val)
Definition: DoubleValue.hpp:156
#define DLLEXPORT
Definition: dllexport.hpp:51