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