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