OpenWalnut  1.4.0
WPropertyWrapper.h
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 #ifndef WPROPERTYWRAPPER_H
26 #define WPROPERTYWRAPPER_H
27 
28 #include <string>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 #include "core/common/WPropertyBase.h"
35 
36 /**
37  * \class WPropertyWrapper
38  *
39  * Encapsulates a WProperty. Used to expose the properties to scripts.
40  */
42 {
43 public:
44  /**
45  * Constructor.
46  *
47  * \param prop The property.
48  */
49  explicit WPropertyWrapper( boost::shared_ptr< WPropertyBase > prop );
50 
51  /**
52  * Return the name of the property.
53  *
54  * \return The name of the property.
55  */
56  std::string getName() const;
57 
58  /**
59  * Return the description of the property.
60  *
61  * \return The description of the property.
62  */
63  std::string getDescription() const;
64 
65  /**
66  * Get the value of a boolean property.
67  *
68  * \param notify If true, informs the property that it was read.
69  * \return The current value of the property.
70  */
71  bool getBool( bool notify = false ) const;
72 
73  /**
74  * Get the value of an integer property.
75  *
76  * \param notify If true, informs the property that it was read.
77  * \return The current value of the property.
78  */
79  int getInt( bool notify = false ) const;
80 
81  /**
82  * Get the value of a string property.
83  *
84  * \param notify If true, informs the property that it was read.
85  * \return The current value of the property.
86  */
87  std::string getString( bool notify = false ) const;
88 
89  /**
90  * Get the value of a double property.
91  *
92  * \param notify If true, informs the property that it was read.
93  * \return The current value of the property.
94  */
95  double getDouble( bool notify = false ) const;
96 
97  /**
98  * Get the filename of a filename property.
99  *
100  * \param notify If true, informs the property that it was read.
101  * \return The current value of the property.
102  */
103  std::string getFilename( bool notify = false ) const;
104 
105  /**
106  * Get the (first) selected item of a selection property.
107  *
108  * \param notify If true, informs the property that it was read.
109  * \return The first of the currently selected items.
110  */
111  int getSelection( bool notify = false ) const;
112 
113  /**
114  * Set the value of a boolean property.
115  *
116  * \param b The new value.
117  */
118  void setBool( bool b );
119 
120  /**
121  * Set the value of an integer property.
122  *
123  * \param i The new value.
124  */
125  void setInt( int i );
126 
127  /**
128  * Set the value of a string property.
129  *
130  * \param s The new value.
131  */
132  void setString( std::string const& s );
133 
134  /**
135  * Set the value of a double property.
136  *
137  * \param d The new value.
138  */
139  void setDouble( double d );
140 
141  /**
142  * Set the filename of the filename property.
143  *
144  * \param fn The new value.
145  */
146  void setFilename( std::string const& fn );
147 
148  /**
149  * Sets the selected item of a selection. All other items will be deselected.
150  *
151  * \param s The index of the selected item.
152  */
153  void setSelection( int s );
154 
155  /**
156  * Trigger a trigger property.
157  */
158  void click();
159 
160  /**
161  * Wait for the property to update its value.
162  */
163  void waitForUpdate();
164 
165 private:
166  //! The property.
167  boost::shared_ptr< WPropertyBase > m_prop;
168 };
169 
170 #endif // WPROPERTYWRAPPER_H
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.
boost::shared_ptr< WPropertyBase > m_prop
The property.
void setDouble(double d)
Set the value of a double property.
void setBool(bool b)
Set the value of a boolean property.
Encapsulates a WProperty.
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.
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.