OpenWalnut  1.4.0
WPropertyWrapper.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <string>
26 #include <boost/shared_ptr.hpp>
27 
28 #include "core/common/WProperties.h"
29 
30 #include "WPropertyWrapper.h"
31 
32 WPropertyWrapper::WPropertyWrapper( boost::shared_ptr< WPropertyBase > prop )
33  : m_prop( prop )
34 {
35 }
36 
37 std::string WPropertyWrapper::getName() const
38 {
39  return m_prop->getName();
40 }
41 
43 {
44  return m_prop->getDescription();
45 }
46 
47 bool WPropertyWrapper::getBool( bool notify ) const
48 {
49  return m_prop->toPropBool()->get( notify );
50 }
51 
52 int WPropertyWrapper::getInt( bool notify ) const
53 {
54  return m_prop->toPropInt()->get( notify );
55 }
56 
57 std::string WPropertyWrapper::getString( bool notify ) const
58 {
59  return m_prop->toPropString()->get( notify );
60 }
61 
62 double WPropertyWrapper::getDouble( bool notify ) const
63 {
64  return m_prop->toPropDouble()->get( notify );
65 }
66 
67 std::string WPropertyWrapper::getFilename( bool notify ) const
68 {
69  return m_prop->toPropFilename()->get( notify ).string();
70 }
71 
72 int WPropertyWrapper::getSelection( bool notify ) const
73 {
74  return static_cast< int >( m_prop->toPropSelection()->get( notify ).getItemIndexOfSelected( 0 ) );
75 }
76 
78 {
79  m_prop->toPropBool()->set( b, false );
80 }
81 
83 {
84  m_prop->toPropInt()->set( i, false );
85 }
86 
87 void WPropertyWrapper::setString( std::string const& s )
88 {
89  m_prop->toPropString()->set( s, false );
90 }
91 
93 {
94  m_prop->toPropDouble()->set( d, false );
95 }
96 
97 void WPropertyWrapper::setFilename( std::string const& fn )
98 {
99  m_prop->toPropFilename()->set( boost::filesystem::path( fn ), false );
100 }
101 
103 {
105  it.push_back( static_cast< std::size_t >( s ) );
106  WItemSelector sel = m_prop->toPropSelection()->get().newSelector( it );
107  m_prop->toPropSelection()->set( sel, false );
108 }
109 
111 {
112  m_prop->toPropTrigger()->set( WPVBaseTypes::PV_TRIGGER_TRIGGERED, false );
113 }
114 
116 {
117  m_prop->getUpdateCondition()->wait();
118 }
void setFilename(std::string const &fn)
Set the filename of the filename property.
bool getBool(bool notify=false) const
Get the value of a boolean property.
void waitForUpdate()
Wait for the property to update its value.
void setString(std::string const &s)
Set the value of a string property.
Trigger property: got triggered.
boost::shared_ptr< WPropertyBase > m_prop
The property.
std::vector< size_t > IndexList
The type used for storing index lists.
Definition: WItemSelector.h:63
void setDouble(double d)
Set the value of a double property.
void setBool(bool b)
Set the value of a boolean property.
void setSelection(int s)
Sets the selected item of a selection.
std::string getDescription() const
Return the description of the property.
std::string getString(bool notify=false) const
Get the value of a string property.
double getDouble(bool notify=false) const
Get the value of a double property.
void click()
Trigger a trigger property.
This class represents a subset of a WItemSelection.
Definition: WItemSelector.h:56
int getSelection(bool notify=false) const
Get the (first) selected item of a selection property.
WPropertyWrapper(boost::shared_ptr< WPropertyBase > prop)
Constructor.
std::string getName() const
Return the name of the property.
void setInt(int i)
Set the value of an integer property.
std::string getFilename(bool notify=false) const
Get the filename of a filename property.
int getInt(bool notify=false) const
Get the value of an integer property.