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" : ["Compute code", "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;
85 
86  public:
87 
88  /**
89  Default constructor
90  */
91  BooleanValue() : SimpleValue(), m_Value(false)
92  { }
93 
94  /**
95  Copy constructor
96  */
97  BooleanValue(const BooleanValue& Val) : SimpleValue(), m_Value(Val.m_Value)
98  { }
99 
100  /**
101  Constructor from plain old type
102  */
103  BooleanValue(const bool& POD) : SimpleValue(), m_Value(POD)
104  { }
105 
106  virtual ~BooleanValue()
107  { }
108 
109  Value& operator =(const Value& Other);
110 
111  /**
112  * Cast operator
113  */
114  operator bool() const
115  {
116  return m_Value;
117  }
118 
119  inline Type getType() const
120  {
121  return Value::BOOLEAN;
122  }
123 
124  Value* clone() const
125  { return new BooleanValue(*this); }
126 
127  bool convert(Value& Val) const;
128 
129  /**
130  Returns the boolean value as plain old type
131  @return the boolean value
132  */
133  inline bool get() const
134  {
135  return m_Value;
136  }
137 
138  /**
139  Sets the plain old type boolean value
140  @param[in] Val the boolean value
141  */
142  inline void set(const bool& Val)
143  {
144  m_Value = Val;
145  }
146 
147  void writeToStream(std::ostream& OutStm) const;
148 
149  void writeQuotedToStream(std::ostream& OutStm) const
150  {
151  writeToStream(OutStm);
152  }
153 
154 };
155 
156 
157 } } // namespaces
158 
159 
160 #endif /* __OPENFLUID_CORE_BOOLEANVALUE_HPP__ */
Value * clone() const
Definition: BooleanValue.hpp:124
Definition: SimpleValue.hpp:51
Definition: Value.hpp:64
void writeQuotedToStream(std::ostream &OutStm) const
Definition: BooleanValue.hpp:149
Definition: BooleanValue.hpp:80
Definition: ApplicationException.hpp:47
Type
Definition: Value.hpp:68
BooleanValue(const BooleanValue &Val)
Definition: BooleanValue.hpp:97
Type getType() const
Definition: BooleanValue.hpp:119
#define OPENFLUID_API
Definition: dllexport.hpp:86
BooleanValue()
Definition: BooleanValue.hpp:91
virtual ~BooleanValue()
Definition: BooleanValue.hpp:106
BooleanValue(const bool &POD)
Definition: BooleanValue.hpp:103
Definition: Value.hpp:68