fw4spl
fwAtoms/src/fwAtoms/Boolean.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwAtoms/registry/macros.hpp"
8 #include "fwAtoms/Boolean.hpp"
9 
10 fwAtomsRegisterMacro( ::fwAtoms::Boolean );
11 
12 namespace fwAtoms
13 {
14 
15 //------------------------------------------------------------------------------
16 
17 Boolean::sptr Boolean::New(std::string value)
18 {
19  Boolean::sptr valueSptr = Boolean::New();
20  valueSptr->m_value = (value.compare("true") == 0);
21  return valueSptr;
22 }
23 
24 //------------------------------------------------------------------------------
25 
26 Boolean::sptr Boolean::New(bool value)
27 {
28  Boolean::sptr valueSptr = Boolean::New();
29  valueSptr->m_value = value;
30  return valueSptr;
31 }
32 
33 //------------------------------------------------------------------------------
34 
35 std::string Boolean::getString() const
36 {
37  return m_value ? "true" : "false";
38 }
39 
40 //------------------------------------------------------------------------------
41 
42 void Boolean::setString(const std::string& value)
43 {
44  m_value = (!value.compare("true"));
45 }
46 
47 //------------------------------------------------------------------------------
48 
49 Base::sptr Boolean::clone() const
50 {
51  return Boolean::New(m_value);
52 }
53 
54 }
55 
fwAtoms contains basic objects to represent any other kind of object
virtual FWATOMS_API std::string getString() const override
Return the string representation of a value.
Represented a Boolean value.
static FWATOMS_API Boolean::sptr New(std::string value)
Construct an object storing a bool value.
virtual FWATOMS_API Base::sptr clone() const override
Returns a clone object.