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  @file IntegerValue.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_CORE_INTEGERVALUE_HPP__
41 #define __OPENFLUID_CORE_INTEGERVALUE_HPP__
42 
43 
45 #include <openfluid/dllexport.hpp>
46 
47 
48 namespace openfluid { namespace core {
49 
50 /**
51  IntegerValue is a container for a signed long integer value.\n
52 
53  @see Value
54 
55  <I>Example : declaration</I>
56  @snippet misc/values.cpp integer_decl
57 
58  <I>Example : getting the contained value</I>
59  @snippet misc/values.cpp integer_get
60 
61  <I>Example : setting the contained value</I>
62  @snippet misc/values.cpp integer_set
63 
64  <I>Example : conversion from string</I>
65  @snippet misc/values.cpp integer_fromstr
66 
67  <I>Example : conversion to string</I>
68  @snippet misc/values.cpp integer_tostr
69 
70  @cond OpenFLUID:completion
71  {
72  "contexts" : ["ANYWARE"],
73  "menupath" : ["Compute code", "Types", "Values"],
74  "title" : "IntegerValue",
75  "text" : "openfluid::core::IntegerValue %%SEL_START%%Val%%SEL_END%%"
76  }
77  @endcond
78 */
80 {
81  private:
82 
83  long m_Value;
84 
85  public:
86 
87  /**
88  Default constructor
89  */
90  IntegerValue() : SimpleValue(), m_Value(0)
91  { }
92 
93  /**
94  Copy constructor
95  */
96  IntegerValue(const IntegerValue& Val) : SimpleValue(), m_Value(Val.m_Value)
97  { }
98 
99  /**
100  Constructor from plain old type
101  */
102  IntegerValue(const long& POD) : SimpleValue(), m_Value(POD)
103  { }
104 
105  virtual ~IntegerValue()
106  { }
107 
108  Value& operator =(const Value& Other);
109 
110  /**
111  * Cast operator
112  */
113  operator long() const
114  {
115  return m_Value;
116  }
117 
118  inline Type getType() const
119  {
120  return Value::INTEGER;
121  }
122 
123  Value* clone() const
124  {
125  return new IntegerValue(*this);
126  };
127 
128  bool convert(Value& Val) const;
129 
130  /**
131  Returns the integer value as a plain old type
132  @return the integer value
133  */
134  inline long get() const
135  {
136  return m_Value;
137  }
138 
139  /**
140  Sets the plain old type long integer value
141  @param[in] Val the long integer value
142  */
143  inline void set(const long& Val)
144  {
145  m_Value = Val;
146  }
147 
148  void writeToStream(std::ostream& OutStm) const;
149 
150  void writeQuotedToStream(std::ostream& OutStm) const
151  {
152  writeToStream(OutStm);
153  }
154 
155 };
156 
157 
158 } } // namespaces
159 
160 
161 #endif /* __OPENFLUID_CORE_INTEGERVALUE_HPP__ */
Value * clone() const
Definition: IntegerValue.hpp:123
Definition: IntegerValue.hpp:79
IntegerValue(const IntegerValue &Val)
Definition: IntegerValue.hpp:96
Definition: SimpleValue.hpp:51
Definition: Value.hpp:64
Type getType() const
Definition: IntegerValue.hpp:118
IntegerValue(const long &POD)
Definition: IntegerValue.hpp:102
Definition: ApplicationException.hpp:47
Type
Definition: Value.hpp:68
IntegerValue()
Definition: IntegerValue.hpp:90
#define OPENFLUID_API
Definition: dllexport.hpp:86
virtual ~IntegerValue()
Definition: IntegerValue.hpp:105
Definition: Value.hpp:68
void writeQuotedToStream(std::ostream &OutStm) const
Definition: IntegerValue.hpp:150