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