Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
IntegerValue.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 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
46
47
48namespace 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" : ["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 Copy constructor
101 */
102 IntegerValue(IntegerValue&& Val) : SimpleValue(), m_Value(std::move(Val.m_Value))
103 { }
104
105 /**
106 Constructor from plain old type
107 */
108 IntegerValue(const long& POD) : SimpleValue(), m_Value(POD)
109 { }
110
111 IntegerValue& operator=(const Value& Other) override;
112
113 IntegerValue& operator=(Value&& Other) override;
114
115 IntegerValue& operator=(const IntegerValue& Other) = default;
116
118
119 virtual ~IntegerValue() = default;
120
121 /**
122 * Cast operator
123 */
124 operator long() const
125 {
126 return m_Value;
127 }
128
129 inline Type getType() const override
130 {
131 return Value::INTEGER;
132 }
133
134 Value* clone() const override
135 {
136 return new IntegerValue(*this);
137 };
138
139 bool convert(Value& Val) const override;
140
141 /**
142 Returns the integer value as a plain old type
143 @return the integer value
144 */
145 inline long get() const
146 {
147 return m_Value;
148 }
149
150 /**
151 Sets the plain old type long integer value
152 @param[in] Val the long integer value
153 */
154 inline void set(const long& Val)
155 {
156 m_Value = Val;
157 }
158
159 void writeToStream(std::ostream& OutStm) const override;
160
161 void writeQuotedToStream(std::ostream& OutStm) const override
162 {
163 writeToStream(OutStm);
164 }
165
166};
167
168
169} } // namespaces
170
171
172#endif /* __OPENFLUID_CORE_INTEGERVALUE_HPP__ */
Definition IntegerValue.hpp:80
bool convert(Value &Val) const override
IntegerValue(const long &POD)
Definition IntegerValue.hpp:108
IntegerValue & operator=(const IntegerValue &Other)=default
IntegerValue & operator=(IntegerValue &&Other)=default
void set(const long &Val)
Definition IntegerValue.hpp:154
Value * clone() const override
Definition IntegerValue.hpp:134
IntegerValue()
Definition IntegerValue.hpp:90
IntegerValue(const IntegerValue &Val)
Definition IntegerValue.hpp:96
void writeToStream(std::ostream &OutStm) const override
long get() const
Definition IntegerValue.hpp:145
IntegerValue & operator=(const Value &Other) override
IntegerValue & operator=(Value &&Other) override
virtual ~IntegerValue()=default
IntegerValue(IntegerValue &&Val)
Definition IntegerValue.hpp:102
Type getType() const override
Definition IntegerValue.hpp:129
void writeQuotedToStream(std::ostream &OutStm) const override
Definition IntegerValue.hpp:161
Definition SimpleValue.hpp:52
Definition Value.hpp:63
Type
Definition Value.hpp:66
#define OPENFLUID_API
Definition dllexport.hpp:86
Definition ApplicationException.hpp:47